Safe Haskell | None |
---|---|
Language | Haskell2010 |
DAP.Log
Synopsis
- data DebugStatus
- data DAPLog
- = DAPLog {
- severity :: Level
- mDebugStatus :: Maybe DebugStatus
- addr :: SockAddr
- message :: Text
- | GenericMessage { }
- = DAPLog {
- newtype LogAction (m :: Type -> Type) msg = LogAction {
- unLogAction :: msg -> m ()
- data Level
- (<&) :: LogAction m msg -> msg -> m ()
- cmap :: forall a b (m :: Type -> Type). (a -> b) -> LogAction m b -> LogAction m a
- cfilter :: forall (m :: Type -> Type) msg. Applicative m => (msg -> Bool) -> LogAction m msg -> LogAction m msg
- mkDebugMessage :: Text -> DAPLog
- renderDAPLog :: DAPLog -> Text
Documentation
data DebugStatus Source #
Instances
Show DebugStatus Source # | |
Defined in DAP.Log Methods showsPrec :: Int -> DebugStatus -> ShowS # show :: DebugStatus -> String # showList :: [DebugStatus] -> ShowS # | |
Eq DebugStatus Source # | |
Defined in DAP.Log |
Constructors
DAPLog | |
Fields
| |
GenericMessage | |
newtype LogAction (m :: Type -> Type) msg #
Polymorphic and very general logging action type.
msg
type variables is an input for logger. It can beText
or custom logging messsage with different fields that you want to format in future.m
type variable is for monadic action inside which logging is happening. It can be eitherIO
or some custom pure monad.
Key design point here is that LogAction
is:
Constructors
LogAction | |
Fields
|
Instances
Contravariant (LogAction m) | |
UnrepresentableClass => Functor (LogAction m) | ⚠️CAUTION⚠️ This instance is for custom error display only.
In case it is used by mistake, the user will see the following:
# 207 "srcCologCore/Action.hs" Since: co-log-core-0.2.1.0 |
Applicative m => Monoid (LogAction m a) | |
Applicative m => Semigroup (LogAction m a) | This instance allows you to join multiple logging actions into single one. For example, if you have two actions like these: logToStdout :: You can create new logToBoth :: |
HasLog (LogAction m msg) msg m | |
Defined in Colog.Core.Class Methods getLogAction :: LogAction m msg -> LogAction m msg # setLogAction :: LogAction m msg -> LogAction m msg -> LogAction m msg # overLogAction :: (LogAction m msg -> LogAction m msg) -> LogAction m msg -> LogAction m msg # logActionL :: Lens' (LogAction m msg) (LogAction m msg) # |
(<&) :: LogAction m msg -> msg -> m () infix 5 #
Operator version of unLogAction
. Note that because of the types, something like:
action <& msg1 <& msg2
doesn't make sense. Instead you want:
action <& msg1 >> action <& msg2
In addition, because <&
has higher precedence than the other operators in this
module, the following:
f >$< action <& msg
is equivalent to:
(f >$< action) <& msg
cmap :: forall a b (m :: Type -> Type). (a -> b) -> LogAction m b -> LogAction m a #
This combinator is contramap
from contravariant functor. It is useful
when you have something like
data LogRecord = LR { lrName :: LoggerName , lrMessage :: Text }
and you need to provide LogAction
which consumes LogRecord
logRecordAction :: LogAction
m LogRecord
when you only have action that consumes Text
logTextAction :: LogAction
m Text
With cmap
you can do the following:
logRecordAction ::LogAction
m LogRecord logRecordAction =cmap
lrMesssage logTextAction
This action will print only lrMessage
from LogRecord
. But if you have
formatting function like this:
formatLogRecord :: LogRecord -> Text
you can apply it instead of lrMessage
to log formatted LogRecord
as Text
.
cfilter :: forall (m :: Type -> Type) msg. Applicative m => (msg -> Bool) -> LogAction m msg -> LogAction m msg #
Takes predicate and performs given logging action only if predicate returns
True
on input logging message.
mkDebugMessage :: Text -> DAPLog Source #
renderDAPLog :: DAPLog -> Text Source #