Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- brackets :: Builder -> Builder
- getKeys :: LogItem s => Verbosity -> s -> [Builder]
- toBuilders :: KeyMap Value -> [[Builder]]
- toTxtKeyList :: KeyMap v -> [(Text, v)]
- renderPair :: (Text, Value) -> [Builder]
- data ColorStrategy
- mkHandleScribe :: ColorStrategy -> Handle -> PermitFunc -> Verbosity -> IO Scribe
- mkHandleScribeWithFormatter :: (forall a. LogItem a => ItemFormatter a) -> ColorStrategy -> Handle -> PermitFunc -> Verbosity -> IO Scribe
- mkFileScribe :: FilePath -> PermitFunc -> Verbosity -> IO Scribe
- type ItemFormatter a = Bool -> Verbosity -> Item a -> Builder
- formatItem :: LogItem a => ItemFormatter a
- bracketFormat :: LogItem a => ItemFormatter a
- jsonFormat :: LogItem a => ItemFormatter a
- colorBySeverity :: Bool -> Severity -> Text -> Text
- ioLogEnv :: PermitFunc -> Verbosity -> IO LogEnv
Documentation
toTxtKeyList :: KeyMap v -> [(Text, v)] Source #
data ColorStrategy Source #
ColorLog Bool | Whether to use color control chars in log output |
ColorIfTerminal | Color if output is a terminal |
Instances
Show ColorStrategy Source # | |
Defined in Katip.Scribes.Handle showsPrec :: Int -> ColorStrategy -> ShowS # show :: ColorStrategy -> String # showList :: [ColorStrategy] -> ShowS # | |
Eq ColorStrategy Source # | |
Defined in Katip.Scribes.Handle (==) :: ColorStrategy -> ColorStrategy -> Bool # (/=) :: ColorStrategy -> ColorStrategy -> Bool # |
mkHandleScribe :: ColorStrategy -> Handle -> PermitFunc -> Verbosity -> IO Scribe Source #
Logs to a file handle such as stdout, stderr, or a file. Contexts and other information will be flattened out into bracketed fields. For example:
[2016-05-11 21:01:15][MyApp][Info][myhost.example.com][PID 1724][ThreadId 1154][main:Helpers.Logging Helpers/Logging.hs:32:7] Started [2016-05-11 21:01:15][MyApp.confrabulation][Debug][myhost.example.com][PID 1724][ThreadId 1154][confrab_factor:42.0][main:Helpers.Logging Helpers/Logging.hs:41:9] Confrabulating widgets, with extra namespace and context [2016-05-11 21:01:15][MyApp][Info][myhost.example.com][PID 1724][ThreadId 1154][main:Helpers.Logging Helpers/Logging.hs:43:7] Namespace and context are back to normal
Returns the newly-created Scribe
. The finalizer flushes the
handle. Handle mode is set to LineBuffering
automatically.
mkHandleScribeWithFormatter :: (forall a. LogItem a => ItemFormatter a) -> ColorStrategy -> Handle -> PermitFunc -> Verbosity -> IO Scribe Source #
Logs to a file handle such as stdout, stderr, or a file. Takes a custom
ItemFormatter
that can be used to format Item
as needed.
Returns the newly-created Scribe
. The finalizer flushes the
handle. Handle mode is set to LineBuffering
automatically.
mkFileScribe :: FilePath -> PermitFunc -> Verbosity -> IO Scribe Source #
A specialization of mkHandleScribe
that takes a FilePath
instead of a Handle
. It is responsible for opening the file in
AppendMode
and will close the file handle on
closeScribe
/closeScribes
. Does not do log coloring. Sets handle
to LineBuffering
mode.
type ItemFormatter a = Bool -> Verbosity -> Item a -> Builder Source #
A custom ItemFormatter for logging Item
s. Takes a Value
indicating
whether to colorize the output, Verbosity
of output, and an Item
to
format.
See bracketFormat
and jsonFormat
for examples.
formatItem :: LogItem a => ItemFormatter a Source #
Deprecated: Use bracketFormat instead
bracketFormat :: LogItem a => ItemFormatter a Source #
A traditional bracketed
log format. Contexts and other information will
be flattened out into bracketed fields. For example:
[2016-05-11 21:01:15][MyApp][Info][myhost.example.com][PID 1724][ThreadId 1154][main:Helpers.Logging Helpers/Logging.hs:32:7] Started [2016-05-11 21:01:15][MyApp.confrabulation][Debug][myhost.example.com][PID 1724][ThreadId 1154][confrab_factor:42.0][main:Helpers.Logging Helpers/Logging.hs:41:9] Confrabulating widgets, with extra namespace and context [2016-05-11 21:01:15][MyApp][Info][myhost.example.com][PID 1724][ThreadId 1154][main:Helpers.Logging Helpers/Logging.hs:43:7] Namespace and context are back to normal
jsonFormat :: LogItem a => ItemFormatter a Source #
Logs items as JSON. This can be useful in circumstances where you already have infrastructure that is expecting JSON to be logged to a standard stream or file. For example:
{"at":"2018-10-02T21:50:30.4523848Z","env":"production","ns":["MyApp"],"data":{},"app":["MyApp"],"msg":"Started","pid":"10456","loc":{"loc_col":9,"loc_pkg":"main","loc_mod":"Helpers.Logging","loc_fn":"Helpers\\Logging.hs","loc_ln":44},"host":"myhost.example.com","sev":"Info","thread":"ThreadId 139"} {"at":"2018-10-02T21:50:30.4523848Z","env":"production","ns":["MyApp","confrabulation"],"data":{"confrab_factor":42},"app":["MyApp"],"msg":"Confrabulating widgets, with extra namespace and context","pid":"10456","loc":{"loc_col":11,"loc_pkg":"main","loc_mod":"Helpers.Logging","loc_fn":"Helpers\\Logging.hs","loc_ln":53},"host":"myhost.example.com","sev":"Debug","thread":"ThreadId 139"} {"at":"2018-10-02T21:50:30.4523848Z","env":"production","ns":["MyApp"],"data":{},"app":["MyApp"],"msg":"Namespace and context are back to normal","pid":"10456","loc":{"loc_col":9,"loc_pkg":"main","loc_mod":"Helpers.Logging","loc_fn":"Helpers\\Logging.hs","loc_ln":55},"host":"myhost.example.com","sev":"Info","thread":"ThreadId 139"}