Module logi_builtin_sink_io_device

A built-in IO device sink.

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

Behaviours: logi_sink_writer.

Description

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

NOTE

This module is provided for debugging/testing purposes only. (e.g. Overload protection is missing)

EXAMPLE

The default IO device is 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
  

Function Index

new/1Equivalent to new(Id, []).
new/2Creates a new sink instance.

Function Details

new/1

new(Id::logi_sink:id()) -> logi_sink:sink()

Equivalent to new(Id, []).

new/2

new(Id::logi_sink:id(), Options) -> logi_sink:sink()

Creates a new sink instance

DEFAULT VALUE

- io_device: standard_io - layout: logi_builtin_layout_default:new()


Generated by EDoc