Timber v3.0.0-alpha.2 Timber.Events.ErrorEvent View Source

The ErrorEvent is used to track errors and exceptions.

The defined structure of this data can be found in the log event JSON schema: https://github.com/timberio/log-event-json-schema

Timber automatically tracks and structures errors and exceptions in your application. Giving you detailed stack traces, context, and error data.

Link to this section Summary

Functions

Adds a stacktrace to an event, converting it if necessary

Builds a new error event from an error / exception

Builds an error from the given log message. This allows us to create Error events downstream in the logging flow. Because of the complicated nature around Elixir exception handling, this is a reliable catch-all to ensure all error are capture and processed properly

Message to be used when logging

Convenience methods for building error events, taking care to normalize values and ensure they meet the validation requirements of the Timber API

Link to this section Types

Link to this type backtrace_entry() View Source
backtrace_entry() :: %{
  app_name: String.t() | nil,
  function: String.t(),
  file: String.t() | nil,
  line: non_neg_integer() | nil
}
Link to this type stacktrace_entry() View Source
stacktrace_entry() ::
  {module(), atom(), arity(),
   [file: IO.chardata(), line: non_neg_integer()] | []}
Link to this type t() View Source
t() :: %Timber.Events.ErrorEvent{
  backtrace: [backtrace_entry()] | nil,
  message: String.t() | nil,
  metadata_json: binary() | nil,
  name: String.t(),
  type: String.t() | nil
}

Link to this section Functions

Link to this function add_backtrace(event, backtrace) View Source
add_backtrace(t(), [stacktrace_entry()] | [backtrace_entry()]) :: t()

Adds a stacktrace to an event, converting it if necessary

Link to this function from_exception(error) View Source
from_exception(Exception.t()) :: t()

Builds a new error event from an error / exception.

Link to this function from_log_message(log_message) View Source
from_log_message(String.t()) :: {:ok, t()} | {:error, atom()}

Builds an error from the given log message. This allows us to create Error events downstream in the logging flow. Because of the complicated nature around Elixir exception handling, this is a reliable catch-all to ensure all error are capture and processed properly.

Link to this function message(error_event) View Source
message(t()) :: IO.chardata()

Message to be used when logging.

Link to this function new(name, message, opts \\ []) View Source

Convenience methods for building error events, taking care to normalize values and ensure they meet the validation requirements of the Timber API.