Safe Haskell | None |
---|---|
Language | Haskell2010 |
Message
with Severity
, and logging functions for them.
Synopsis
- data Message = Message {
- messageSeverity :: !Severity
- messageStack :: !CallStack
- messageText :: !Text
- log :: WithLog env Message m => Severity -> Text -> m ()
- logDebug :: WithLog env Message m => Text -> m ()
- logInfo :: WithLog env Message m => Text -> m ()
- logWarning :: WithLog env Message m => Text -> m ()
- logError :: WithLog env Message m => Text -> m ()
- logException :: forall e m env. (WithLog env Message m, Exception e) => e -> m ()
- fmtMessage :: Message -> Text
- type family FieldType (fieldName :: Symbol) :: Type
- newtype MessageField (m :: Type -> Type) (fieldName :: Symbol) where
- MessageField :: forall fieldName m. {..} -> MessageField m fieldName
- type FieldMap (m :: Type -> Type) = TypeRepMap (MessageField m)
- defaultFieldMap :: MonadIO m => FieldMap m
- data RichMessage (m :: Type -> Type)
- fmtRichMessageDefault :: MonadIO m => RichMessage m -> m Text
- upgradeMessageAction :: forall m. FieldMap m -> LogAction m (RichMessage m) -> LogAction m Message
Basic message type
Consist of the message Severity
level and the message itself.
Message | |
|
log :: WithLog env Message m => Severity -> Text -> m () Source #
Logs the message with given Severity
.
logException :: forall e m env. (WithLog env Message m, Exception e) => e -> m () Source #
Logs Exception
message.
Externally extensible message type
type family FieldType (fieldName :: Symbol) :: Type Source #
Open type family that maps some user defined tags (type names) to actual types. The type family is open so you can add new instances.
newtype MessageField (m :: Type -> Type) (fieldName :: Symbol) where Source #
newtype
wrapper. Stores monadic ability to extract value of FieldType
.
Implementation detail: this exotic writing of MessageField
is required in
order to use it nicer with type applications. So users can write
MessageField @"threadId" myThreadId
instead of
MessageField _
"threadId" myThreadId
Simpler version of this newtype
:
newtype MessageField m fieldName = MessageField { unMesssageField :: m (FieldType fieldName) }
MessageField :: forall fieldName m. {..} -> MessageField m fieldName | |
|
Instances
(KnownSymbol fieldName, a ~ m (FieldType fieldName)) => IsLabel fieldName (a -> WrapTypeable (MessageField m)) Source # | |
Defined in Colog.Message fromLabel :: a -> WrapTypeable (MessageField m) # |
type FieldMap (m :: Type -> Type) = TypeRepMap (MessageField m) Source #
Depedent map from type level strings to the corresponding types. See
FieldType
for mapping between names and types.
defaultFieldMap :: MonadIO m => FieldMap m Source #
Default message map that contains actions to extract ThreadId
and
UTCTime
. Basically, the following mapping:
"threadId" -> myThreadId "utcTime" -> getCurrentTime
data RichMessage (m :: Type -> Type) Source #
Contains additional data to Message
to display more verbose information.
fmtRichMessageDefault :: MonadIO m => RichMessage m -> m Text Source #
Formats RichMessage
in the following way:
[Severity] [Time] [SourceLocation] [ThreadId] message
upgradeMessageAction :: forall m. FieldMap m -> LogAction m (RichMessage m) -> LogAction m Message Source #
Allows to extend basic Message
type with given dependent map of fields.