Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
-
data
LogMsg
a r
where
- LMessage :: LogMessage a -> LogMsg a ()
- data LogLevel
-
data
LogMessage
a =
LogMessage
{
- _logLevel :: LogLevel
- _logMessageContent :: a
- logLevel :: forall a. Lens' ( LogMessage a) LogLevel
- logMessageContent :: forall a a. Lens ( LogMessage a) ( LogMessage a) a a
- logMessage :: LogLevel -> Prism' ( LogMessage a) a
- logDebug :: forall a effs. Member ( LogMsg a) effs => a -> Eff effs ()
- logInfo :: forall a effs. Member ( LogMsg a) effs => a -> Eff effs ()
- logWarn :: forall a effs. Member ( LogMsg a) effs => a -> Eff effs ()
- logError :: forall a effs. Member ( LogMsg a) effs => a -> Eff effs ()
- mapLog :: forall a b effs. Member ( LogMsg b) effs => (a -> b) -> LogMsg a ~> Eff effs
- mapMLog :: forall a b effs. Member ( LogMsg b) effs => (a -> Eff effs b) -> LogMsg a ~> Eff effs
- handleWriterLog :: forall a f effs. ( Member ( LogMsg a) effs, Traversable f) => (a -> LogLevel ) -> Eff ( Writer (f a) ': effs) ~> Eff effs
- handleLogIgnore :: Eff ( LogMsg a ': effs) ~> Eff effs
- handleLogTrace :: Pretty a => Eff ( LogMsg a ': effs) ~> Eff effs
- handleLogWriter :: forall a w effs. Member ( Writer w) effs => AReview w ( LogMessage a) -> LogMsg a ~> Eff effs
- renderLogMessages :: forall a effs. ( Member ( LogMsg Text ) effs, Pretty a) => LogMsg a ~> Eff effs
-
data
LogObserve
a r
where
- ObserveBefore :: a -> LogObserve a ObservationHandle
- ObserveAfter :: Maybe a -> ObservationHandle -> LogObserve a ()
- data ObservationHandle
-
data
Observation
v s =
Observation
{
- obsLabelStart :: v
- obsStart :: s
- obsLabelEnd :: Maybe v
- obsExit :: ExitMode
- observeBefore :: forall a. forall effs. Member ( LogObserve a) effs => a -> Eff effs ObservationHandle
- observeAfter :: forall a. forall effs. Member ( LogObserve a) effs => Maybe a -> ObservationHandle -> Eff effs ()
- surround :: forall v a effs. Member ( LogObserve v) effs => v -> Eff effs a -> Eff effs a
- surroundDebug :: Member ( LogObserve ( LogMessage v)) effs => v -> Eff effs a -> Eff effs a
- surroundInfo :: Member ( LogObserve ( LogMessage v)) effs => v -> Eff effs a -> Eff effs a
- surroundWarn :: Member ( LogObserve ( LogMessage v)) effs => v -> Eff effs a -> Eff effs a
- handleObserveLog :: forall effs. Member ( LogMsg Text ) effs => Eff ( LogObserve ( LogMessage Text ) ': effs) ~> Eff effs
- handleObserve :: forall v s effs. (v -> Eff effs s) -> ( Observation v s -> Eff effs ()) -> Eff ( LogObserve v ': effs) ~> Eff effs
Documentation
This module provides effects and handlers for structured logging and tracing.
The severity level of a log message See https://en.wikipedia.org/wiki/Syslog#Severity_level
Instances
Eq LogLevel Source # | |
Ord LogLevel Source # | |
Defined in Control.Monad.Freer.Extras.Log |
|
Show LogLevel Source # | |
Generic LogLevel Source # | |
ToJSON LogLevel Source # | |
FromJSON LogLevel Source # | |
Pretty LogLevel Source # | |
type Rep LogLevel Source # | |
Defined in Control.Monad.Freer.Extras.Log
type
Rep
LogLevel
=
D1
('
MetaData
"LogLevel" "Control.Monad.Freer.Extras.Log" "freer-extras-1.2.0.0-LXgx2kLJeQTLxOMFH7LYd8" '
False
) (((
C1
('
MetaCons
"Debug" '
PrefixI
'
False
) (
U1
::
Type
->
Type
)
:+:
C1
('
MetaCons
"Info" '
PrefixI
'
False
) (
U1
::
Type
->
Type
))
:+:
(
C1
('
MetaCons
"Notice" '
PrefixI
'
False
) (
U1
::
Type
->
Type
)
:+:
C1
('
MetaCons
"Warning" '
PrefixI
'
False
) (
U1
::
Type
->
Type
)))
:+:
((
C1
('
MetaCons
"Error" '
PrefixI
'
False
) (
U1
::
Type
->
Type
)
:+:
C1
('
MetaCons
"Critical" '
PrefixI
'
False
) (
U1
::
Type
->
Type
))
:+:
(
C1
('
MetaCons
"Alert" '
PrefixI
'
False
) (
U1
::
Type
->
Type
)
:+:
C1
('
MetaCons
"Emergency" '
PrefixI
'
False
) (
U1
::
Type
->
Type
))))
|
data LogMessage a Source #
Instances
logMessageContent :: forall a a. Lens ( LogMessage a) ( LogMessage a) a a Source #
logMessage :: LogLevel -> Prism' ( LogMessage a) a Source #
Modifying logs
mapMLog :: forall a b effs. Member ( LogMsg b) effs => (a -> Eff effs b) -> LogMsg a ~> Eff effs Source #
Re-interpret a logging effect by mapping the log messages. Can use other effects.
Running logs
handleWriterLog :: forall a f effs. ( Member ( LogMsg a) effs, Traversable f) => (a -> LogLevel ) -> Eff ( Writer (f a) ': effs) ~> Eff effs Source #
Re-interpret a
Writer
effect by writing the events to the log
handleLogTrace :: Pretty a => Eff ( LogMsg a ': effs) ~> Eff effs Source #
Write the log to stdout using
trace
handleLogWriter :: forall a w effs. Member ( Writer w) effs => AReview w ( LogMessage a) -> LogMsg a ~> Eff effs Source #
Re-interpret a
Log
effect with a
Writer
renderLogMessages :: forall a effs. ( Member ( LogMsg Text ) effs, Pretty a) => LogMsg a ~> Eff effs Source #
Pretty-print the log messages
Observing
data LogObserve a r where Source #
ObserveBefore :: a -> LogObserve a ObservationHandle | |
ObserveAfter :: Maybe a -> ObservationHandle -> LogObserve a () |
data ObservationHandle Source #
An abstract type used to tie the beginning and end of observations together.
data Observation v s Source #
An observation with measurements before and after running an action.
Observation | |
|
observeBefore :: forall a. forall effs. Member ( LogObserve a) effs => a -> Eff effs ObservationHandle Source #
observeAfter :: forall a. forall effs. Member ( LogObserve a) effs => Maybe a -> ObservationHandle -> Eff effs () Source #
Combinators
surround :: forall v a effs. Member ( LogObserve v) effs => v -> Eff effs a -> Eff effs a Source #
Write a log message before and after an action. Consider using
observeBefore
and
observeAfter
directly if you need more control
over the values that are observed at the call site.
surroundDebug :: Member ( LogObserve ( LogMessage v)) effs => v -> Eff effs a -> Eff effs a Source #
surroundDebug = surround Debug
surroundInfo :: Member ( LogObserve ( LogMessage v)) effs => v -> Eff effs a -> Eff effs a Source #
surroundInfo = surround Info
surroundWarn :: Member ( LogObserve ( LogMessage v)) effs => v -> Eff effs a -> Eff effs a Source #
surroundWarn = surround Warn
Handlers
handleObserveLog :: forall effs. Member ( LogMsg Text ) effs => Eff ( LogObserve ( LogMessage Text ) ': effs) ~> Eff effs Source #
Interpret the
LogObserve
effect by logging a "start" message
before the action and an "end" message after the action.
:: forall v s effs. (v -> Eff effs s) |
How to get the current
|
-> ( Observation v s -> Eff effs ()) | |
-> Eff ( LogObserve v ': effs) ~> Eff effs |
Handle the
LogObserve
effect by recording observations
s
before and after the observed action, and turning
them into 'LogMessage (Observation s)' values.