GitXplorerGitXplorer
g

erl-log-formatter

public
2 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
58017a4ad97ad41df4a6eb6dc70699420c7736b5

update readme

ggaldor committed 4 years ago
Unverified
1045a536e0f21f9714f6fa98aca8da5f16be22f0

put log metadata on their own line

ggaldor committed 4 years ago
Unverified
e4f3cea45c0dbbda22b7d9d570ad28b6b8f9d196

1.3.1

ggaldor committed 4 years ago
Unverified
498efbbec4f5b21e10e25809552187bf56f35eb8

fix metadata escaping

ggaldor committed 4 years ago
Unverified
100abe454eeeaa75c8b34fb5d54c8a13bcbaa707

remove extra whitespace between text parts

ggaldor committed 4 years ago
Unverified
274c85532bd376bf30e4a3912b495041ad99f08e

fix metadata text formatting

ggaldor committed 4 years ago

README

The README file for this repository.

Project

This repository contains a customizable formatter for the logger OTP application.

It currently supports a human-readable text output and a JSON output.

This application is now included in erl-mlog.

Features

Metadata

The following metadata entry are handled separately:

  • domain: see the official documentation for more information.
  • event: a list of atoms identifying what is being logged.

Text output

In text mode, the formatter returns one or more lines of text representing the log message. Messages are prefixed with the log level, domain string (if present) and event string (if present); they are followed by the set of metadata formatted as a sequence of "key=value" strings.

JSON output

In JSON mode, the formatter returns one JSON object serialized as a single line of text for each log message.

The following members are used:

  • level: the log level string (e.g. "error");
  • domain: the domain of the log message formatted as a string (e.g. "otp.sasl"). Optional.
  • event: if the message had an event metadata entry, a string representing the event. For example, if event was [http, request_received], the field will be formatted as http.request_received. Optional.
  • time: the timestamp of the message as a microsecond UNIX timestamp.
  • message: the message string.
  • data: an object containing metadata associated with the message.

Usage

Make sure to add the application as dependency in the Rebar3 configuration file. After that, the formatter is configured as any other logger formatter, in the system configuration file.

Example:

[{kernel,
  [{logger,
    [{handler, default, logger_std_h,
      #{level => debug,
        filter_default => log,
        formatter => {log_formatter, #{format => text}}}}]},
   {logger_level, debug}]}].

See the logger documentation for more information.

Configuration

The following options are available in the formatter configuration map:

  • debug: print log events on the standard output; used when developing the formatter itself.
  • format: the output format, either text or json.
  • include_time: include the time in each formatted message (text format only).
  • color: colorize log entries (text format only).

Contact

If you find a bug or have any question, feel free to open a GitHub issue or to contact me by email.

Please note that I do not currently review or accept any contribution.