Copyright © 2014-2016 Takeru Ohta <phjgt308@gmail.com>
Behaviours: logi_sink_writer.
A built-in IO device sink
This sink writes log messages to an IO device (e.g. standard output, file, etc)
The default layout is logi_builtin_layout_default:new()
.
This module is provided for debugging/testing purposes only. (e.g. Overload protection is missing)
standard_io
:
> error_logger:tty(false). % Suppresses annoying warning outputs for brevity
> {ok, _} = logi_channel:install_sink(logi_builtin_sink_io_device:new(foo), info).
> logi:info("hello world").
2015-10-21 05:21:52.332 [info] nonode@nohost <0.91.0> erl_eval:do_apply:673 [] hello world
Outputs to a file:
> {ok, Fd} = file:open("/tmp/hoge", [write]).
> Sink = logi_builtin_sink_io_device:new(foo, [{io_device, Fd}]).
> {ok, _} = logi_channel:install_sink(Sink, info).
> logi:info("hello world").
> file:read_file("/tmp/hoge").
{ok,<<"2015-10-21 05:23:19.940 [info] nonode@nohost <0.91.0> erl_eval:do_apply:673 [] hello world\n">>}
Customizes message layout:
> Layout = logi_builtin_layout_fun:new(fun (_, Format, Data) -> io_lib:format("[my_layout] " ++ Format ++ "\n", Data) end).
> Sink = logi_builtin_sink_io_device:new(foo, [{layout, Layout}]).
> {ok, _} = logi_channel:install_sink(Sink, info).
> logi:info("hello world").
[my_layout] hello world
new/1 | Equivalent to new(Id, []). |
new/2 | Creates a new sink instance. |
new(Id::logi_sink:id()) -> logi_sink:sink()
Equivalent to new(Id, []).
new(Id::logi_sink:id(), Options) -> logi_sink:sink()
Creates a new sink instance
standard_io
- layout: logi_builtin_layout_default:new()
Generated by EDoc