co-log-polysemy-formatting-0.1.1.0: A Polysemy logging effect for high quality (unstructured) logs.
Safe HaskellNone
LanguageHaskell2010

Colog.Polysemy.Formatting.Render

Description

 
Synopsis

Documentation

renderThreadTimeMessage :: LogEnv -> ThreadTimeMessage -> Text Source #

Render the message, optionally in color, with green " | " separating fields, and these fields:

  • Severity (e.g. INFO, see fSeverity),
  • Timestamp (e.g. "2020-10-13T16:58:43.982720690+1100", see fIso8601Tz),
  • Thread Id (e.g. "Thread 8", see fThread),
  • Caller (e.g. "MyApp.CLI.cliMain#43", see fCallerLong), and
  • The log message itself.

E.g: "INFO | 2020-10-13T17:06:52.408921221+1100 | Thread 8 | MyApp.CLI.cliMain#43 | MyApp version 0.1.0.0"

The first three columns are fixed-width, which makes visual scanning of the log easier.

renderThreadTimeMessageShort :: LogEnv -> ThreadTimeMessage -> Text Source #

Like renderThreadTimeMessage, but abbreviate the caller by removing lowercase letters from the module name.

fIso8601Tz :: FormatTime a => (Color -> Builder -> Builder) -> Format r (a -> r) Source #

Render a timestamp in ISO-8601 format, in color, to 9 decimal places, e.g.: "2020-10-13T16:58:43.982720690+1100"

The T is rendered in green, the time in yellow, the rest without color.

fSeverity :: (Color -> Builder -> Builder) -> Format r (Severity -> r) Source #

Render the Severity of the message, with color, using 4 characters to maintain alignment:

  • DBUG in green,
  • INFO in blue,
  • WARN in yellow, or
  • ERR in red.

fThread :: Format r (ThreadId -> r) Source #

Render the Id of the thread that the log message was generated in, with a fixed width, at least until the thread Ids exceed 100,000, e.g. "Thread 97".

fCaller :: (Color -> Builder -> Builder) -> Format r (String -> String -> Int -> r) Source #

fCallerLong :: (Color -> Builder -> Builder) -> Format r (CallStack -> r) Source #

Render the fully qualified function that called the log function, and line number in the source file, e.g. "MyApp.CLI.cliMain#43", with the function name in cyan and line number in red.

fCallerShort :: (Color -> Builder -> Builder) -> Format r (CallStack -> r) Source #

Render the fully qualified function that called the log function, and line number in the source file, abbreviating the module path by removing lower-case letters, e.g. "MA.CLI.cliMain#43", with the function name in cyan and line number in red.