Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Log functions using CallStack support in place of Template Haskell
Since: 0.3.19
Synopsis
- fromLogStr :: LogStr -> ByteString
- data LogStr
- class ToLogStr msg where
-
data
Loc
=
Loc
{
- loc_filename :: String
- loc_package :: String
- loc_module :: String
- loc_start :: CharPos
- loc_end :: CharPos
- newtype LoggingT m a = LoggingT { }
-
newtype
WriterLoggingT
m a =
WriterLoggingT
{
- unWriterLoggingT :: m (a, DList LogLine )
- type LogLine = ( Loc , LogSource , LogLevel , LogStr )
-
newtype
NoLoggingT
m a =
NoLoggingT
{
- runNoLoggingT :: m a
- class ( MonadLogger m, MonadIO m) => MonadLoggerIO m where
-
class
Monad
m =>
MonadLogger
m
where
- monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> m ()
- type LogSource = Text
-
data
LogLevel
- = LevelDebug
- | LevelInfo
- | LevelWarn
- | LevelError
- | LevelOther Text
- liftLoc :: Loc -> Q Exp
- logDebugS :: Q Exp
- logInfoS :: Q Exp
- logWarnS :: Q Exp
- logErrorS :: Q Exp
- logOtherS :: Q Exp
- runWriterLoggingT :: Functor m => WriterLoggingT m a -> m (a, [ LogLine ])
- execWriterLoggingT :: Functor m => WriterLoggingT m a -> m [ LogLine ]
- defaultOutput :: Handle -> Loc -> LogSource -> LogLevel -> LogStr -> IO ()
- defaultLogStr :: Loc -> LogSource -> LogLevel -> LogStr -> LogStr
- runFileLoggingT :: MonadBaseControl IO m => FilePath -> LoggingT m a -> m a
- runStderrLoggingT :: MonadIO m => LoggingT m a -> m a
- runStdoutLoggingT :: MonadIO m => LoggingT m a -> m a
- runChanLoggingT :: MonadIO m => Chan LogLine -> LoggingT m a -> m a
- unChanLoggingT :: ( MonadLogger m, MonadIO m) => Chan LogLine -> m void
- withChannelLogger :: ( MonadBaseControl IO m, MonadIO m) => Int -> LoggingT m a -> LoggingT m a
- filterLogger :: ( LogSource -> LogLevel -> Bool ) -> LoggingT m a -> LoggingT m a
- mapLoggingT :: (m a -> n b) -> LoggingT m a -> LoggingT n b
- mapNoLoggingT :: (m a -> n b) -> NoLoggingT m a -> NoLoggingT n b
- defaultLoc :: Loc
- logWithoutLoc :: ( MonadLogger m, ToLogStr msg) => LogSource -> LogLevel -> msg -> m ()
- logDebugN :: MonadLogger m => Text -> m ()
- logInfoN :: MonadLogger m => Text -> m ()
- logWarnN :: MonadLogger m => Text -> m ()
- logErrorN :: MonadLogger m => Text -> m ()
- logOtherN :: MonadLogger m => LogLevel -> Text -> m ()
- logDebugNS :: MonadLogger m => LogSource -> Text -> m ()
- logInfoNS :: MonadLogger m => LogSource -> Text -> m ()
- logWarnNS :: MonadLogger m => LogSource -> Text -> m ()
- logErrorNS :: MonadLogger m => LogSource -> Text -> m ()
- logOtherNS :: MonadLogger m => LogSource -> LogLevel -> Text -> m ()
- logDebugCS :: MonadLogger m => CallStack -> Text -> m ()
- logInfoCS :: MonadLogger m => CallStack -> Text -> m ()
- logWarnCS :: MonadLogger m => CallStack -> Text -> m ()
- logErrorCS :: MonadLogger m => CallStack -> Text -> m ()
- logOtherCS :: MonadLogger m => CallStack -> LogLevel -> Text -> m ()
- logDebug :: ( HasCallStack , MonadLogger m) => Text -> m ()
- logInfo :: ( HasCallStack , MonadLogger m) => Text -> m ()
- logWarn :: ( HasCallStack , MonadLogger m) => Text -> m ()
- logError :: ( HasCallStack , MonadLogger m) => Text -> m ()
- logOther :: ( HasCallStack , MonadLogger m) => LogLevel -> Text -> m ()
- logDebugSH :: ( HasCallStack , MonadLogger m, Show a) => a -> m ()
- logInfoSH :: ( HasCallStack , MonadLogger m, Show a) => a -> m ()
- logWarnSH :: ( HasCallStack , MonadLogger m, Show a) => a -> m ()
- logErrorSH :: ( HasCallStack , MonadLogger m, Show a) => a -> m ()
- logOtherSH :: ( HasCallStack , MonadLogger m, Show a) => LogLevel -> a -> m ()
Documentation
fromLogStr :: LogStr -> ByteString Source #
Converting
LogStr
to
ByteString
.
Log message builder. Use (
<>
) to append two LogStr in O(1).
class ToLogStr msg where Source #
Types that can be converted to a
LogStr
. Instances for
types from the
text
library use a UTF-8 encoding. Instances
for numerical types use a decimal encoding.
Instances
ToLogStr Double |
Since: fast-logger-2.4.14 |
ToLogStr Float |
Since: fast-logger-2.4.14 |
ToLogStr Int |
Since: fast-logger-2.4.14 |
ToLogStr Int8 |
Since: fast-logger-2.4.14 |
ToLogStr Int16 |
Since: fast-logger-2.4.14 |
ToLogStr Int32 |
Since: fast-logger-2.4.14 |
ToLogStr Int64 |
Since: fast-logger-2.4.14 |
ToLogStr Integer |
Since: fast-logger-2.4.14 |
ToLogStr Word |
Since: fast-logger-2.4.14 |
ToLogStr Word8 |
Since: fast-logger-2.4.14 |
ToLogStr Word16 |
Since: fast-logger-2.4.14 |
ToLogStr Word32 |
Since: fast-logger-2.4.14 |
ToLogStr Word64 |
Since: fast-logger-2.4.14 |
ToLogStr ByteString | |
Defined in System.Log.FastLogger.LogStr toLogStr :: ByteString -> LogStr Source # |
|
ToLogStr ByteString | |
Defined in System.Log.FastLogger.LogStr toLogStr :: ByteString -> LogStr Source # |
|
ToLogStr Text | |
ToLogStr Text | |
ToLogStr String | |
ToLogStr ShortByteString | |
Defined in System.Log.FastLogger.LogStr toLogStr :: ShortByteString -> LogStr Source # |
|
ToLogStr Builder | |
ToLogStr LogStr | |
Loc | |
|
Instances
Eq Loc | |
Data Loc | |
Defined in Language.Haskell.TH.Syntax gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> Loc -> c Loc Source # gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c Loc Source # toConstr :: Loc -> Constr Source # dataTypeOf :: Loc -> DataType Source # dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c Loc ) Source # dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c Loc ) Source # gmapT :: ( forall b. Data b => b -> b) -> Loc -> Loc Source # gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> Loc -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> Loc -> r Source # gmapQ :: ( forall d. Data d => d -> u) -> Loc -> [u] Source # gmapQi :: Int -> ( forall d. Data d => d -> u) -> Loc -> u Source # gmapM :: Monad m => ( forall d. Data d => d -> m d) -> Loc -> m Loc Source # gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> Loc -> m Loc Source # gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> Loc -> m Loc Source # |
|
Ord Loc | |
Show Loc | |
Generic Loc | |
type Rep Loc | |
Defined in Language.Haskell.TH.Syntax
type
Rep
Loc
=
D1
('
MetaData
"Loc" "Language.Haskell.TH.Syntax" "template-haskell" '
False
) (
C1
('
MetaCons
"Loc" '
PrefixI
'
True
) ((
S1
('
MetaSel
('
Just
"loc_filename") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
String
)
:*:
S1
('
MetaSel
('
Just
"loc_package") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
String
))
:*:
(
S1
('
MetaSel
('
Just
"loc_module") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
String
)
:*:
(
S1
('
MetaSel
('
Just
"loc_start") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
CharPos
)
:*:
S1
('
MetaSel
('
Just
"loc_end") '
NoSourceUnpackedness
'
NoSourceStrictness
'
DecidedLazy
) (
Rec0
CharPos
)))))
|
Monad transformer that adds a new logging function.
Since: 0.2.2
Instances
newtype WriterLoggingT m a Source #
Since: 0.3.28
WriterLoggingT | |
|
Instances
newtype NoLoggingT m a Source #
Monad transformer that disables logging.
Since: 0.2.4
NoLoggingT | |
|
Instances
class ( MonadLogger m, MonadIO m) => MonadLoggerIO m where Source #
An extension of
MonadLogger
for the common case where the logging action
is a simple
IO
action. The advantage of using this typeclass is that the
logging function itself can be extracted as a first-class value, which can
make it easier to manipulate monad transformer stacks, as an example.
Since: 0.3.10
Nothing
askLoggerIO :: m ( Loc -> LogSource -> LogLevel -> LogStr -> IO ()) Source #
Request the logging function itself.
Since: 0.3.10
default askLoggerIO :: ( MonadTrans t, MonadLoggerIO n, m ~ t n) => m ( Loc -> LogSource -> LogLevel -> LogStr -> IO ()) Source #
Instances
class Monad m => MonadLogger m where Source #
A
Monad
which has the ability to log messages in some manner.
Nothing
monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> m () Source #
default monadLoggerLog :: ( MonadLogger m', MonadTrans t, MonadLogger (t m'), ToLogStr msg, m ~ t m') => Loc -> LogSource -> LogLevel -> msg -> m () Source #
Instances
Instances
Eq LogLevel Source # | |
Ord LogLevel Source # | |
Defined in Control.Monad.Logger |
|
Read LogLevel Source # | |
Show LogLevel Source # | |
Lift LogLevel Source # | |
Generates a function that takes a
LogSource
and
Text
and logs a
LevelDebug
message. Usage:
$logDebugS "SomeSource" "This is a debug log message"
Generates a function that takes a
LogSource
, a level name and a
Text
and logs a
LevelOther
message. Usage:
$logOtherS "SomeSource" "My new level" "This is a log message"
runWriterLoggingT :: Functor m => WriterLoggingT m a -> m (a, [ LogLine ]) Source #
Run a block using a
MonadLogger
instance. Return a value and logs in a list
| @since 0.3.28
execWriterLoggingT :: Functor m => WriterLoggingT m a -> m [ LogLine ] Source #
Run a block using a
MonadLogger
instance. Return logs in a list
| @since 0.3.28
defaultOutput :: Handle -> Loc -> LogSource -> LogLevel -> LogStr -> IO () Source #
A default implementation of
monadLoggerLog
that accepts a file
handle as the first argument.
This is used in the definition of
runStdoutLoggingT
:
runStdoutLoggingT
::MonadIO
m =>LoggingT
m a -> m arunStdoutLoggingT
action =runLoggingT
action (defaultOutput
stdout
)
Since: 0.3.36
runFileLoggingT :: MonadBaseControl IO m => FilePath -> LoggingT m a -> m a Source #
Run a block using a
MonadLogger
instance which appends to the specified file.
Since: 0.3.22
runStderrLoggingT :: MonadIO m => LoggingT m a -> m a Source #
Run a block using a
MonadLogger
instance which prints to stderr.
Since: 0.2.2
runStdoutLoggingT :: MonadIO m => LoggingT m a -> m a Source #
Run a block using a
MonadLogger
instance which prints to stdout.
Since: 0.2.2
runChanLoggingT :: MonadIO m => Chan LogLine -> LoggingT m a -> m a Source #
Run a block using a
MonadLogger
instance which writes tuples to an
unbounded channel.
The tuples can be extracted (ie. in another thread) with
unChanLoggingT
or a custom extraction funtion, and written to a destination.
Since: 0.3.17
unChanLoggingT :: ( MonadLogger m, MonadIO m) => Chan LogLine -> m void Source #
Read logging tuples from an unbounded channel and log them into a
MonadLoggerIO
monad, forever.
For use in a dedicated thread with a channel fed by
runChanLoggingT
.
Since: 0.3.17
:: ( MonadBaseControl IO m, MonadIO m) | |
=> Int |
Number of messages to keep |
-> LoggingT m a | |
-> LoggingT m a |
Within the
LoggingT
monad, capture all log messages to a bounded
channel of the indicated size, and only actually log them if there is an
exception.
Since: 0.3.2
filterLogger :: ( LogSource -> LogLevel -> Bool ) -> LoggingT m a -> LoggingT m a Source #
Only log messages passing the given predicate function.
This can be a convenient way, for example, to ignore debug level messages.
Since: 0.3.13
mapLoggingT :: (m a -> n b) -> LoggingT m a -> LoggingT n b Source #
Map the unwrapped computation using the given function.
Since: 0.3.29
mapNoLoggingT :: (m a -> n b) -> NoLoggingT m a -> NoLoggingT n b Source #
Map the unwrapped computation using the given function.
Since: 0.3.29
defaultLoc :: Loc Source #
dummy location, used with
logWithoutLoc
Since: 0.3.23
logWithoutLoc :: ( MonadLogger m, ToLogStr msg) => LogSource -> LogLevel -> msg -> m () Source #
Since: 0.3.23
logDebugN :: MonadLogger m => Text -> m () Source #
logInfoN :: MonadLogger m => Text -> m () Source #
logWarnN :: MonadLogger m => Text -> m () Source #
logErrorN :: MonadLogger m => Text -> m () Source #
logDebugNS :: MonadLogger m => LogSource -> Text -> m () Source #
logErrorNS :: MonadLogger m => LogSource -> Text -> m () Source #
logOtherNS :: MonadLogger m => LogSource -> LogLevel -> Text -> m () Source #
logDebugCS :: MonadLogger m => CallStack -> Text -> m () Source #
logInfoCS :: MonadLogger m => CallStack -> Text -> m () Source #
See
logDebugCS
Since: 0.3.19
logWarnCS :: MonadLogger m => CallStack -> Text -> m () Source #
See
logDebugCS
Since: 0.3.19
logErrorCS :: MonadLogger m => CallStack -> Text -> m () Source #
See
logDebugCS
Since: 0.3.19
logOtherCS :: MonadLogger m => CallStack -> LogLevel -> Text -> m () Source #
See
logDebugCS
Since: 0.3.19
logDebug :: ( HasCallStack , MonadLogger m) => Text -> m () Source #
Logs a message with the location provided by
an implicit
CallStack
.
Since: 0.3.19
logInfo :: ( HasCallStack , MonadLogger m) => Text -> m () Source #
See
logDebug
Since: 0.3.19
logWarn :: ( HasCallStack , MonadLogger m) => Text -> m () Source #
See
logDebug
Since: 0.3.19
logError :: ( HasCallStack , MonadLogger m) => Text -> m () Source #
See
logDebug
Since: 0.3.19
logOther :: ( HasCallStack , MonadLogger m) => LogLevel -> Text -> m () Source #
See
logDebug
Since: 0.3.25
logDebugSH :: ( HasCallStack , MonadLogger m, Show a) => a -> m () Source #
Logs a showable value with the location provided by
an implicit
CallStack
.
Since: 0.3.25
logInfoSH :: ( HasCallStack , MonadLogger m, Show a) => a -> m () Source #
See
logDebugSH
Since: 0.3.25
logWarnSH :: ( HasCallStack , MonadLogger m, Show a) => a -> m () Source #
See
logDebugSH
Since: 0.3.25
logErrorSH :: ( HasCallStack , MonadLogger m, Show a) => a -> m () Source #
See
logDebugSH
Since: 0.3.25
logOtherSH :: ( HasCallStack , MonadLogger m, Show a) => LogLevel -> a -> m () Source #
See
logDebugSH
Since: 0.3.25