fast-logger-3.1.2: A fast logging system
Safe Haskell None
Language Haskell2010

System.Log.FastLogger

Description

This module provides a fast logging system which scales on multicore environments (i.e. +RTS -N<x>).

Note: This library does not guarantee correct ordering of log messages when program is run on more than one core thus users should rely more on message timestamps than on their order in the log.

Synopsis

FastLogger

data LogType' a where Source #

Logger Type.

Constructors

LogNone

Fields

LogStdout

Fields

LogStderr

Fields

LogFileNoRotate

Fields

LogFile

Fields

LogFileTimedRotate

Fields

LogCallback

Fields

  • :: (v -> IO ())
  • -> IO ()
  • -> LogType' v

    Logging with a log and flush action. run flush after log each message.

newFastLogger :: LogType' v -> IO (v -> IO (), IO ()) Source #

Initialize a FastLogger without attaching timestamp a tuple of logger and clean up action are returned. This type signature should be read as:

newFastLogger :: LogType -> IO (FastLogger, IO ())

This logger uses numCapabilities many buffers, and thus does not provide time-ordered output. For time-ordered output, use newFastLogger1 .

newFastLogger1 :: LogType' v -> IO (v -> IO (), IO ()) Source #

Like newFastLogger , but creating a logger that uses only 1 capability. This scales less well on multi-core machines, but provides time-ordered output.

Timed FastLogger

type TimedFastLogger = ( FormattedTime -> LogStr ) -> IO () Source #

TimedFastLogger pass FormattedTime to callback and simply log its result. this can be used to customize how to log timestamp.

Usually, one would write a wrapper on top of TimedFastLogger , for example:

{-# LANGUAGE OverloadedStrings #-}

log :: TimedFastLogger -> LogStr -> IO ()
log logger msg = logger (\time -> toLogStr (show time) <> " " <> msg <> "\n")

newTimedFastLogger Source #

Arguments

:: IO FormattedTime

How do we get FormattedTime ? System.Log.FastLogger.Date provide cached formatted time.

-> LogType
-> IO ( TimedFastLogger , IO ())

Initialize a FastLogger with timestamp attached to each message. a tuple of logger and clean up action are returned.

Log messages

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.

Instances

Instances details
ToLogStr Double Source #

Since: 2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Float Source #

Since: 2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int Source #

Since: 2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int8 Source #

Since: 2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int16 Source #

Since: 2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int32 Source #

Since: 2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Int64 Source #

Since: 2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Integer Source #

Since: 2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Word Source #

Since: 2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Word8 Source #

Since: 2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Word16 Source #

Since: 2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Word32 Source #

Since: 2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Word64 Source #

Since: 2.4.14

Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr String Source #
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr ShortByteString Source #
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr ByteString Source #
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr ByteString Source #
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Builder Source #
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Text Source #
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr Text Source #
Instance details

Defined in System.Log.FastLogger.LogStr

ToLogStr LogStr Source #
Instance details

Defined in System.Log.FastLogger.LogStr

Buffer size

type BufSize = Int Source #

The type for buffer size of each core.

defaultBufSize :: BufSize Source #

The default buffer size (4,096 bytes).

LoggerSet

Date cache

File rotation

Types