Safe Haskell | None |
---|---|
Language | GHC2021 |
Effectful.Logger.Namespace
Description
Provides static namespaced logging functionality on top of
Logger
.
Since: 0.1
Synopsis
- newtype Namespace = MkNamespace {
- unNamespace :: Seq Text
- addNamespace :: forall env a k (es :: [Effect]). (Is k A_Setter, LabelOptic' "namespace" k env Namespace, Reader env :> es) => Text -> Eff es a -> Eff es a
- type HasNamespace env k (es :: [Effect]) = (Is k A_Getter, Is k A_Setter, LabelOptic' "namespace" k env Namespace, Reader env :> es)
- type LoggerNS env k (es :: [Effect]) = (HasNamespace env k es, Logger :> es, Reader env :> es)
- data LogFormatter = MkLogFormatter {
- locStrategy :: !LocStrategy
- newline :: !Bool
- threadLabel :: !Bool
- timezone :: !Bool
- defaultLogFormatter :: Loc -> LogFormatter
- data LocStrategy
- = LocPartial !Loc
- | LocStable !Loc
- | LocNone
- formatLog :: forall env msg k (es :: [Effect]). (Concurrent :> es, Is k A_Getter, LabelOptic' "namespace" k env Namespace, HasCallStack, Reader env :> es, Time :> es, ToLogStr msg) => LogFormatter -> LogLevel -> msg -> Eff es LogStr
- logStrToBs :: LogStr -> ByteString
- logStrToText :: LogStr -> Text
- _LocPartial :: Prism' LocStrategy Loc
- _LocStable :: Prism' LocStrategy Loc
- _LocNone :: Prism' LocStrategy ()
Effect
Logging namespace.
Since: 0.1
Constructors
MkNamespace | |
Fields
|
Instances
NFData Namespace Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils | |||||
Monoid Namespace Source # | Since: 0.1 | ||||
Semigroup Namespace Source # | Since: 0.1 | ||||
IsString Namespace Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils Methods fromString :: String -> Namespace # | |||||
Generic Namespace Source # | |||||
Defined in Effectful.Logger.Utils Associated Types
| |||||
IsList Namespace Source # | Since: 0.1 | ||||
Show Namespace Source # | Since: 0.1 | ||||
Eq Namespace Source # | Since: 0.1 | ||||
(k ~ An_Iso, a ~ Seq Text, b ~ Seq Text) => LabelOptic "unNamespace" k Namespace Namespace a b Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils | |||||
type Rep Namespace Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils | |||||
type Item Namespace Source # | |||||
Defined in Effectful.Logger.Utils |
Arguments
:: forall env a k (es :: [Effect]). (Is k A_Setter, LabelOptic' "namespace" k env Namespace, Reader env :> es) | |
=> Text | New namespace. |
-> Eff es a | |
-> Eff es a |
Adds to the namespace.
Since: 0.1
Constraint aliases
type HasNamespace env k (es :: [Effect]) = (Is k A_Getter, Is k A_Setter, LabelOptic' "namespace" k env Namespace, Reader env :> es) Source #
Alias for constraints required to use namespaces.
type LoggerNS env k (es :: [Effect]) = (HasNamespace env k es, Logger :> es, Reader env :> es) Source #
Alias for HasNamespace and Logger constraint.
Formatting
data LogFormatter Source #
Formatter for logs.
Since: 0.1
Constructors
MkLogFormatter | |
Fields
|
Instances
defaultLogFormatter :: Loc -> LogFormatter Source #
LogFormatter
with:
locStrategy
=LocPartial
locnewline
=True
threadLabel
=False
timezone
=False
Since: 0.1
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
Generic LocStrategy Source # | |||||
Defined in Effectful.Logger.Utils Associated Types
| |||||
Show LocStrategy Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils Methods showsPrec :: Int -> LocStrategy -> ShowS # show :: LocStrategy -> String # showList :: [LocStrategy] -> ShowS # | |||||
Eq LocStrategy Source # | Since: 0.1 | ||||
Defined in Effectful.Logger.Utils | |||||
type Rep LocStrategy Source # | Since: 0.1 | ||||
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))) |
Arguments
:: forall env msg k (es :: [Effect]). (Concurrent :> es, Is k A_Getter, LabelOptic' "namespace" k env Namespace, HasCallStack, Reader env :> es, Time :> es, ToLogStr msg) | |
=> LogFormatter | Formatter. |
-> LogLevel | Log level. |
-> msg | Message. |
-> Eff es LogStr |
Produces a formatted LogStr
in terms of:
- Static Concurrent.
- Static Reader.
- Dynamic Time.
Example
-- [timestamp][thread_label][namespace][code_loc][level] msg [2022-02-08 10:20:05][thread-label][one.two][filename:1:2][Warn] msg
Since: 0.1
LogStr
logStrToBs :: LogStr -> ByteString Source #
Since: 0.1
logStrToText :: LogStr -> Text Source #
Since: 0.1
Optics
LocStrategy
_LocPartial :: Prism' LocStrategy Loc Source #
Since: 0.1
_LocStable :: Prism' LocStrategy Loc Source #
Since: 0.1
_LocNone :: Prism' LocStrategy () Source #
Since: 0.1