Membrane.Logger (Membrane Core v0.7.0) View Source

Wrapper around the Elixir logger. Adds Membrane prefixes and handles verbose logging.

Prefixes

By default, this wrapper prepends each log with a prefix containing the context of the log, such as element name. This can be turned off via configuration:

use Mix.Config
config :membrane_core, :logger, prefix: false

Regardless of the config, the prefix is passed to Logger metadata under :mb_prefix key. Prefixes are passed via process dictionary, so they have process-wide scope, but it can be extended with get_prefix/0 and set_prefix/1.

Verbose logging

For verbose debug logs that should be silenced by default, use debug_verbose/2 macro. Verbose logs are purged in the compile time, unless turned on via configuration:

use Mix.Config
config :membrane_core, :logger, verbose: true

Verbose debugs should be used for logs that are USUALLY USEFUL for debugging, but printed so often that they make the output illegible. For example, it may be a good idea to debug_verbose from within Membrane.Filter.handle_process/4 or Membrane.Element.WithOutputPads.handle_demand/5 callbacks.

Link to this section Summary

Functions

Wrapper around Logger.bare_log/3 that adds Membrane prefix.

Wrapper around Logger.debug/2 that adds Membrane prefix.

Macro for verbose debug logs, that are silenced by default.

Wrapper around Logger.error/2 that adds Membrane prefix.

Returns the Membrane logger config.

Returns value at given key in the Membrane logger config.

Returns the logger prefix.

Wrapper around Logger.info/2 that adds Membrane prefix.

Wrapper around Logger.log/3 that adds Membrane prefix.

Sets the logger prefix. Avoid using in Membrane-managed processes.

Wrapper around Logger.warn/2 that adds Membrane prefix.

Link to this section Functions

Link to this function

bare_log(level, message, metadata \\ [])

View Source

Specs

bare_log(Logger.level(), Logger.message(), Logger.metadata()) :: :ok

Wrapper around Logger.bare_log/3 that adds Membrane prefix.

For details, see the 'prefixes' section of the moduledoc.

Link to this macro

debug(message, metadata \\ [])

View Source (macro)

Wrapper around Logger.debug/2 that adds Membrane prefix.

For details, see the 'prefixes' section of the moduledoc.

Link to this macro

debug_verbose(message, metadata \\ [])

View Source (macro)

Macro for verbose debug logs, that are silenced by default.

For details, see the 'verbose logging' section of the moduledoc.

Link to this macro

error(message, metadata \\ [])

View Source (macro)

Wrapper around Logger.error/2 that adds Membrane prefix.

For details, see the 'prefixes' section of the moduledoc.

Specs

get_config() :: Keyword.t()

Returns the Membrane logger config.

Link to this function

get_config(key, default \\ nil)

View Source

Specs

get_config(key, value) :: value when key: atom(), value: any()

Returns value at given key in the Membrane logger config.

Specs

get_prefix() :: String.t()

Returns the logger prefix.

Returns an empty string if no prefix is set.

Link to this macro

info(message, metadata \\ [])

View Source (macro)

Wrapper around Logger.info/2 that adds Membrane prefix.

For details, see the 'prefixes' section of the moduledoc.

Link to this macro

log(level, message, metadata \\ [])

View Source (macro)

Wrapper around Logger.log/3 that adds Membrane prefix.

For details, see the 'prefixes' section of the moduledoc.

Specs

set_prefix(prefix :: String.t()) :: :ok

Sets the logger prefix. Avoid using in Membrane-managed processes.

This function is intended to enable setting prefix obtained in a Membrane-managed process via get_prefix/1. If some custom data needs to be prepended to logs, please use Logger.metadata/1.

Prefixes in Membrane-managed processes are set automatically and using this function there would overwrite them, which is usually unintended.

Link to this macro

warn(message, metadata \\ [])

View Source (macro)

Wrapper around Logger.warn/2 that adds Membrane prefix.

For details, see the 'prefixes' section of the moduledoc.