logi_ex v0.1.1 Logi.Layout behaviour

Log Message Layout Behaviour.

This module defines the standard interface to format log messages issued by the functions in Logi module. (e.g., Logi.info/3, Logi.warning/3, etc)

A layout instance may be installed into a channel along with an associated sink.

Examples

iex> format_fun = fn (_, format, data) -> :lists.flatten(:io_lib.format("EXAMPLE: " <> format <> "\n", data)) end
iex> layout = Logi.BuiltIn.Layout.Fun.new format_fun
iex> {:ok, _} = Logi.Channel.install_sink(Logi.BuiltIn.Sink.IoDevice.new(:foo, [layout: layout]), :info)
iex> Logi.info "hello world"
#OUTPUT# EXAMPLE: hello world

Summary

Types

A module that implements the Logi.Layout behaviour

A data which is subject to format

The value of the fourth arguemnt of the format/4 callback function

Formatted Data

An instance of Logi.Layout behaviour implementation module

Functions

Returns an formatted_data() which represents data formatted by layout in accordance with format and context

Gets the extra data of layout

Gets the module of layout

Returns true if x is a layout/0, false otherwise

Creates a new layout instance

Callbacks

Message formatting function

Types

callback_module()
callback_module() :: module

A module that implements the Logi.Layout behaviour.

data()
data() :: [any]

A data which is subject to format.

This type is an alias of the type of second arguemnt of the :io_lib.format/2.

extra_data()
extra_data() :: any

The value of the fourth arguemnt of the format/4 callback function.

If the layout() does not have an explicit extra_data(), nil will be passed instead.

formatted_data()
formatted_data() :: any

Formatted Data.

layout()

An instance of Logi.Layout behaviour implementation module.

Functions

format(context, format, data, layout)
format(Logi.Context.context, :io.format, data, layout) :: formatted_data

Returns an formatted_data() which represents data formatted by layout in accordance with format and context.

get_extra_data(layout)
get_extra_data(layout) :: extra_data

Gets the extra data of layout.

get_module(layout)
get_module(layout) :: callback_module

Gets the module of layout.

layout?(x)
layout?(any) :: boolean

Returns true if x is a layout/0, false otherwise.

new(module, extra_data \\ nil)

Creates a new layout instance.

Callbacks

format(arg0, arg1, data, extra_data)

Message formatting function.