logi_ex v0.1.1 Logi.SinkWriter behaviour

Sink Writer Behaviour.

A sink writer will write log messages to a destination sink process.

The main purpose of writers is to write messages to some output devices (e.g., tty, file, socket).

Summary

Types

A module that implements the Logi.SinkWriter behaviour

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

A writer instance

The data written to a sink

Functions

Returns true if x is a module which implements this behaviour, otherwise false

Gets the module of writer

Gets the state of writer

Gets the writee process of log messages

Creates a new writer instance

Returns true if x is a writer/0 instance, otherwise false

Callbacks

Gets the writee process of log messages

Writes a log message to somewhere

Types

callback_module()
callback_module() :: module

A module that implements the Logi.SinkWriter behaviour.

state()
state() :: any

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

Note

This value might be loaded from ETS every time when a log message is issued. Therefore, very huge state can cause a performance problem.

writer()

A writer instance.

written_data()
written_data() :: Logi.Layout.formatted_data

The data written to a sink.

Functions

callback_module?(x)
callback_module?(any) :: boolean

Returns true if x is a module which implements this behaviour, otherwise false.

get_module(writer)
get_module(writer) :: callback_module

Gets the module of writer.

get_state(writer)
get_state(writer) :: state

Gets the state of writer.

get_writee(writer)
get_writee(writer) :: pid | :undefined

Gets the writee process of log messages.

“writee” is the destination process of written_data/0 of write/4. If such process is dead or unknown, the function returns :undefined.

The result value might change on every call.

new(module, state)

Creates a new writer instance.

write(context, format, data, writer)

Writes a log message.

If it fails to write, an exception will be raised.

writer?(x)
writer?(any) :: boolean

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

Callbacks

get_writee(state)
get_writee(state) :: pid | :undefined

Gets the writee process of log messages.

write(arg0, arg1, arg2, state)

Writes a log message to somewhere.