logi_ex v0.1.1 Logi.BuiltIn.Sink.Fun

A built-in sink which consumes log messages by an arbitrary user defined function.

Behaviours: Logi.SinkWriter

The default layout is Logi.BuiltIn.Layout.Default.new().

Note

This module is provided for debuging/testing purposes only.

A sink is stored into a logi_channel’s ETS. Then it will be loaded every time a log message is issued. Therefore if the write function (write_fun/0) of the sink is a huge size anonymous function, all log issuers which use the channel will have to pay a non negligible cost to load it.

And there is no overload protection.

Examples

iex> write_fun = fn (_, format, data) -> :io.format("[CONSUMED] " <> format <> "\n", data) end
iex> {:ok, _} = Logi.Channel.install_sink Logi.BuiltIn.Sink.Fun.new(:foo, write_fun), :info

iex> require Logi
iex> Logi.info "hello world"
#OUTPUT# [CONSUMED] hello world

Summary

Types

A function which is used to consume log messages issued by logi

Functions

Creats a new sink instance

Types

write_fun()

A function which is used to consume log messages issued by logi.

Functions

new(sink_id, fun)

Creats a new sink instance.