LogVol (log_vol v0.0.2)

Documentation for LogVol, a wrapper around Elixir's native Logger with global volume control.

Link to this section Summary

Functions

Configures the underlying Elixir Logger. This is a wrapper for Logger.configure/1 and therefore takes the same options found in the docs here.

Logs the debug message at the currently set volume. If a message is not specified at a volume, nothing will be displayed if debug is called at that volume.

See docs for debug/1.

Logs the error message at the currently set volume. If a message is not specified at a volume, nothing will be displayed if error is called at that volume.

See docs for error/1.

Logs the info message at the currently set volume. If a message is not specified at a volume, nothing will be displayed if info is called at that volume.

See docs for info/1.

Logs the given messages at the given level, where level is an atom from the following list of supported log levels

Sets the logging volume for the application. There are 5 supported log volumes

Same as set/1 except raises if unsuccessful.

Sets the logging level for the application. Attempting to log any message with severity less than the given level will cause the message to be ignored. This is a convenience for LogVol.configure(level: some_level).

Same as set_level/1 except raises if unsuccessful.

Returns the currently set logging volume for the application.

Logs the warn message at the currently set volume. If a message is not specified at a volume, nothing will be displayed if warn is called at that volume.

See docs for warn/1.

Link to this section Functions

Link to this function

configure(options)

Configures the underlying Elixir Logger. This is a wrapper for Logger.configure/1 and therefore takes the same options found in the docs here.

Link to this function

debug(string_or_keyword)

Logs the debug message at the currently set volume. If a message is not specified at a volume, nothing will be displayed if debug is called at that volume.

Usage

For convenience, debug/1 can be given a string to log at :normal volume or a keyword list of strings to log at any volume. debug/2 takes a string to log at :normal volume and a keyword list of strings to log at other volumes.

Examples

iex> LogVol.volume
:normal
iex> LogVol.debug("normal msg")
timestamp [debug] normal msg
:ok
iex> LogVol.set :verbose
:ok
iex> LogVol.debug("normal msg", verbose: "verbose msg")
timestamp [debug] verbose msg
:ok
iex> LogVol.debug(verbose: "verbose msg")
timestamp [debug] verbose msg
:ok
iex> LogVol.debug(very_verbose: "very verbose msg")
:noop
iex> LogVol.debug("normal msg")
:noop
Link to this function

debug(string, messages)

See docs for debug/1.

Link to this function

error(string_or_keyword)

Logs the error message at the currently set volume. If a message is not specified at a volume, nothing will be displayed if error is called at that volume.

Usage

For convenience, error/1 can be given a string to log at :normal volume or a keyword list of strings to log at any volume. error/2 takes a string to log at :normal volume and a keyword list of strings to log at other volumes.

Examples

iex> LogVol.volume
:normal
iex> LogVol.error("normal msg")
timestamp [error] normal msg
:ok
iex> LogVol.set :verbose
:ok
iex> LogVol.error("normal msg", verbose: "verbose msg")
timestamp [error] verbose msg
:ok
iex> LogVol.error(verbose: "verbose msg")
timestamp [error] verbose msg
:ok
iex> LogVol.error(very_verbose: "very verbose msg")
:noop
iex> LogVol.error("normal msg")
:noop
Link to this function

error(string, messages)

See docs for error/1.

Link to this function

info(string_or_keyword)

Logs the info message at the currently set volume. If a message is not specified at a volume, nothing will be displayed if info is called at that volume.

Usage

For convenience, info/1 can be given a string to log at :normal volume or a keyword list of strings to log at any volume. info/2 takes a string to log at :normal volume and a keyword list of strings to log at other volumes.

Examples

iex> LogVol.volume
:normal
iex> LogVol.info("normal msg")
timestamp [info] normal msg
:ok
iex> LogVol.set :verbose
:ok
iex> LogVol.info("normal msg", verbose: "verbose msg")
timestamp [info] verbose msg
:ok
iex> LogVol.info(verbose: "verbose msg")
timestamp [info] verbose msg
:ok
iex> LogVol.info(quiet: "quiet msg")
:noop
iex> LogVol.info("normal msg")
:noop
Link to this function

info(string, messages)

See docs for info/1.

Link to this function

log(level, messages)

Logs the given messages at the given level, where level is an atom from the following list of supported log levels:

debug

info warn error

Examples

iex> LogVol.volume
:normal
iex> LogVol.log(:debug, normal: "normal msg") # same as LogVol.debug("normal msg")
timestamp [debug] normal msg
:ok
iex> LogVol.log(:error, quiet: "quiet msg", verbose: "verbose msg")
:noop

Sets the logging volume for the application. There are 5 supported log volumes:

:very_verbose
:verbose
:normal
:quiet
:silent # all logs will be suppressed

Returns :ok if successful or returns {:error, reason}.

Same as set/1 except raises if unsuccessful.

Link to this function

set_level(level)

Sets the logging level for the application. Attempting to log any message with severity less than the given level will cause the message to be ignored. This is a convenience for LogVol.configure(level: some_level).

Usage

Whereas configure/1 supports all the options of Logger.configure/1, this function only accepts LogVol's supported levels along with:

:all - all messages will be logged, conceptually identical to :debug
:none - no messages will be logged at all

See configure/1 for more details on runtime configuration.

Returns :ok if successful or {:error, reason} if unsuccessful.

Link to this function

set_level!(level)

Same as set_level/1 except raises if unsuccessful.

Returns the currently set logging volume for the application.

Examples

iex> LogVol.volume
:normal
Link to this function

warn(string_or_keyword)

Logs the warn message at the currently set volume. If a message is not specified at a volume, nothing will be displayed if warn is called at that volume.

Usage

For convenience, warn/1 can be given a string to log at :normal volume or a keyword list of strings to log at any volume. warn/2 takes a string to log at :normal volume and a keyword list of strings to log at other volumes.

Examples

iex> LogVol.volume
:normal
iex> LogVol.warn("normal msg")
timestamp [warn] normal msg
:ok
iex> LogVol.set :verbose
:ok
iex> LogVol.warn("normal msg", verbose: "verbose msg")
timestamp [warn] verbose msg
:ok
iex> LogVol.warn(verbose: "verbose msg")
timestamp [warn] verbose msg
:ok
iex> LogVol.warn(very_verbose: "very verbose msg")
:noop
iex> LogVol.warn("normal msg")
:noop
Link to this function

warn(string, messages)

See docs for warn/1.