| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Effectful.Logger.Dynamic
Description
Dynamic effect for Control.Monad.Logger.
Since: 0.1
Synopsis
- data Logger (a :: Type -> Type) b where
- loggerLog :: forall (es :: [Effect]) msg. (HasCallStack, Logger :> es, ToLogStr msg) => Loc -> LogSource -> LogLevel -> msg -> Eff es ()
- data LogLevel
- type LogLine = (Loc, LogSource, LogLevel, LogStr)
- type LogSource = Text
- data LogStr
- class ToLogStr msg where
- fromLogStr :: LogStr -> ByteString
- logTrace :: Q Exp
- logDebug :: Q Exp
- logInfo :: Q Exp
- logWarn :: Q Exp
- logError :: Q Exp
- logFatal :: Q Exp
- logOther :: Text -> Q Exp
- logTraceSH :: Q Exp
- logDebugSH :: Q Exp
- logInfoSH :: Q Exp
- logWarnSH :: Q Exp
- logErrorSH :: Q Exp
- logFatalSH :: Q Exp
- logOtherSH :: Text -> Q Exp
- logTraceS :: Q Exp
- logDebugS :: Q Exp
- logInfoS :: Q Exp
- logWarnS :: Q Exp
- logErrorS :: Q Exp
- logFatalS :: Q Exp
- logOtherS :: Q Exp
- liftLoc :: Loc -> Q Exp
- logTraceN :: forall (es :: [Effect]). Logger :> es => Text -> Eff es ()
- logDebugN :: forall (es :: [Effect]). Logger :> es => Text -> Eff es ()
- logInfoN :: forall (es :: [Effect]). Logger :> es => Text -> Eff es ()
- logWarnN :: forall (es :: [Effect]). Logger :> es => Text -> Eff es ()
- logErrorN :: forall (es :: [Effect]). Logger :> es => Text -> Eff es ()
- logFatalN :: forall (es :: [Effect]). Logger :> es => Text -> Eff es ()
- logOtherN :: forall (es :: [Effect]). Logger :> es => LogLevel -> Text -> Eff es ()
- logWithoutLoc :: forall (es :: [Effect]) msg. (HasCallStack, Logger :> es, ToLogStr msg) => LogSource -> LogLevel -> msg -> Eff es ()
- logTraceNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es ()
- logDebugNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es ()
- logInfoNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es ()
- logWarnNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es ()
- logErrorNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es ()
- logFatalNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es ()
- logOtherNS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => LogSource -> LogLevel -> Text -> Eff es ()
- logTraceCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es ()
- logDebugCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es ()
- logInfoCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es ()
- logWarnCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es ()
- logErrorCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es ()
- logFatalCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es ()
- logOtherCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> LogLevel -> Text -> Eff es ()
- defaultLogStr :: Loc -> LogSource -> LogLevel -> LogStr -> LogStr
- data Loc = Loc {}
- defaultLoc :: Loc
- defaultOutput :: HasCallStack => Handle -> Loc -> LogSource -> LogLevel -> LogStr -> IO ()
- guardLevel :: (Applicative f, HasCallStack) => LogLevel -> LogLevel -> (HasCallStack => f ()) -> f ()
- shouldLog :: LogLevel -> LogLevel -> Bool
- data LogFormatter = MkLogFormatter {
- locStrategy :: !LocStrategy
- newline :: !Bool
- threadLabel :: !Bool
- timezone :: !Bool
- defaultLogFormatter :: Loc -> LogFormatter
- data LocStrategy
- = LocPartial !Loc
- | LocStable !Loc
- | LocNone
- formatLog :: forall msg (es :: [Effect]). (Concurrent :> es, HasCallStack, Time :> es, ToLogStr msg) => LogFormatter -> LogLevel -> msg -> Eff es LogStr
- _LevelTrace :: Prism' LogLevel ()
- _LevelInfo :: Prism' LogLevel ()
- _LevelDebug :: Prism' LogLevel ()
- _LevelWarn :: Prism' LogLevel ()
- _LevelError :: Prism' LogLevel ()
- _LevelOther :: Prism' LogLevel Text
- _LevelFatal :: Prism' LogLevel ()
Effect
data Logger (a :: Type -> Type) b where Source #
Dynamic logging effect for Control.Monad.Logger.
Since: 0.1
Constructors
| LoggerLog :: forall msg (a :: Type -> Type). ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> Logger a () |
Instances
| ShowEffect Logger Source # | Since: 0.1 |
Defined in Effectful.Logger.Dynamic | |
| type DispatchOf Logger Source # | Since: 0.1 |
Defined in Effectful.Logger.Dynamic | |
loggerLog :: forall (es :: [Effect]) msg. (HasCallStack, Logger :> es, ToLogStr msg) => Loc -> LogSource -> LogLevel -> msg -> Eff es () Source #
Writes a log.
Since: 0.1
Types
Since: 0.1
Constructors
| LevelTrace | Since: 0.1 |
| LevelDebug | Since: 0.1 |
| LevelInfo | Since: 0.1 |
| LevelWarn | Since: 0.1 |
| LevelError | Since: 0.1 |
| LevelFatal | Since: 0.1 |
| LevelOther Text | Since: 0.1 |
Instances
Re-export from fast-logger
Log message builder. Use (<>) to append two LogStr in O(1).
class ToLogStr msg where Source #
Types that can be converted to a LogStr. Instances for
types from the text library use a UTF-8 encoding. Instances
for numerical types use a decimal encoding.
Instances
| ToLogStr Builder Source # | |
| ToLogStr ByteString Source # | |
Defined in System.Log.FastLogger.LogStr Methods toLogStr :: ByteString -> LogStr Source # | |
| ToLogStr ByteString Source # | |
Defined in System.Log.FastLogger.LogStr Methods toLogStr :: ByteString -> LogStr Source # | |
| ToLogStr ShortByteString Source # | |
Defined in System.Log.FastLogger.LogStr Methods toLogStr :: ShortByteString -> LogStr Source # | |
| ToLogStr LogStr Source # | |
| ToLogStr Int16 Source # | Since: fast-logger-2.4.14 |
| ToLogStr Int32 Source # | Since: fast-logger-2.4.14 |
| ToLogStr Int64 Source # | Since: fast-logger-2.4.14 |
| ToLogStr Int8 Source # | Since: fast-logger-2.4.14 |
| ToLogStr Word16 Source # | Since: fast-logger-2.4.14 |
| ToLogStr Word32 Source # | Since: fast-logger-2.4.14 |
| ToLogStr Word64 Source # | Since: fast-logger-2.4.14 |
| ToLogStr Word8 Source # | Since: fast-logger-2.4.14 |
| ToLogStr Text Source # | |
| ToLogStr Text Source # | |
| ToLogStr Integer Source # | Since: fast-logger-2.4.14 |
| ToLogStr String Source # | |
| ToLogStr Double Source # | Since: fast-logger-2.4.14 |
| ToLogStr Float Source # | Since: fast-logger-2.4.14 |
| ToLogStr Int Source # | Since: fast-logger-2.4.14 |
| ToLogStr Word Source # | Since: fast-logger-2.4.14 |
fromLogStr :: LogStr -> ByteString Source #
Converting LogStr to ByteString.
TH logging
Generates a function that takes a Text and logs a LevelDebug message.
Usage:
$(logDebug) "This is a debug log message"
Since: 0.1
logOther :: Text -> Q Exp Source #
Generates a function that takes a Text and logs a LevelOther message.
Usage:
$(logOther "My new level") "This is a log message"
Since: 0.1
TH logging of showable values
logTraceSH :: Q Exp Source #
See logDebugSH
Since: 0.1
logDebugSH :: Q Exp Source #
Generates a function that takes a 'Show a => a' and logs a LevelDebug
message. Usage:
$(logDebugSH) (Just "This is a debug log message")
Since: 0.1
logErrorSH :: Q Exp Source #
See logDebugSH
Since: 0.1
logFatalSH :: Q Exp Source #
See logDebugSH
Since: 0.1
logOtherSH :: Text -> Q Exp Source #
Generates a function that takes a 'Show a => a' and logs a LevelOther
message. Usage:
$(logOtherSH "My new level") "This is a log message"
Since: 0.1
TH logging with source
Generates a function that takes a LogSource and Text and logs a
LevelDebug message. Usage:
$logDebugS "SomeSource" "This is a debug log message"
Since: 0.1
Generates a function that takes a LogSource, a level name and a Text
and logs a LevelOther message. Usage:
$logOtherS "SomeSource" "My new level" "This is a log message"
Since: 0.1
TH util
Non-TH logging
logOtherN :: forall (es :: [Effect]). Logger :> es => LogLevel -> Text -> Eff es () Source #
Since: 0.1
Non-TH logging with source
logWithoutLoc :: forall (es :: [Effect]) msg. (HasCallStack, Logger :> es, ToLogStr msg) => LogSource -> LogLevel -> msg -> Eff es () Source #
Since: 0.1
logTraceNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es () Source #
Since: 0.1
logDebugNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es () Source #
Since: 0.1
logInfoNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es () Source #
Since: 0.1
logWarnNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es () Source #
Since: 0.1
logErrorNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es () Source #
Since: 0.1
logFatalNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es () Source #
Since: 0.1
logOtherNS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => LogSource -> LogLevel -> Text -> Eff es () Source #
Since: 0.1
Callstack logging
logTraceCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es () Source #
See logDebugCS
Since: 0.1
logDebugCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es () Source #
logInfoCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es () Source #
See logDebugCS
Since: 0.1
logWarnCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es () Source #
See logDebugCS
Since: 0.1
logErrorCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es () Source #
See logDebugCS
Since: 0.1
logFatalCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es () Source #
See logDebugCS
Since: 0.1
logOtherCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> LogLevel -> Text -> Eff es () Source #
See logDebugCS
Since: 0.1
utilities for defining your own loggers
A location within a source file.
Constructors
| Loc | |
Fields
| |
Instances
| Data Loc # | |||||
Defined in GHC.Internal.TH.Syntax Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Loc -> c Loc # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Loc # dataTypeOf :: Loc -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Loc) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Loc) # gmapT :: (forall b. Data b => b -> b) -> Loc -> Loc # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Loc -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Loc -> r # gmapQ :: (forall d. Data d => d -> u) -> Loc -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Loc -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Loc -> m Loc # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Loc -> m Loc # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Loc -> m Loc # | |||||
| Generic Loc # | |||||
Defined in GHC.Internal.TH.Syntax Associated Types
| |||||
| Show Loc # | |||||
| Eq Loc # | |||||
| Ord Loc # | |||||
| Lift Loc # | Since: template-haskell-2.22.1.0 | ||||
| type Rep Loc # | |||||
Defined in GHC.Internal.TH.Syntax type Rep Loc = D1 ('MetaData "Loc" "GHC.Internal.TH.Syntax" "ghc-internal" 'False) (C1 ('MetaCons "Loc" 'PrefixI 'True) ((S1 ('MetaSel ('Just "loc_filename") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "loc_package") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)) :*: (S1 ('MetaSel ('Just "loc_module") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: (S1 ('MetaSel ('Just "loc_start") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CharPos) :*: S1 ('MetaSel ('Just "loc_end") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CharPos))))) | |||||
defaultLoc :: Loc Source #
dummy location, used with logWithoutLoc
Since: 0.1
defaultOutput :: HasCallStack => Handle -> Loc -> LogSource -> LogLevel -> LogStr -> IO () Source #
A default implementation of loggerLog that accepts a file
handle as the first argument.
This is used in the definition of runStdoutLoggingT:
runStdoutLoggingT::MonadIOm =>LoggingTm a -> m arunStdoutLoggingTaction =runLoggingTaction (defaultOutputstdout)
Since: 0.1
Level checks
Arguments
| :: (Applicative f, HasCallStack) | |
| => LogLevel | The configured log level to check against. |
| -> LogLevel | The log level for this action. |
| -> (HasCallStack => f ()) | The logging action to run if the level passes. |
| -> f () |
guardLevel configLvl lvl m runs m iff .shouldLog configLvl lvl
Since: 0.1
Arguments
| :: LogLevel | The configured log level to check against. |
| -> LogLevel | Level for this log |
| -> Bool | Whether we should log |
shouldLog configLvl lvl returns true iff configLvl <= lvl. Uses
LogLevel's built-in ordering. The ordering is thus:
LevelTrace
< LevelDebug
< LevelInfo
< LevelWarn
< LevelError
< LevelFatal
< LevelOther "<any>"
In other words, LogLevel's usual Ord is respected. Note that
LevelOther "custom" sits at the the highest level and compares via
Text's Ord, just like LogLevel's usual Ord.
Since: 0.1
Formatting
data LogFormatter Source #
Formatter for logs.
Since: 0.1
Constructors
| MkLogFormatter | |
Fields
| |
Instances
| Generic LogFormatter Source # | |||||
Defined in Effectful.Logger.Utils Associated Types
| |||||
| Show LogFormatter Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils Methods showsPrec :: Int -> LogFormatter -> ShowS # show :: LogFormatter -> String # showList :: [LogFormatter] -> ShowS # | |||||
| Eq LogFormatter Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils | |||||
| (k ~ A_Lens, a ~ LocStrategy, b ~ LocStrategy) => LabelOptic "locStrategy" k LogFormatter LogFormatter a b Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils Methods labelOptic :: Optic k NoIx LogFormatter LogFormatter a b Source # | |||||
| (k ~ A_Lens, a ~ Bool, b ~ Bool) => LabelOptic "newline" k LogFormatter LogFormatter a b Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils Methods labelOptic :: Optic k NoIx LogFormatter LogFormatter a b Source # | |||||
| (k ~ A_Lens, a ~ Bool, b ~ Bool) => LabelOptic "threadLabel" k LogFormatter LogFormatter a b Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils Methods labelOptic :: Optic k NoIx LogFormatter LogFormatter a b Source # | |||||
| (k ~ A_Lens, a ~ Bool, b ~ Bool) => LabelOptic "timezone" k LogFormatter LogFormatter a b Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils Methods labelOptic :: Optic k NoIx LogFormatter LogFormatter a b Source # | |||||
| type Rep LogFormatter Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils type Rep LogFormatter = D1 ('MetaData "LogFormatter" "Effectful.Logger.Utils" "logger-effectful-0.1-inplace" 'False) (C1 ('MetaCons "MkLogFormatter" 'PrefixI 'True) ((S1 ('MetaSel ('Just "locStrategy") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LocStrategy) :*: S1 ('MetaSel ('Just "newline") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :*: (S1 ('MetaSel ('Just "threadLabel") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "timezone") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)))) | |||||
defaultLogFormatter :: Loc -> LogFormatter Source #
LogFormatter with:
locStrategy=LocPartiallocnewline=TruethreadLabel=Falsetimezone=False
Since: 0.1
data LocStrategy Source #
Determines how we log location data.
Since: 0.1
Constructors
| LocPartial !Loc | Logs the location with filename, line, col. Since: 0.1 |
| LocStable !Loc | Logs the location with filename. Since: 0.1 |
| LocNone | No location logging. Since: 0.1 |
Instances
| Generic LocStrategy Source # | |||||
Defined in Effectful.Logger.Utils Associated Types
| |||||
| Show LocStrategy Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils Methods showsPrec :: Int -> LocStrategy -> ShowS # show :: LocStrategy -> String # showList :: [LocStrategy] -> ShowS # | |||||
| Eq LocStrategy Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils | |||||
| type Rep LocStrategy Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils type Rep LocStrategy = D1 ('MetaData "LocStrategy" "Effectful.Logger.Utils" "logger-effectful-0.1-inplace" 'False) (C1 ('MetaCons "LocPartial" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Loc)) :+: (C1 ('MetaCons "LocStable" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Loc)) :+: C1 ('MetaCons "LocNone" 'PrefixI 'False) (U1 :: Type -> Type))) | |||||
Arguments
| :: forall msg (es :: [Effect]). (Concurrent :> es, HasCallStack, Time :> es, ToLogStr msg) | |
| => LogFormatter | Formatter to use. |
| -> LogLevel | The level in which to log. |
| -> msg | Message. |
| -> Eff es LogStr | Formatted LogStr. |
Produces a formatted LogStr in terms of:
- Static Concurrent.
- Dynamic Time.
Example
-- [timestamp][thread_label][code_loc][level] msg [2022-02-08 10:20:05][thread-label][filename:1:2][Warn] msg
Since: 0.1
Optics
_LevelTrace :: Prism' LogLevel () Source #
Since: 0.1
_LevelInfo :: Prism' LogLevel () Source #
Since: 0.1
_LevelDebug :: Prism' LogLevel () Source #
Since: 0.1
_LevelWarn :: Prism' LogLevel () Source #
Since: 0.1
_LevelError :: Prism' LogLevel () Source #
Since: 0.1
_LevelFatal :: Prism' LogLevel () Source #
Since: 0.1