Timber v2.3.0 Timber.LogEntry View Source

The LogEntry module formalizes the structure of every log entry.

When a log is produced, it is converted to this intermediary form by the Timber.LoggerBackend module before being passed on to the desired transport. Each transport implements a write/2 function as defined by the Timber.Transport.write/2 behaviour. Inside of this function, the transport is responsible for formatting the data contained in a log entry appropriately.

Each log entry consists of the log message, its level, the timestamp it was logged at, a context map, and an optional event. See the main Timber module for more information.

Link to this section Summary

Link to this section Types

Link to this type format() View Source
format() :: :json | :logfmt
Link to this type t() View Source
t() :: %Timber.LogEntry{context: Timber.Context.t, dt: IO.chardata, event: Timber.Event.t | nil, level: Timber.LoggerBackend.level, message: Timber.LoggerBackend.message, tags: nil | [String.t], time_ms: nil | float}

Link to this section Functions

Link to this function new(timestamp, level, message, metadata) View Source
new(Timber.LoggerBackend.timestamp, Logger.level, Logger.message, Keyword.t) :: t

Creates a new LogEntry struct

The metadata from Logger is given as the final parameter. If the :timber_context key is present in the metadata, it will be used to fill the context for the log entry. Otherwise, a blank context will be used.

Link to this function to_map!(log_entry, options \\ []) View Source
to_map!(t, Keyword.t) :: map
Link to this function to_string!(log_entry, format, options \\ []) View Source
to_string!(t, format, Keyword.t) :: IO.chardata

Encodes the log event to a string

Options

  • :only - A list of key names. Only the key names passed will be encoded.