logger-effectful-0.1: Effectful version of @monad-logger@'s API.
Safe HaskellNone
LanguageGHC2021

Effectful.Logger.Dynamic

Description

Dynamic effect for Control.Monad.Logger.

Since: 0.1

Synopsis

Effect

data Logger (a :: Type -> Type) b where Source #

Dynamic logging effect for Control.Monad.Logger.

Since: 0.1

Constructors

LoggerLog :: forall msg (a :: Type -> Type). ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> Logger a () 

Instances

Instances details
ShowEffect Logger Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Dynamic

Methods

showEffectCons :: forall (m :: Type -> Type) a. Logger m a -> String Source #

type DispatchOf Logger Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Dynamic

loggerLog :: forall (es :: [Effect]) msg. (HasCallStack, Logger :> es, ToLogStr msg) => Loc -> LogSource -> LogLevel -> msg -> Eff es () Source #

Writes a log.

Since: 0.1

Types

data LogLevel Source #

Since: 0.1

Constructors

LevelTrace

Since: 0.1

LevelDebug

Since: 0.1

LevelInfo

Since: 0.1

LevelWarn

Since: 0.1

LevelError

Since: 0.1

LevelFatal

Since: 0.1

LevelOther Text

Since: 0.1

Instances

Instances details
NFData LogLevel Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

Methods

rnf :: LogLevel -> () #

Generic LogLevel Source # 
Instance details

Defined in Effectful.Logger.Utils

Associated Types

type Rep LogLevel

Since: logger-effectful-0.1

Instance details

Defined in Effectful.Logger.Utils

