Module logi_sink_file

A sink which writes log messages to a file.

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

Description

A sink which writes log messages to a file

NOTE

The sink has no overload protections, so it is recommended to use it together with (for example) logi_slink_flow_limiter in a production environment.

EXAMPLE

  > {ok, _} =  logi_sink_file:start_writer(sample_file_writer, <<"/tmp/sample.log">>).
  > {ok, _} = logi_channel:install_sink(debug, logi_sink_file:new(sample_file_writer)).
  > logi:info("hello world").
  > file:read_file("/tmp/sample.log").
  {ok,<<"2015-11-04 00:13:33.058 [info] nonode@nohost <0.98.0> erl_eval:do_apply:673 [] hello world\n">>}
  

Data Types

filepath()

filepath() = binary()

A log file path

open_options()

open_options() = list()

Log file open options

See [file:mode/0](http://www.erlang.org/doc/man/file.html#type-mode) for more details

option()

option() = {layout, logi_layout:layout()} | {logger, logi:logger()} | {rotator, logi_sink_file_rotator:rotator()} | {open_opt, open_options()}

layout: - The layout instance used by the sink - Default: logi_sink_file:default_layout()

logger: - The logger instance which is used to report internal events of the sink process - Default: logi:default_logger()

rotator: - The rotator instance used by the sink - Default: logi_sink_file_rotator_noop:new()

open_opt: - Log file open options (i.e., the second argument of file:open/2) - Default: [append, raw, delayed_write]

options()

options() = [option()]

Function Index

default_layout/0Default layout.
new/2Equivalent to new(SinkId, FilePath, []).
new/3Creates a new sink.

Function Details

default_layout/0

default_layout() -> Layout::logi_layout:layout()

Default layout

Layout is logi_layout_newline:new(logi_layout_limit:new(logi_layout_default:new())).

new/2

new(SinkId::logi_sink:id(), FilePath::file:name_all()) -> logi_sink:sink()

Equivalent to new(SinkId, FilePath, []).

new/3

new(SinkId::logi_sink:id(), FilePath::file:name_all(), Options::options()) -> logi_sink:sink()

Creates a new sink


Generated by EDoc, Sep 27 2018, 23:13:24.