fast-logger-2.1.4: A fast logging system

Safe HaskellNone

System.Log.FastLogger

Contents

Description

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

Synopsis

Creating a logger set

data LoggerSet Source

A set of loggers. The number of loggers is the capabilities of GHC RTS. You can specify it with "+RTS -N<x>". A buffer is prepared for each capability.

newFileLoggerSet :: BufSize -> FilePath -> IO LoggerSetSource

Creating a new LoggerSet using a file.

newStdoutLoggerSet :: BufSize -> IO LoggerSetSource

Creating a new LoggerSet using stdout.

newStderrLoggerSet :: BufSize -> IO LoggerSetSource

Creating a new LoggerSet using stderr.

newLoggerSet :: BufSize -> Maybe FilePath -> IO LoggerSetSource

Deprecated: Use newFileLoggerSet etc instead

Creating a new LoggerSet. If Nothing is specified to the second argument, stdout is used. Please note that the minimum BufSize is 1.

Buffer size

type BufSize = IntSource

The type for buffer size of each core.

defaultBufSize :: BufSizeSource

The default buffer size (4,096 bytes).

Renewing and removing a logger set

renewLoggerSet :: LoggerSet -> IO ()Source

Renewing the internal file information in LoggerSet. This does nothing for stdout and stderr.

rmLoggerSet :: LoggerSet -> IO ()Source

Flushing the buffers, closing the internal file information and freeing the buffers.

Log messages

data LogStr Source

Log message builder. Use (<>) to append two LogStr in O(1).

logStrLength :: LogStr -> IntSource

Obtaining the length of LogStr.

Writing a log message

pushLogStr :: LoggerSet -> LogStr -> IO ()Source

Writing a log message to the corresponding buffer. If the buffer becomes full, the log messages in the buffer are written to its corresponding file, stdout, or stderr.

Flushing buffered log messages

flushLogStr :: LoggerSet -> IO ()Source

Flushing log messages in buffers. This function must be called explicitly when the program is being terminated.

File rotation