ex_syslogger v1.4.2 ExSyslogger.JsonFormatter View Source

JsonFormatter is formatter that produces a properly JSON object string where the level, message, node, and metadata are JSON object root properties.

JSON object:

  {
    "level": "error",
    "message": "hello JSON formatter",
    "node": "foo@local",
    "module": "MyApp.MyModule",
    "function": "do_something/2",
    "line": 21
  }

JSON string:

{"level":"error","message":"hello JSON formatter","node":"foo@local","module":"MyApp.MyModule","function":"do_something/2","line":21}

Link to this section Summary

Functions

Compiles a format string into an array that the format/6 can handle. It uses Logger.Formatter

Takes a compiled format and injects the level, message, node and metadata and returns a properly formatted JSON object where level, message, node and metadata properties are root JSON properties. Message is formated with Logger.Formatter

Link to this section Functions

Link to this function compile(str) View Source
compile({atom(), atom()}) :: {atom(), atom()}
compile(binary() | nil) :: [Logger.Formatter.pattern() | binary()]

Compiles a format string into an array that the format/6 can handle. It uses Logger.Formatter.

Link to this function format(format, level, msg, timestamp, metadata, config_metadata) View Source

Takes a compiled format and injects the level, message, node and metadata and returns a properly formatted JSON object where level, message, node and metadata properties are root JSON properties. Message is formated with Logger.Formatter.

config_metadata: is the metadata that is set on the configuration e.g. metadata: [:module, :line, :function] to include :module, :line and :function keys. Can be set to :all to include all keys.