System.Log.FastLogger.LoggerSet

fast-logger-3.2.5: A fast logging system

Safe Haskell | None
Language | Haskell2010

System.Log.FastLogger.LoggerSet

Contents

- Creating a logger set
- Renewing and removing a logger set
- Writing a log message
- Flushing buffered log messages
- Misc

Synopsis

- data LoggerSet
- newFileLoggerSet :: BufSize -> FilePath -> IO LoggerSet
- newFileLoggerSetN :: BufSize -> Maybe Int -> FilePath -> IO LoggerSet
- newStdoutLoggerSet :: BufSize -> IO LoggerSet
- newStdoutLoggerSetN :: BufSize -> Maybe Int -> IO LoggerSet
- newStderrLoggerSet :: BufSize -> IO LoggerSet
- newStderrLoggerSetN :: BufSize -> Maybe Int -> IO LoggerSet
- newLoggerSet :: BufSize -> Maybe Int -> Maybe FilePath -> IO LoggerSet
- newFDLoggerSet :: BufSize -> Maybe Int -> Maybe FilePath -> FD -> IO LoggerSet
- renewLoggerSet :: LoggerSet -> IO ()
- rmLoggerSet :: LoggerSet -> IO ()
- pushLogStr :: LoggerSet -> LogStr -> IO ()
- pushLogStrLn :: LoggerSet -> LogStr -> IO ()
- flushLogStr :: LoggerSet -> IO ()
- replaceLoggerSet :: LoggerSet -> FilePath -> (LoggerSet, Maybe FilePath)

# Creating a logger set

data LoggerSet #

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 LoggerSet #

Creating a new `LoggerSet` using a file.

Uses `numCapabilties` many buffers, which will result in log output that is not ordered by time (see `newFileLoggerSetN`).

newFileLoggerSetN :: BufSize -> Maybe Int -> FilePath -> IO LoggerSet #

Creating a new `LoggerSet` using a file, using only the given number of capabilites.

Giving `mn = Just 1` scales less well on multi-core machines, but provides time-ordered output.

newStdoutLoggerSet :: BufSize -> IO LoggerSet #

Creating a new `LoggerSet` using stdout.

newStdoutLoggerSetN :: BufSize -> Maybe Int -> IO LoggerSet #

Creating a new `LoggerSet` using stdout, with the given number of buffers (see `newFileLoggerSetN`).

newStderrLoggerSet :: BufSize -> IO LoggerSet #

Creating a new `LoggerSet` using stderr.

newStderrLoggerSetN :: BufSize -> Maybe Int -> IO LoggerSet #

Creating a new `LoggerSet` using stderr, with the given number of buffers (see `newFileLoggerSetN`).

newLoggerSet :: BufSize -> Maybe Int -> Maybe FilePath -> IO LoggerSet #

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.

newFDLoggerSet :: BufSize -> Maybe Int -> Maybe FilePath -> FD -> IO LoggerSet #

Creating a new `LoggerSet` using a FD.

# Renewing and removing a logger set

renewLoggerSet :: LoggerSet -> IO () #

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

rmLoggerSet :: LoggerSet -> IO () #

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

# Writing a log message

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

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.

pushLogStrLn :: LoggerSet -> LogStr -> IO () #

Same as `pushLogStr` but also appends a newline.

# Flushing buffered log messages

flushLogStr :: LoggerSet -> IO () #

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

Note: Since version 2.1.6, this function does not need to be explicitly called, as every push includes an auto-debounced flush courtesy of the auto-update package. Since version 2.2.2, this function can be used to force flushing outside of the debounced flush calls.

# Misc

replaceLoggerSet :: LoggerSet -> FilePath -> (LoggerSet, Maybe FilePath) #

Replacing the file path in `LoggerSet` and returning a new `LoggerSet` and the old file path.