Safe Haskell | None |
---|---|
Language | Haskell2010 |
Structure for tracing context.
We assume that each message (Message
) can be tagged with two types of values:
segment
- path that tells where are we in the codebase.attrbibutes
- additional key-value tags, where value is an arbitrary json object.
Segment is needed in a case if we want to apply differrent logging rules to the differrent parts of the codebase. For example we may way to log all the messages in the component one but not all the rest.
In addition each Message
provides some common fields:
- "thread" - id of the thread that emits message
- "severity" - message severity
All messages in the same context share segment and attributes. So when exported to the log analytics systems it's easy to load all the information associated with it.
- *Compatibility note** internal structure of the message may be changed in the future in case if it's proven that another implementation is faster or more memory efficient. However the higher level API is likely to be stable.
Synopsis
- data Structured
- data Message = Message {}
- newtype LogStr = LogStr Builder
- newtype PushContext = PushContext (Seq Structured -> Seq Structured)
- data Severity
- encodeSeverity :: Severity -> Encoding
- showLS :: Show a => a -> LogStr
- ls :: StringConv a Text => a -> LogStr
- sl :: ToJSON a => Text -> a -> PushContext
- mkThreadId :: ThreadId -> Int
Log datastructure.
data Structured Source #
Part of the structured message.
Log message.
Message | |
|
Efficient message builder.
newtype PushContext Source #
Wrapper over the structured message builder.
Internals.
Logger severity.
DebugS | Debug level, intended for internal information |
InfoS | Info level, that may be interesting to the user |
NoticeS | Notice, information that |
WarningS | Warning, information possible problem problem of some sort |
ErrorS | Error, information about a problem |
CriticalS | Critical error, intended for error that may break the system |
AlertS | Critical error where immediate actions should be taken |
EmergencyS | System wide emergency |
Instances
Bounded Severity Source # | |
Enum Severity Source # | |
Defined in Colog.Json.Internal.Structured | |
Eq Severity Source # | |
Ord Severity Source # | |
Defined in Colog.Json.Internal.Structured | |
Show Severity Source # | |
encodeSeverity :: Severity -> Encoding Source #
Convert severity into the one accepted by the loger.
showLS :: Show a => a -> LogStr Source #
Convert loggable value from any message that has show instance.
sl :: ToJSON a => Text -> a -> PushContext Source #
"Simple logger" adds a key value to the context:
sl "foo" 123
Will add "foo":123
key pair to the current list of the attributes.
Submitted value is stored with json encoding.
mkThreadId :: ThreadId -> Int Source #
Helper function to get id of the thread.