Module logi_sink_file_rotator

The interface of file rotators.

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

This module defines the logi_sink_file_rotator behaviour.
Required callback functions: rotate/2, get_current_filepath/2, is_outdated/2.

Description

The interface of file rotators

Data Types

callback_module()

callback_module() = module()

A module that implements the logi_sink_file_rotator behaviour.

rotator()

abstract datatype: rotator()

A rotator instance

state()

state() = term()

The state of an instance of a logi_sink_file_rotator implementing module.

Function Index

get_current_filepath/2Gets the current output file path.
is_outdated/2Determines the given file path is outdated.
is_rotator/1Returns true if X is a rotator instance, false otherwise.
new/1Equivalent to new(Module, undefined).
new/2Creates a new rotator instance.
rotate/2Rotates Filepath

Function Details

get_current_filepath/2

get_current_filepath(BaseFilePath::logi_sink_file:filepath(), X2::rotator()) -> {ok, logi_sink_file:filepath(), rotator()} | {error, Reason::term()}

Gets the current output file path

is_outdated/2

is_outdated(FilePath::logi_sink_file:filepath(), X2::rotator()) -> {IsOutdated::boolean(), NextCheckTime::timeout(), rotator()}

Determines the given file path is outdated

If IsOutdated is false, the caller process invokes rotate/2 to rotate the old file. Then it will reopen a new file path which is the result of get_current_filepath/2.

The function will be re-invoked after NextCheckTime milliseconds.

is_rotator/1

is_rotator(X::rotator() | term()) -> boolean()

Returns true if X is a rotator instance, false otherwise

new/1

new(Module::callback_module()) -> rotator()

Equivalent to new(Module, undefined).

new/2

new(Module::callback_module(), State::state()) -> rotator()

Creates a new rotator instance

rotate/2

rotate(FilePath::logi_sink_file:filepath(), X2::rotator()) -> {ok, Rotated::logi_sink_file:filepath(), rotator()} | {error, Reason::term()}

Rotates Filepath

Rotated is new file path after the rotation. It may be the same as FilePath.

A implementation module may not physically rotate the file (e.g., leaves the old file as it is).


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