logrex v0.5.0 Logrex View Source

An Elixir package for more easily adding Logger metadata and formatting the console output so it's easier for humans to parse.

It wraps Elixir's Logger module to let you write code like this:

> use Logrex
> name = "Matt"
> user_info = %{login_count: 1}
> Logrex.info "New login", [name, user_info.login_count]

To display this:

> INFO 20:56:40 New login                    user=Matt login_count=1

Link to this section Summary

Functions

Log a debug message with dynamic metadata.

Log an error message with dynamic metadata.

Custom Logger format function, which receives the Logger arguments and returns a string with formatted key/value metadata pairs broken out to the right of the message.

Log an info message with dynamic metadata.

Logs a metadata-only message.

Log a warning message with dynamic metadata.

Link to this section Functions

Link to this macro

debug(chardata_or_fun, metadata \\ [])

View Source (macro)

Log a debug message with dynamic metadata.

Link to this macro

error(chardata_or_fun, metadata \\ [])

View Source (macro)

Log an error message with dynamic metadata.

Link to this function

format(level, message, timestamp, metadata)

View Source

Custom Logger format function, which receives the Logger arguments and returns a string with formatted key/value metadata pairs broken out to the right of the message.

Link to this macro

info(chardata_or_fun, metadata \\ [])

View Source (macro)

Log an info message with dynamic metadata.

Link to this macro

meta(metadata \\ [])

View Source (macro)

Logs a metadata-only message.

It is a shorthand and more explicit way of using one of the level functions with an empty string as the first parameter. By default, all meta/1 calls are logged as debug, but that can be changed via the :meta_level config.

Examples

Logrex.meta foo: bar
Logrex.meta [var1, var2]
Link to this macro

warn(chardata_or_fun, metadata \\ [])

View Source (macro)

Log a warning message with dynamic metadata.