Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Logger
- class HasLogger env where
- withLogger :: MonadUnliftIO m => LogSettings -> (Logger -> m a) -> m a
- newLogger :: MonadIO m => LogSettings -> m Logger
- flushLogger :: (MonadIO m, MonadReader env m, HasLogger env) => m ()
- pushLogger :: (MonadIO m, MonadReader env m, HasLogger env) => Text -> m ()
- pushLoggerLn :: (MonadIO m, MonadReader env m, HasLogger env) => Text -> m ()
- getLoggerLogSettings :: Logger -> LogSettings
- getLoggerReformat :: Logger -> LogLevel -> ByteString -> ByteString
- getLoggerShouldLog :: Logger -> LogSource -> LogLevel -> Bool
- getLoggerShouldColor :: Logger -> Bool
- pushLogStrLn :: MonadIO m => Logger -> LogStr -> m ()
- flushLogStr :: MonadIO m => Logger -> m ()
- runLogAction :: (MonadIO m, ToLogStr msg) => Logger -> Loc -> LogSource -> LogLevel -> msg -> m ()
- newTestLogger :: MonadIO m => LogSettings -> m Logger
- data LoggedMessage = LoggedMessage {}
- getLoggedMessages :: (MonadIO m, MonadReader env m, HasLogger env) => m [Either String LoggedMessage]
- getLoggedMessagesLenient :: (MonadIO m, MonadReader env m, HasLogger env) => m [LoggedMessage]
- getLoggedMessagesUnsafe :: (HasCallStack, MonadIO m, MonadReader env m, HasLogger env) => m [LoggedMessage]
Documentation
withLogger :: MonadUnliftIO m => LogSettings -> (Logger -> m a) -> m a Source #
Initialize logging, pass a Logger
to the callback, and clean up at the end
Applications should avoid calling this more than once in their lifecycle.
flushLogger :: (MonadIO m, MonadReader env m, HasLogger env) => m () Source #
pushLogger :: (MonadIO m, MonadReader env m, HasLogger env) => Text -> m () Source #
pushLoggerLn :: (MonadIO m, MonadReader env m, HasLogger env) => Text -> m () Source #
getLoggerReformat :: Logger -> LogLevel -> ByteString -> ByteString Source #
getLoggerShouldColor :: Logger -> Bool Source #
flushLogStr :: MonadIO m => Logger -> m () Source #
runLogAction :: (MonadIO m, ToLogStr msg) => Logger -> Loc -> LogSource -> LogLevel -> msg -> m () Source #
Testing
newTestLogger :: MonadIO m => LogSettings -> m Logger Source #
Create a Logger
that will capture log messages instead of logging them
See Blammo.Logging.LoggedMessages for more details.
data LoggedMessage #
This type is the Haskell representation of each JSON log message produced by this library.
While we never interact with this type directly when logging messages with
monad-logger-aeson
, we may wish to use this type if we are
parsing/processing log files generated by this library.
Since: monad-logger-aeson-0.1.0.0
Instances
getLoggedMessages :: (MonadIO m, MonadReader env m, HasLogger env) => m [Either String LoggedMessage] Source #
Return the logged messages if newTestLogger
was used
If not, the empty list is returned.
getLoggedMessagesLenient :: (MonadIO m, MonadReader env m, HasLogger env) => m [LoggedMessage] Source #
getLoggedMessages
but ignore any messages that fail to parse
getLoggedMessagesUnsafe :: (HasCallStack, MonadIO m, MonadReader env m, HasLogger env) => m [LoggedMessage] Source #
getLoggedMessages
but throwString
if any messages failed to parse