Module logi_builtin_sink_fun

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

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

Behaviours: logi_sink_writer.

Description

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

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.

EXAMPLE

  > error_logger:tty(false). % Suppresses annoying warning outputs for brevity
 
  > WriteFun = fun (_, Format, Data) -> io:format("[CONSUMED] " ++ Format ++ "\n", Data) end.
  > {ok, _} = logi_channel:install_sink(logi_builtin_sink_fun:new(foo, WriteFun), info).
  > logi:info("hello world").
  [CONSUMED] hello world
  

Data Types

write_fun()

write_fun() = fun((logi_context:context(), io:format(), logi_layout:data()) -> logi_sink_writer:written_data())

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

Function Index

new/2Creats a new sink instance.

Function Details

new/2

new(Id::logi_sink:id(), Fun::write_fun()) -> logi_sink:sink()

Creats a new sink instance


Generated by EDoc