Module logi_sink_writer

Sink Writer Behaviour.

Copyright © 2014-2016 Takeru Ohta <phjgt308@gmail.com>

This module defines the logi_sink_writer behaviour.
Required callback functions: write/4, get_writee/1.

Description

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).

Data Types

callback_module()

callback_module() = module()

A module that implements the logi_sink_writer behaviour.

state()

state() = term()

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()

abstract datatype: writer()

A writer instance.

written_data()

written_data() = logi_layout:formatted_data()

The data written to a sink

Function Index

get_module/1Gets the module of Writer
get_state/1Gets the state of Writer
get_writee/1Gets the writee process of log messages.
is_callback_module/1Returns true if X is a module which implements the writer behaviour, otherwise false
is_writer/1Returns true if X is a writer instance, otherwise false
new/2Creates a new writer instance.
write/4Writes a log message.

Function Details

get_module/1

get_module(Writer::writer()) -> callback_module()

Gets the module of Writer

get_state/1

get_state(Writer::writer()) -> state()

Gets the state of Writer

get_writee/1

get_writee(Writer::writer()) -> pid() | undefined

Gets the writee process of log messages

"writee" is the destination process of written_data() of write/4.

If such process is dead or unknown, the function returns undefined.

The result value might change on every call.

is_callback_module/1

is_callback_module(X::callback_module() | term()) -> boolean()

Returns true if X is a module which implements the writer behaviour, otherwise false

is_writer/1

is_writer(X::writer() | term()) -> boolean()

Returns true if X is a writer instance, otherwise false

new/2

new(Module::callback_module(), State::state()) -> writer()

Creates a new writer instance

write/4

write(Context::logi_context:context(), Format::io:format(), Data::logi_layout:data(), Writer::writer()) -> written_data()

Writes a log message

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


Generated by EDoc