Copyright | Copyright (c) 2014-2015 PivotCloud, Inc. |
---|---|
License | Apache License, Version 2.0 |
Maintainer | Lars Kuhtz <lkuhtz@pivotmail.com> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
This module provides a logger that implements the logger interface that is defined in System.Logger.Types.
If you want to roll your own implementation you may use the code in this module as an example and starting point.
- data LoggerConfig = LoggerConfig {}
- loggerConfigQueueSize :: Lens' LoggerConfig Int
- loggerConfigThreshold :: Lens' LoggerConfig LogLevel
- loggerConfigScope :: Lens' LoggerConfig LogScope
- defaultLoggerConfig :: LoggerConfig
- validateLoggerConfig :: ConfigValidation LoggerConfig λ
- pLoggerConfig :: MParser LoggerConfig
- data Logger a
- loggerScope :: Lens' (Logger a) LogScope
- loggerThreshold :: Lens' (Logger a) LogLevel
- createLogger :: MonadIO μ => LoggerConfig -> LoggerBackend a -> μ (Logger a)
- releaseLogger :: MonadIO μ => Logger a -> μ ()
- withLogger :: (MonadIO μ, MonadBaseControl IO μ) => LoggerConfig -> LoggerBackend a -> (Logger a -> μ α) -> μ α
- loggCtx :: (Show a, Typeable a, NFData a) => Logger a -> LogFunctionIO a
- withLogFunction :: (Show a, Typeable a, NFData a, MonadIO μ, MonadBaseControl IO μ) => LoggerConfig -> LoggerBackend a -> (LogFunctionIO a -> μ α) -> μ α
- type LoggerT a = LoggerCtxT (Logger a)
- runLoggerT :: LoggerT a m α -> Logger a -> m α
- runLogT :: (MonadBaseControl IO m, MonadIO m) => LoggerConfig -> LoggerBackend msg -> LoggerT msg m α -> m α
Logger Configuration
data LoggerConfig Source
Logger Configuration
LoggerConfig | |
|
Logger
loggerScope :: Lens' (Logger a) LogScope Source
loggerThreshold :: Lens' (Logger a) LogLevel Source
createLogger :: MonadIO μ => LoggerConfig -> LoggerBackend a -> μ (Logger a) Source
releaseLogger :: MonadIO μ => Logger a -> μ () Source
withLogger :: (MonadIO μ, MonadBaseControl IO μ) => LoggerConfig -> LoggerBackend a -> (Logger a -> μ α) -> μ α Source
Provide a computation with a Logger
.
Here is an example how this can be used to run a computation
with a MonadLog
constraint:
withConsoleLogger ∷ (MonadIO m, MonadBaseControl IO m) ⇒ LogLevel → (LoggerT T.Text m α) → m α withConsoleLogger level = do backend ← mkHandleLoggerBackend $ config ^. loggerConfigBackend withLogger config backend ∘ flip runLoggerT where config = defaultLoggerConfig & loggerConfigThreshold .~ level
withLogFunction :: (Show a, Typeable a, NFData a, MonadIO μ, MonadBaseControl IO μ) => LoggerConfig -> LoggerBackend a -> (LogFunctionIO a -> μ α) -> μ α Source
For simple cases, when the logger threshold and the logger scope is constant this function can be used to directly initialize a log function.
LoggerT Monad Transformer
type LoggerT a = LoggerCtxT (Logger a) Source
runLoggerT :: LoggerT a m α -> Logger a -> m α Source
runLogT :: (MonadBaseControl IO m, MonadIO m) => LoggerConfig -> LoggerBackend msg -> LoggerT msg m α -> m α Source