type Rep LogLevel = D1 ('MetaData "LogLevel" "Effectful.Logger.Utils" "logger-effectful-0.1-inplace" 'False) ((C1 ('MetaCons "LevelTrace" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LevelDebug" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LevelInfo" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "LevelWarn" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LevelError" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "LevelFatal" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LevelOther" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))))

Methods

from :: LogLevel -> Rep LogLevel x #

to :: Rep LogLevel x -> LogLevel #

Read LogLevel Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

Show LogLevel Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

Eq LogLevel Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

Ord LogLevel Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

Lift LogLevel Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

Methods

lift :: Quote m => LogLevel -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => LogLevel -> Code m LogLevel #

type Rep LogLevel Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

type Rep LogLevel = D1 ('MetaData "LogLevel" "Effectful.Logger.Utils" "logger-effectful-0.1-inplace" 'False) ((C1 ('MetaCons "LevelTrace" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "LevelDebug" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LevelInfo" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "LevelWarn" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LevelError" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "LevelFatal" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "LevelOther" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))))

type LogLine = (Loc, LogSource, LogLevel, LogStr) Source #

Since: 0.1

type LogSource = Text Source #

Since: 0.1

Re-export from fast-logger

data LogStr Source #

Log message builder. Use (<>) to append two LogStr in O(1).

Instances

Instances details
ToLogStr LogStr 
Instance details

Defined in System.Log.FastLogger.LogStr

Monoid LogStr 
Instance details

Defined in System.Log.FastLogger.LogStr

Semigroup LogStr 
Instance details

Defined in System.Log.FastLogger.LogStr

IsString LogStr 
Instance details

Defined in System.Log.FastLogger.LogStr

Methods

fromString :: String -> LogStr #

Show LogStr 
Instance details

Defined in System.Log.FastLogger.LogStr

Eq LogStr 
Instance details

Defined in System.Log.FastLogger.LogStr

Methods

(==) :: LogStr -> LogStr -> Bool #

(/=) :: LogStr -> LogStr -> Bool #

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.

Methods

toLogStr :: msg -> LogStr Source #

Instances

Instances details
ToLogStr Builder 
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr ByteString 
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr ByteString 
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr ShortByteString 
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr LogStr 
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int16

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int32

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int64

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int8

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

Methods

toLogStr :: Int8 -> LogStr Source #

ToLogStr Word16

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Word32

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Word64

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Word8

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Text 
Instance details

Defined in System.Log.FastLogger.LogStr

Methods

toLogStr :: Text -> LogStr Source #

ToLogStr Text 
Instance details

Defined in System.Log.FastLogger.LogStr

Methods

toLogStr :: Text -> LogStr Source #

ToLogStr Integer

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr String 
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Double

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Float

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

Methods

toLogStr :: Int -> LogStr Source #

ToLogStr Word

Since: fast-logger-2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

Methods

toLogStr :: Word -> LogStr Source #

TH logging

logTrace :: Q Exp Source #

See logDebug

Since: 0.1

logDebug :: Q Exp Source #

Generates a function that takes a Text and logs a LevelDebug message. Usage:

$(logDebug) "This is a debug log message"

Since: 0.1

logInfo :: Q Exp Source #

See logDebug

Since: 0.1

logWarn :: Q Exp Source #

See logDebug

Since: 0.1

logError :: Q Exp Source #

See logDebug

Since: 0.1

logFatal :: Q Exp Source #

See logDebug

Since: 0.1

logOther :: Text -> Q Exp Source #

Generates a function that takes a Text and logs a LevelOther message. Usage:

$(logOther "My new level") "This is a log message"

Since: 0.1

TH logging of showable values

logTraceSH :: Q Exp Source #

See logDebugSH

Since: 0.1

logDebugSH :: Q Exp Source #

Generates a function that takes a 'Show a => a' and logs a LevelDebug message. Usage:

$(logDebugSH) (Just "This is a debug log message")

Since: 0.1

logInfoSH :: Q Exp Source #

See logDebugSH

Since: 0.1

logWarnSH :: Q Exp Source #

See logDebugSH

Since: 0.1

logErrorSH :: Q Exp Source #

See logDebugSH

Since: 0.1

logFatalSH :: Q Exp Source #

See logDebugSH

Since: 0.1

logOtherSH :: Text -> Q Exp Source #

Generates a function that takes a 'Show a => a' and logs a LevelOther message. Usage:

$(logOtherSH "My new level") "This is a log message"

Since: 0.1

TH logging with source

logTraceS :: Q Exp Source #

See logDebugS

Since: 0.1

logDebugS :: Q Exp Source #

Generates a function that takes a LogSource and Text and logs a LevelDebug message. Usage:

$logDebugS "SomeSource" "This is a debug log message"

Since: 0.1

logInfoS :: Q Exp Source #

See logDebugS

Since: 0.1

logWarnS :: Q Exp Source #

See logDebugS

Since: 0.1

logErrorS :: Q Exp Source #

See logDebugS

Since: 0.1

logFatalS :: Q Exp Source #

See logDebugS

Since: 0.1

logOtherS :: Q Exp Source #

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"

Since: 0.1

TH util

liftLoc :: Loc -> Q Exp Source #

Lift a location into an Exp.

Since: 0.1

Non-TH logging

logTraceN :: forall (es :: [Effect]). Logger :> es => Text -> Eff es () Source #

Since: 0.1

logDebugN :: forall (es :: [Effect]). Logger :> es => Text -> Eff es () Source #

Since: 0.1

logInfoN :: forall (es :: [Effect]). Logger :> es => Text -> Eff es () Source #

Since: 0.1

logWarnN :: forall (es :: [Effect]). Logger :> es => Text -> Eff es () Source #

Since: 0.1

logErrorN :: forall (es :: [Effect]). Logger :> es => Text -> Eff es () Source #

Since: 0.1

logFatalN :: forall (es :: [Effect]). Logger :> es => Text -> Eff es () Source #

Since: 0.1

logOtherN :: forall (es :: [Effect]). Logger :> es => LogLevel -> Text -> Eff es () Source #

Since: 0.1

Non-TH logging with source

logWithoutLoc :: forall (es :: [Effect]) msg. (HasCallStack, Logger :> es, ToLogStr msg) => LogSource -> LogLevel -> msg -> Eff es () Source #

Since: 0.1

logTraceNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es () Source #

Since: 0.1

logDebugNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es () Source #

Since: 0.1

logInfoNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es () Source #

Since: 0.1

logWarnNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es () Source #

Since: 0.1

logErrorNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es () Source #

Since: 0.1

logFatalNS :: forall (es :: [Effect]). Logger :> es => LogSource -> Text -> Eff es () Source #

Since: 0.1

logOtherNS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => LogSource -> LogLevel -> Text -> Eff es () Source #

Since: 0.1

Callstack logging

logTraceCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es () Source #

See logDebugCS

Since: 0.1

logDebugCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es () Source #

Logs a message with location given by CallStack. See CallStack for more convenient functions for CallStack based logging.

Since: 0.1

logInfoCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es () Source #

See logDebugCS

Since: 0.1

logWarnCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es () Source #

See logDebugCS

Since: 0.1

logErrorCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es () Source #

See logDebugCS

Since: 0.1

logFatalCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> Text -> Eff es () Source #

See logDebugCS

Since: 0.1

logOtherCS :: forall (es :: [Effect]). (HasCallStack, Logger :> es) => CallStack -> LogLevel -> Text -> Eff es () Source #

See logDebugCS

Since: 0.1

utilities for defining your own loggers

data Loc #

Instances

Instances details
Data Loc 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Loc -> c Loc #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Loc #

toConstr :: Loc -> Constr #

dataTypeOf :: Loc -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Loc) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Loc) #

gmapT :: (forall b. Data b => b -> b) -> Loc -> Loc #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Loc -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Loc -> r #

gmapQ :: (forall d. Data d => d -> u) -> Loc -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Loc -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Loc -> m Loc #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Loc -> m Loc #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Loc -> m Loc #

Generic Loc 
Instance details

Defined in Language.Haskell.TH.Syntax

Associated Types

type Rep Loc 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

from :: Loc -> Rep Loc x #

to :: Rep Loc x -> Loc #

Show Loc 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

showsPrec :: Int -> Loc -> ShowS #

show :: Loc -> String #

showList :: [Loc] -> ShowS #

Eq Loc 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

(==) :: Loc -> Loc -> Bool #

(/=) :: Loc -> Loc -> Bool #

Ord Loc 
Instance details

Defined in Language.Haskell.TH.Syntax

Methods

compare :: Loc -> Loc -> Ordering #

(<) :: Loc -> Loc -> Bool #

(<=) :: Loc -> Loc -> Bool #

(>) :: Loc -> Loc -> Bool #

(>=) :: Loc -> Loc -> Bool #

max :: Loc -> Loc -> Loc #

min :: Loc -> Loc -> Loc #

Ppr Loc 
Instance details

Defined in Language.Haskell.TH.Ppr

Methods

ppr :: Loc -> Doc #

ppr_list :: [Loc] -> Doc #

type Rep Loc 
Instance details

Defined in Language.Haskell.TH.Syntax

defaultLoc :: Loc Source #

dummy location, used with logWithoutLoc

Since: 0.1

defaultOutput :: HasCallStack => Handle -> Loc -> LogSource -> LogLevel -> LogStr -> IO () Source #

A default implementation of loggerLog that accepts a file handle as the first argument.

This is used in the definition of runStdoutLoggingT:

runStdoutLoggingT :: MonadIO m => LoggingT m a -> m a
runStdoutLoggingT action =
    runLoggingT action (defaultOutput stdout)

Since: 0.1

Level checks

guardLevel Source #

Arguments

:: (Applicative f, HasCallStack) 
=> LogLevel

The configured log level to check against.

-> LogLevel

The log level for this action.

-> (HasCallStack => f ())

The logging action to run if the level passes.

-> f () 

guardLevel configLvl lvl m runs m iff shouldLog configLvl lvl.

Since: 0.1

shouldLog Source #

Arguments

:: LogLevel

The configured log level to check against.

-> LogLevel

Level for this log

-> Bool

Whether we should log

shouldLog configLvl lvl returns true iff configLvl <= lvl. Uses LogLevel's built-in ordering. The ordering is thus:

  LevelTrace
    < LevelDebug
    < LevelInfo
    < LevelWarn
    < LevelError
    < LevelFatal
    < LevelOther "<any>"

In other words, LogLevel's usual Ord is respected. Note that LevelOther "custom" sits at the the highest level and compares via Text's Ord, just like LogLevel's usual Ord.

Since: 0.1

Formatting

data LogFormatter Source #

Formatter for logs.

Since: 0.1

Constructors

MkLogFormatter 

Fields

Instances

Instances details
Generic LogFormatter Source # 
Instance details

Defined in Effectful.Logger.Utils

Associated Types

type Rep LogFormatter

Since: logger-effectful-0.1

Instance details

Defined in Effectful.Logger.Utils

type Rep LogFormatter = D1 ('MetaData "LogFormatter" "Effectful.Logger.Utils" "logger-effectful-0.1-inplace" 'False) (C1 ('MetaCons "MkLogFormatter" 'PrefixI 'True) ((S1 ('MetaSel ('Just "locStrategy") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LocStrategy) :*: S1 ('MetaSel ('Just "newline") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :*: (S1 ('MetaSel ('Just "threadLabel") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "timezone") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool))))
Show LogFormatter Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

Eq LogFormatter Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

(k ~ A_Lens, a ~ LocStrategy, b ~ LocStrategy) => LabelOptic "locStrategy" k LogFormatter LogFormatter a b Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

(k ~ A_Lens, a ~ Bool, b ~ Bool) => LabelOptic "newline" k LogFormatter LogFormatter a b Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

(k ~ A_Lens, a ~ Bool, b ~ Bool) => LabelOptic "threadLabel" k LogFormatter LogFormatter a b Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

(k ~ A_Lens, a ~ Bool, b ~ Bool) => LabelOptic "timezone" k LogFormatter LogFormatter a b Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

type Rep LogFormatter Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

type Rep LogFormatter = D1 ('MetaData "LogFormatter" "Effectful.Logger.Utils" "logger-effectful-0.1-inplace" 'False) (C1 ('MetaCons "MkLogFormatter" 'PrefixI 'True) ((S1 ('MetaSel ('Just "locStrategy") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 LocStrategy) :*: S1 ('MetaSel ('Just "newline") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool)) :*: (S1 ('MetaSel ('Just "threadLabel") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool) :*: S1 ('MetaSel ('Just "timezone") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Bool))))

data LocStrategy Source #

Determines how we log location data.

Since: 0.1

Constructors

LocPartial !Loc

Logs the location with filename, line, col.

Since: 0.1

LocStable !Loc

Logs the location with filename.

Since: 0.1

LocNone

No location logging.

Since: 0.1

Instances

Instances details
Generic LocStrategy Source # 
Instance details

Defined in Effectful.Logger.Utils

Associated Types

type Rep LocStrategy

Since: logger-effectful-0.1

Instance details

Defined in Effectful.Logger.Utils

type Rep LocStrategy = D1 ('MetaData "LocStrategy" "Effectful.Logger.Utils" "logger-effectful-0.1-inplace" 'False) (C1 ('MetaCons "LocPartial" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Loc)) :+: (C1 ('MetaCons "LocStable" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Loc)) :+: C1 ('MetaCons "LocNone" 'PrefixI 'False) (U1 :: Type -> Type)))
Show LocStrategy Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

Eq LocStrategy Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

type Rep LocStrategy Source #

Since: 0.1

Instance details

Defined in Effectful.Logger.Utils

type Rep LocStrategy = D1 ('MetaData "LocStrategy" "Effectful.Logger.Utils" "logger-effectful-0.1-inplace" 'False) (C1 ('MetaCons "LocPartial" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Loc)) :+: (C1 ('MetaCons "LocStable" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Loc)) :+: C1 ('MetaCons "LocNone" 'PrefixI 'False) (U1 :: Type -> Type)))

formatLog Source #

Arguments

:: forall msg (es :: [Effect]). (Concurrent :> es, HasCallStack, Time :> es, ToLogStr msg) 
=> LogFormatter

Formatter to use.

-> LogLevel

The level in which to log.

-> msg

Message.

-> Eff es LogStr

Formatted LogStr.

Produces a formatted LogStr in terms of:

  • Static Concurrent.
  • Dynamic Time.

Example

-- [timestamp][thread_label][code_loc][level] msg
[2022-02-08 10:20:05][thread-label][filename:1:2][Warn] msg

Since: 0.1

Optics