Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Blammo.Logging
Synopsis
- data LogLevel
- data Logger
- data Message = Text :# [SeriesElem]
- (.=) :: (KeyValue e kv, ToJSON v) => Key -> v -> kv
- data Series
- class Monad m => MonadLogger (m :: Type -> Type) where
- monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> m ()
- class (MonadLogger m, MonadIO m) => MonadLoggerIO (m :: Type -> Type) where
- logDebug :: (HasCallStack, MonadLogger m) => Message -> m ()
- logInfo :: (HasCallStack, MonadLogger m) => Message -> m ()
- logWarn :: (HasCallStack, MonadLogger m) => Message -> m ()
- logError :: (HasCallStack, MonadLogger m) => Message -> m ()
- logOther :: (HasCallStack, MonadLogger m) => LogLevel -> Message -> m ()
- type LogSource = Text
- logDebugNS :: (HasCallStack, MonadLogger m) => LogSource -> Message -> m ()
- logInfoNS :: (HasCallStack, MonadLogger m) => LogSource -> Message -> m ()
- logWarnNS :: (HasCallStack, MonadLogger m) => LogSource -> Message -> m ()
- logErrorNS :: (HasCallStack, MonadLogger m) => LogSource -> Message -> m ()
- logOtherNS :: (HasCallStack, MonadLogger m) => LogSource -> LogLevel -> Message -> m ()
Documentation
Constructors
LevelDebug | |
LevelInfo | |
LevelWarn | |
LevelError | |
LevelOther Text |
Re-exports from Control.Monad.Logger.Aeson
Messages
A Message
captures a textual component and a metadata component. The
metadata component is a list of SeriesElem
to support tacking on arbitrary
structured data to a log message.
With the OverloadedStrings
extension enabled, Message
values can be
constructed without metadata fairly conveniently, just as if we were using
Text
directly:
logDebug "Some log message without metadata"
Metadata may be included in a Message
via the :#
constructor:
logDebug
$ "Some log message with metadata":#
[ "bloorp".=
(42 ::Int
) , "bonk".=
("abc" ::Text
) ]
The mnemonic for the :#
constructor is that the #
symbol is sometimes
referred to as a hash, a JSON object can be thought of as a hash map, and
so with :#
(and enough squinting), we are cons
-ing a textual message onto
a JSON object. Yes, this mnemonic isn't well-typed, but hopefully it still
helps!
Since: monad-logger-aeson-0.1.0.0
Constructors
Text :# [SeriesElem] infixr 5 |
Instances
IsString Message | |
Defined in Control.Monad.Logger.Aeson.Internal Methods fromString :: String -> Message # | |
ToLogStr Message | |
Defined in Control.Monad.Logger.Aeson.Internal |
A series of values that, when encoded, should be separated by
commas. Since 0.11.0.0, the .=
operator is overloaded to create
either (Text, Value)
or Series
. You can use Series when
encoding directly to a bytestring builder as in the following
example:
toEncoding (Person name age) = pairs ("name" .= name <> "age" .= age)
Classes
class Monad m => MonadLogger (m :: Type -> Type) where #
A Monad
which has the ability to log messages in some manner.
Minimal complete definition
Nothing
Instances
class (MonadLogger m, MonadIO m) => MonadLoggerIO (m :: Type -> Type) where #
An extension of MonadLogger
for the common case where the logging action
is a simple IO
action. The advantage of using this typeclass is that the
logging function itself can be extracted as a first-class value, which can
make it easier to manipulate monad transformer stacks, as an example.
Since: monad-logger-0.3.10
Minimal complete definition
Nothing
Methods
askLoggerIO :: m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
Request the logging function itself.
Since: monad-logger-0.3.10
Instances
Common logging functions
Import Control.Monad.Logger.Aeson if you want more
Implicit call stack, no LogSource
logDebug :: (HasCallStack, MonadLogger m) => Message -> m () #
logInfo :: (HasCallStack, MonadLogger m) => Message -> m () #
See logDebug
Since: monad-logger-aeson-0.1.0.0
logWarn :: (HasCallStack, MonadLogger m) => Message -> m () #
See logDebug
Since: monad-logger-aeson-0.1.0.0
logError :: (HasCallStack, MonadLogger m) => Message -> m () #
See logDebug
Since: monad-logger-aeson-0.1.0.0
logOther :: (HasCallStack, MonadLogger m) => LogLevel -> Message -> m () #
See logDebug
Since: monad-logger-aeson-0.1.0.0
Implicit call stack, with LogSource
logDebugNS :: (HasCallStack, MonadLogger m) => LogSource -> Message -> m () #
See logDebugCS
Since: monad-logger-aeson-0.1.0.0
logInfoNS :: (HasCallStack, MonadLogger m) => LogSource -> Message -> m () #
See logDebugNS
Since: monad-logger-aeson-0.1.0.0
logWarnNS :: (HasCallStack, MonadLogger m) => LogSource -> Message -> m () #
See logDebugNS
Since: monad-logger-aeson-0.1.0.0
logErrorNS :: (HasCallStack, MonadLogger m) => LogSource -> Message -> m () #
See logDebugNS
Since: monad-logger-aeson-0.1.0.0
logOtherNS :: (HasCallStack, MonadLogger m) => LogSource -> LogLevel -> Message -> m () #
See logDebugNS
Since: monad-logger-aeson-0.1.0.0