Copyright | (c) 2023 GYELD GMBH |
---|---|
License | Apache 2.0 |
Maintainer | [email protected] |
Stability | develop |
Safe Haskell | None |
Language | GHC2021 |
GeniusYield.Types.Logging
Description
Synopsis
- data GYLogSeverity
- logSeverityToKatip :: GYLogSeverity -> Severity
- newtype GYLogVerbosity = GYLogVerbosity Verbosity
- logVerbosityToKatip :: GYLogVerbosity -> Verbosity
- data GYLogNamespace
- logNamespaceFromKatip :: Namespace -> GYLogNamespace
- logNamespaceToKatip :: GYLogNamespace -> Namespace
- data GYLogContexts
- logContextsFromKatip :: LogContexts -> GYLogContexts
- logContextsToKatip :: GYLogContexts -> LogContexts
- addContext :: LogItem i => i -> GYLogContexts -> GYLogContexts
- sl :: ToJSON a => Text -> a -> SimpleLogPayload
- logContextsToS :: StringConv ByteString a => GYLogContexts -> a
- data GYLogEnv
- logEnvFromKatip :: LogEnv -> GYLogEnv
- logEnvToKatip :: GYLogEnv -> LogEnv
- closeScribes :: GYLogEnv -> IO GYLogEnv
- data GYLogConfiguration = GYLogConfiguration {}
- data GYRawLog = GYRawLog {
- rawLogRun :: RawLogger
- rawLogCleanUp :: IO ()
- newtype RawLogger = RawLogger {
- unRawLogger :: GYLogContexts -> GYLogNamespace -> GYLogSeverity -> Text -> IO ()
- unitRawLogger :: RawLogger
- simpleRawLogger :: GYLogSeverity -> (Text -> IO ()) -> RawLogger
- cfgAddNamespace :: GYLogNamespace -> GYLogConfiguration -> GYLogConfiguration
- cfgAddContext :: LogItem i => i -> GYLogConfiguration -> GYLogConfiguration
- logRun :: (HasCallStack, MonadIO m, StringConv a Text) => GYLogConfiguration -> GYLogSeverity -> a -> m ()
- data GYLogScribeType
- data GYLogScribeConfig = GYLogScribeConfig {}
- newtype LogSrc = LogSrc URI
- prettyNamespace :: GYLogNamespace -> String
- mkLogEnv :: GYLogNamespace -> [GYLogScribeConfig] -> IO GYLogEnv
Severity
data GYLogSeverity #
>>>
LBS8.putStrLn $ Aeson.encode GYDebug
"Debug"
>>>
LBS8.putStrLn $ Aeson.encode GYInfo
"Info"
>>>
LBS8.putStrLn $ Aeson.encode GYWarning
"Warning"
>>>
LBS8.putStrLn $ Aeson.encode GYError
"Error"
Instances
Verbosity
newtype GYLogVerbosity #
>>>
Aeson.eitherDecode @GYLogVerbosity "\"V0\""
Right (GYLogVerbosity V0)
>>>
Aeson.eitherDecode @GYLogVerbosity "\"V1\""
Right (GYLogVerbosity V1)
>>>
Aeson.eitherDecode @GYLogVerbosity "\"V2\""
Right (GYLogVerbosity V2)
>>>
Aeson.eitherDecode @GYLogVerbosity "\"V3\""
Right (GYLogVerbosity V3)
>>>
Aeson.eitherDecode @GYLogVerbosity "\"V4\""
Left "Error in $: Invalid Verbosity V4"
Constructors
GYLogVerbosity Verbosity |
Instances
Namespace
data GYLogNamespace #
>>>
"My" <> "Namespace" :: GYLogNamespace
GYLogNamespace (Namespace {unNamespace = ["My","Namespace"]})
Instances
Log contexts
data GYLogContexts #
Instances
Monoid GYLogContexts # | |
Defined in GeniusYield.Types.Logging Methods mempty :: GYLogContexts # mappend :: GYLogContexts -> GYLogContexts -> GYLogContexts # mconcat :: [GYLogContexts] -> GYLogContexts # | |
Semigroup GYLogContexts # | |
Defined in GeniusYield.Types.Logging Methods (<>) :: GYLogContexts -> GYLogContexts -> GYLogContexts # sconcat :: NonEmpty GYLogContexts -> GYLogContexts # stimes :: Integral b => b -> GYLogContexts -> GYLogContexts # |
addContext :: LogItem i => i -> GYLogContexts -> GYLogContexts #
Add a context to the log contexts. See sl
.
sl :: ToJSON a => Text -> a -> SimpleLogPayload #
Construct a simple log payload.
>>>
Aeson.encode $ logContextsToKatip $ addContext (sl "key" "value") mempty
"{\"key\":\"value\"}"
logContextsToS :: StringConv ByteString a => GYLogContexts -> a #
Get textual representation of log contexts.
>>>
logContextsToS @Text $ addContext (sl "key" "value") mempty
"{\"key\":\"value\"}"
Log environment
logEnvFromKatip :: LogEnv -> GYLogEnv #
logEnvToKatip :: GYLogEnv -> LogEnv #
closeScribes :: GYLogEnv -> IO GYLogEnv #
Calls closeScribes
from Katip.
Log configuration
data GYLogConfiguration #
Constructors
GYLogConfiguration | |
Fields |
Constructors
RawLogger | |
Fields
|
A logger that does ignores the logs.
simpleRawLogger :: GYLogSeverity -> (Text -> IO ()) -> RawLogger #
A logger that ignores context and namespace and filters messages based on severity.
cfgAddContext :: LogItem i => i -> GYLogConfiguration -> GYLogConfiguration #
logRun :: (HasCallStack, MonadIO m, StringConv a Text) => GYLogConfiguration -> GYLogSeverity -> a -> m () #
Scribe Configuration
data GYLogScribeType #
Constructors
GYStdErrScribe | |
GYGCPScribe | |
GYCustomSourceScribe !LogSrc |
Instances
FromJSON GYLogScribeType # |
|
Defined in GeniusYield.Types.Logging Methods parseJSON :: Value -> Parser GYLogScribeType # parseJSONList :: Value -> Parser [GYLogScribeType] # | |
ToJSON GYLogScribeType # |
|
Defined in GeniusYield.Types.Logging Methods toJSON :: GYLogScribeType -> Value # toEncoding :: GYLogScribeType -> Encoding # toJSONList :: [GYLogScribeType] -> Value # toEncodingList :: [GYLogScribeType] -> Encoding # omitField :: GYLogScribeType -> Bool # | |
Show GYLogScribeType # | |
Defined in GeniusYield.Types.Logging Methods showsPrec :: Int -> GYLogScribeType -> ShowS # show :: GYLogScribeType -> String # showList :: [GYLogScribeType] -> ShowS # | |
Eq GYLogScribeType # | |
Defined in GeniusYield.Types.Logging Methods (==) :: GYLogScribeType -> GYLogScribeType -> Bool # (/=) :: GYLogScribeType -> GYLogScribeType -> Bool # | |
Ord GYLogScribeType # | |
Defined in GeniusYield.Types.Logging Methods compare :: GYLogScribeType -> GYLogScribeType -> Ordering # (<) :: GYLogScribeType -> GYLogScribeType -> Bool # (<=) :: GYLogScribeType -> GYLogScribeType -> Bool # (>) :: GYLogScribeType -> GYLogScribeType -> Bool # (>=) :: GYLogScribeType -> GYLogScribeType -> Bool # max :: GYLogScribeType -> GYLogScribeType -> GYLogScribeType # min :: GYLogScribeType -> GYLogScribeType -> GYLogScribeType # |
data GYLogScribeConfig #
Constructors
GYLogScribeConfig | |
Fields |
Instances
Utilities
prettyNamespace :: GYLogNamespace -> String #
mkLogEnv :: GYLogNamespace -> [GYLogScribeConfig] -> IO GYLogEnv #