Sovite.Core.Logging (sovite v0.2.0)

Copy Markdown View Source

Configures logging from the [log] config section.

Logs go to standard output through the VM's default :logger handler, or, when directory is set, to rotating files written by Sovite.Core.Logging.FileHandler.

Every log line about a message carries its queue ID in the :queue_id metadata key, so one message's lifecycle can be followed with grep. metadata_keys/0 lists the standard keys. See docs/logging.md.

Summary

Functions

Returns the child specs that write logs to files, or [] when logging to standard output.

Applies the log level and format to the default handler.

Formats an IP address for the :remote_ip metadata key. The text formatter skips tuples, so addresses are logged as strings.

Returns the :logger formatter for format.

Metadata keys included in every log format.

Types

config()

@type config() :: %{
  level: :debug | :info | :notice | :warning | :error,
  format: :text | :json,
  directory: Path.t() | nil,
  file_name: String.t(),
  date_format: String.t(),
  max_size: pos_integer(),
  rotation: Sovite.Core.Logging.FileHandler.rotation(),
  max_files: non_neg_integer(),
  symlink: String.t() | nil
}

Functions

child_specs(log)

@spec child_specs(config()) :: [Supervisor.module_spec()]

Returns the child specs that write logs to files, or [] when logging to standard output.

The file handler silences the default handler while it runs, so lines are not written twice.

configure(map)

@spec configure(config()) :: :ok

Applies the log level and format to the default handler.

format_ip(ip)

@spec format_ip(:inet.ip_address() | nil) :: String.t() | nil

Formats an IP address for the :remote_ip metadata key. The text formatter skips tuples, so addresses are logged as strings.

formatter(format, opts \\ [])

@spec formatter(:text | :json, keyword()) :: {module(), term()}

Returns the :logger formatter for format.

For :text, opts are passed to Logger.Formatter.new/1.

metadata_keys()

@spec metadata_keys() :: [atom()]

Metadata keys included in every log format.