otel-api-common-0.0.0: STUB
Safe HaskellSafe-Inferred
LanguageHaskell2010

OTel.API.Common.Logging

Synopsis

Documentation

type Logger = Loc -> LogSource -> LogLevel -> LogStr -> IO () Source #

withBufferedLogger :: forall m a. MonadUnliftIO m => BufferedLoggerSpec -> (Logger -> m a) -> m a 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 #

Arguments

:: forall a. ToJSON a 
=> (BufferedLogAgg -> Maybe a)

Summarizes the aggregated info

-> BufferedLog 
-> BufferedLogAgg 
-> [SeriesElem] 
-> LogStr 

bufferedLogLogStr :: BufferedLog -> Either ByteString Text Source #

Right when the log message was parsed as a Message, Left otherwise.