Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type Logger = Loc -> LogSource -> LogLevel -> LogStr -> IO ()
- withBufferedLogger :: forall m a. MonadUnliftIO m => BufferedLoggerSpec -> (Logger -> m a) -> m a
- data BufferedLoggerSpec
- defaultBufferedLoggerSpec :: BufferedLoggerSpec
- bufferedLoggerSpecShouldBuffer :: BufferedLoggerSpec -> Loc -> LogSource -> LogLevel -> LogStr -> Bool
- bufferedLoggerSpecLogger :: BufferedLoggerSpec -> Logger
- bufferedLoggerSpecFlushPeriod :: BufferedLoggerSpec -> Int
- bufferedLoggerSpecFlushTimeout :: BufferedLoggerSpec -> Int
- bufferedLoggerSpecOnFlushTimeout :: BufferedLoggerSpec -> BufferedLogs -> OnTimeout ()
- bufferedLoggerSpecOnFlushException :: BufferedLoggerSpec -> BufferedLog -> BufferedLogAgg -> OnException ()
- bufferedLoggerSpecOnFlushExceptionLogger :: BufferedLoggerSpec -> Logger
- bufferedLoggerSpecIncludeLogAggregate :: BufferedLoggerSpec -> BufferedLog -> BufferedLogAgg -> [SeriesElem] -> LogStr
- includeLogAggregateViaAeson :: forall a. ToJSON a => (BufferedLogAgg -> Maybe a) -> BufferedLog -> BufferedLogAgg -> [SeriesElem] -> LogStr
- type BufferedLogs = HashMap BufferedLog BufferedLogAgg
- data BufferedLog
- bufferedLogLoc :: BufferedLog -> Loc
- bufferedLogLogSource :: BufferedLog -> LogSource
- bufferedLogLogLevel :: BufferedLog -> LogLevel
- bufferedLogLogStr :: BufferedLog -> Either ByteString Text
- data BufferedLogAgg
- bufferedLogAggCount :: BufferedLogAgg -> Int
- bufferedLogAggMetas :: BufferedLogAgg -> DList (KeyMap Value)
Documentation
withBufferedLogger :: forall m a. MonadUnliftIO m => BufferedLoggerSpec -> (Logger -> m a) -> m a Source #
data BufferedLoggerSpec Source #
bufferedLoggerSpecShouldBuffer :: BufferedLoggerSpec -> Loc -> LogSource -> LogLevel -> LogStr -> Bool Source #
Predicate that determines if a log message should be buffered. The default is no buffering, so all log messages are logged immediately.
bufferedLoggerSpecLogger :: BufferedLoggerSpec -> Logger Source #
The logger to wrap. For all unbuffered log messages, these
are passed to bufferedLoggerSpecLogger
immediately. For
buffered log messages, aggregates will eventually be passed
to bufferedLoggerSpecLogger
on the configured period (see
bufferedLoggerSpecFlushPeriod
).
bufferedLoggerSpecFlushPeriod :: BufferedLoggerSpec -> Int Source #
Buffered logs are regularly flushed from internal storage on this period (in microseconds). The default is 5 minutes.
bufferedLoggerSpecFlushTimeout :: BufferedLoggerSpec -> Int Source #
Max amount of time allowed for flushing buffered logs (in microseconds). The default is 10 seconds.
bufferedLoggerSpecOnFlushTimeout :: BufferedLoggerSpec -> BufferedLogs -> OnTimeout () Source #
Handler that is run if flushing buffered logs takes longer than
bufferedLoggerSpecFlushTimeout
. The default is to log the timeout using
bufferedLoggerSpecOnFlushExceptionLogger
. This may be overridden if the
timeout needs to be reported or dealt with via some means other than
logging. Note that if the handler throws a synchronous exception, that
exception will be caught and ignored.
The input argument is all remaining buffered logs that were unable to be flushed within the timeout.
bufferedLoggerSpecOnFlushException :: BufferedLoggerSpec -> BufferedLog -> BufferedLogAgg -> OnException () Source #
Handler that is run if a synchronous exception is encountered during
log flushing. The default is to log the exception using
bufferedLoggerSpecOnFlushExceptionLogger
. This may be overridden if the
exception needs to be reported or dealt with via some means other than
logging. Note that if the handler rethrows the exception, the exception
will be caught and ignored.
The input arguments are the specific buffered log and aggregate that encountered an exception during flushing.
bufferedLoggerSpecOnFlushExceptionLogger :: BufferedLoggerSpec -> Logger Source #
The bufferedLoggerSpecOnFlushTimeout
and
bufferedLoggerSpecOnFlushException
handlers are run using this logger.
This logger is intentionally different from bufferedLoggerSpecLogger
,
as bufferedLoggerSpecLogger
may have ultimately been what triggered
running either handler in the first place.
bufferedLoggerSpecIncludeLogAggregate :: BufferedLoggerSpec -> BufferedLog -> BufferedLogAgg -> [SeriesElem] -> LogStr Source #
The internal storage tracks a count of each buffered log message's
occurrences (rather than tracking each occurrence) and each occurrence's
metadata (convenience for monad-logger-aeson
users). This function
enables including this aggregate info in the log message when it is
eventually logged. The default is to not include the aggregate info.
monad-logger-aeson
users may find it convenient to set this function
to includeLogAggregateViaAeson Just
. This will include the aggregate in
full. If there is a risk that a buffered log's aggregated metadata may
exceed a logging system's max payload per message, Just
can be replaced
with a function that more carefully summarizes the metadata. For example,
to ignore the metadata altogether and instead only log the count of
aggregated messages, the following could be used:
includeLogAggregateViaAeson
\bufferedLogAgg ->Just
$object
["count".=
bufferedLogAggCount
bufferedLogAgg]
includeLogAggregateViaAeson Source #
:: forall a. ToJSON a | |
=> (BufferedLogAgg -> Maybe a) | Summarizes the aggregated info |
-> BufferedLog | |
-> BufferedLogAgg | |
-> [SeriesElem] | |
-> LogStr |
data BufferedLog Source #
Instances
ToJSON BufferedLog Source # | |
Defined in OTel.API.Common.Internal toJSON :: BufferedLog -> Value # toEncoding :: BufferedLog -> Encoding # toJSONList :: [BufferedLog] -> Value # toEncodingList :: [BufferedLog] -> Encoding # omitField :: BufferedLog -> Bool # | |
Eq BufferedLog Source # | |
Defined in OTel.API.Common.Internal (==) :: BufferedLog -> BufferedLog -> Bool # (/=) :: BufferedLog -> BufferedLog -> Bool # | |
Hashable BufferedLog Source # | |
Defined in OTel.API.Common.Internal hashWithSalt :: Int -> BufferedLog -> Int # hash :: BufferedLog -> Int # |
bufferedLogLoc :: BufferedLog -> Loc Source #
data BufferedLogAgg Source #
Instances
ToJSON BufferedLogAgg Source # | |
Defined in OTel.API.Common.Internal toJSON :: BufferedLogAgg -> Value # toEncoding :: BufferedLogAgg -> Encoding # toJSONList :: [BufferedLogAgg] -> Value # toEncodingList :: [BufferedLogAgg] -> Encoding # omitField :: BufferedLogAgg -> Bool # | |
Semigroup BufferedLogAgg Source # | |
Defined in OTel.API.Common.Internal (<>) :: BufferedLogAgg -> BufferedLogAgg -> BufferedLogAgg # sconcat :: NonEmpty BufferedLogAgg -> BufferedLogAgg # stimes :: Integral b => b -> BufferedLogAgg -> BufferedLogAgg # | |
Eq BufferedLogAgg Source # | |
Defined in OTel.API.Common.Internal (==) :: BufferedLogAgg -> BufferedLogAgg -> Bool # (/=) :: BufferedLogAgg -> BufferedLogAgg -> Bool # |
bufferedLogAggMetas :: BufferedLogAgg -> DList (KeyMap Value) Source #