rotating-log-0.2

Stabilityexperimental
Maintaineradmin@soostone.com
Safe HaskellNone

System.RotatingLog

Contents

Description

Convenient logging to a disk-based log file with automatic file rotation based on size.

Synopsis

Core API

data RotatingLog Source

A size-limited rotating log. Log filenames are of the format prefix_timestamp.log.

mkRotatingLogSource

Arguments

:: String

A prefix for the written log files.

-> Word64

A size limit in bytes.

-> BufferMode

A buffering mode for output; we leave it to you to decide how often the file should be flushed.

-> (FilePath -> IO ())

An action to be performed on the finished file following rotation. For example, you could give a callback that moves or ships the files somewhere else.

-> IO RotatingLog 

Creates a rotating log given a prefix and size limit in bytes.

rotatedWrite :: RotatingLog -> ByteString -> IO ()Source

Like rotatedWrite', but doesn't need a UTCTime and obtains it with a syscall.

rotatedWrite' :: RotatingLog -> UTCTime -> ByteString -> IO ()Source

Writes ByteString to a rotating log file. If this write would exceed the size limit, then the file is closed and a new file opened. This function takes a UTCTime to allow a cached time to be used to avoid a system call.

Please note this function does NOT implicitly insert a newline at the end of the string you provide. This is so that it can be used to log non-textual streams such as binary serialized or compressed content.

Built-In Post-Rotate Actions

archiveFileSource

Arguments

:: FilePath

A target archive directory

-> FilePath -> IO () 

A built-in post-rotate action that moves the finished file to a given archive location.