log_mf_h — stdlib v6.0

Search documentation of stdlib

# View Source log_mf_h (stdlib v6.0)

An event handler that logs events to disk.

This module is a `gen_event` handler module that can be installed in any `gen_event` process. It logs onto disk all events that are sent to an event manager. Each event is written as a binary, which makes the logging very fast. However, a tool such as the Report Browser (`rb`) must be used to read the files. The events are written to multiple files. When all files have been used, the first one is reused and overwritten. The directory location, the number of files, and the size of each file are configurable. The directory will include one file called `index`, and report files `1, 2, ...`.

## See Also

`gen_event`, `rb`

# Summary

## Types

args()

Term to be sent to `gen_event:add_handler/3`.

b()
f()
pred()

## Functions

init(Dir, MaxBytes, MaxFiles)

Equivalent to `init(Dir, MaxBytes, MaxFiles, fun(_) -> true end)`.

init(Dir, MaxBytes, MaxFiles, Pred)

Initiates the event handler. Returns `Args`, which is to be used in a call to `gen_event:add_handler(EventMgr, log_mf_h, Args)`.

# Types

Link to this opaque

# args()

View Source

    -opaque args()

Term to be sent to `gen_event:add_handler/3`.

Link to this type

# b()

View Source (not exported)

    -type b() :: non_neg_integer().

Link to this type

# f()

View Source (not exported)

    -type f() :: 1..255.

Link to this type

# pred()

View Source (not exported)

    -type pred() :: fun((term()) -> boolean()).

# Functions

Link to this function

# init(Dir, MaxBytes, MaxFiles)

View Source

    -spec init(Dir, MaxBytes, MaxFiles) -> Args
                  when
                      Dir :: file:filename(),
                      MaxBytes :: non_neg_integer(),
                      MaxFiles :: 1..255,
                      Args :: args().

Equivalent to `init(Dir, MaxBytes, MaxFiles, fun(_) -> true end)`.

Link to this function

# init(Dir, MaxBytes, MaxFiles, Pred)

View Source

    -spec init(Dir, MaxBytes, MaxFiles, Pred) -> Args
                  when
                      Dir :: file:filename(),
                      MaxBytes :: non_neg_integer(),
                      MaxFiles :: 1..255,
                      Pred :: fun((Event :: term()) -> boolean()),
                      Args :: args().

Initiates the event handler. Returns `Args`, which is to be used in a call to `gen_event:add_handler(EventMgr, log_mf_h, Args)`.

`Dir` specifies which directory to use for the log files. `MaxBytes` specifies the size of each individual file. `MaxFiles` specifies how many files are used. `Pred` is a predicate function used to filter the events. If no predicate function is specified, all events are logged.