Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Tinylog convenience things.
Synopsis
- module System.Logger
- data LogFormat
- = JSON
- | Plain
- | Netstring
- | StructuredJSON
- mkLogger :: Level -> Maybe (Last Bool) -> Maybe (Last LogFormat) -> IO Logger
- mkLogger' :: IO Logger
- newtype LoggerT m a = LoggerT {
- runLoggerT :: ReaderT Logger m a
- runWithLogger :: Logger -> LoggerT m a -> m a
- netStringsToLogFormat :: Bool -> LogFormat
- structuredJSONRenderer :: Renderer
Documentation
module System.Logger
The log formats supported
Instances
FromJSON LogFormat Source # | |
ToJSON LogFormat Source # | |
Generic LogFormat Source # | |
Show LogFormat Source # | |
Eq LogFormat Source # | |
type Rep LogFormat Source # | |
Defined in System.Logger.Extended type Rep LogFormat = D1 ('MetaData "LogFormat" "System.Logger.Extended" "extended-0.1.0-D4cMSnuM03B3VG13bPRRym" 'False) ((C1 ('MetaCons "JSON" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Plain" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Netstring" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "StructuredJSON" 'PrefixI 'False) (U1 :: Type -> Type))) |
mkLogger :: Level -> Maybe (Last Bool) -> Maybe (Last LogFormat) -> IO Logger Source #
Creates a logger given a log format Also takes an useNetstrings argument which is there because we cannot immediatelly deprecate the old interface. Old configs only provide the useNetstrings argument and not the logFormat argument, and in that case implement the old behaviour of either enabling plain text logging or netstring logging. If both arguments are set, logFormat takes presedence over useNetstrings
FUTUREWORK: Once we get rid of the useNetstrings in our config files, we can
remove this function and rename mkLoggerNew
to mkLogger
It's a bit odd that we mention MonadClient
from the cql-io package here, but it's the
easiest way to get things done. Alternatively, we could introduce LoggerT
in the gundeck
integration tests, which is the only place in the world where it is currently used, but we
may need it elsewhere in the future and here it's easier to find.
LoggerT | |
|
Instances
runWithLogger :: Logger -> LoggerT m a -> m a Source #
netStringsToLogFormat :: Bool -> LogFormat Source #
Here for backwards-compatibility reasons
structuredJSONRenderer :: Renderer Source #
Displays all the Bytes
segments in a list under key msgs
and Field
segments as key-value pair in a JSON
>>>
logElems = [Bytes "W", Bytes "The message", Field "field1" "val1", Field "field2" "val2", Field "field1" "val1.1"]
>>>
B.toLazyByteString $ structuredJSONRenderer "," iso8601UTC Info logElems
"{\"msgs\":[\"The message\"],\"field1\":[\"val1\",\"val1.1\"],\"field2\":\"val2\",\"level\":\"Warn\"}"