SimpleLog- Simple, configurable logging

Safe HaskellTrustworthy




This module defines the Format datatype that describes how to format a log line. It also defines a template function $(format _) :: Format that allows C-style string formatting. The format string is thus parsed at compile time.

The format string may contain the following elements:

  • %m - The logged message
  • %s - The severity of the message
  • %t - The name of the logging thread
  • %d(FORMAT) - A timestamp, formatted with FORMAT.

The datetime FORMAT is a UNIX style format string detailed in Data.Time.Format. The only difference is that closing brackets ')' inside the datetime format must be escaped with a backslash.


logFormat = $(format "%d(%T) (%s) %t: %m")

Which when logging with logI "Something" will produce something like:

14:49:06 (INFO   ) main: Something

Example for escaping ')' in the datetime format string:

logFormat = $(format "%d((%F\\)(%T\\)) %m")

Which when logging with logI "Something" will produce:

(2013-10-02)(16:26:21) Something

Note how we need an additional '\' because of Haskell strings



type Format = [FormatElem] Source

Format is the type of a full format. It is simply a list of FormatElems

format :: String -> ExpQ Source

$(format _) :: Format is a template function that parses the passed in format string, then finalises it and returns a Format.