Documentation

Log Handler

The Log Handler tells Nitrogen what to do with the wf:error, wf:warning, and wf:info messages. It does not currently affect how Erlang errors are handled. It only affects how error messages are handled when generated by the above function calls.

Behavior Functions

init(Config, State)

Initialize the handler

  • /Return Value/ - {ok, NewState}
finish(Config, State)

Clean up the handler

  • /Return Value/ - {ok, NewState}
info(Message, Config, State)

Generate an info message

  • Message - The string to generate the message

  • /Return Value/ - Description of the return value

warning(Message, Config, State)

Generate a warning message

  • Message - The string to generate the message

  • /Return Value/ - Description of the return value

error(Message, Config, State)

Generate an error message

  • Message - The string to generate the message

  • /Return Value/ - Description of the return value

Example

Here is the complete text of the default log handler in Nitrogen, which basically serves as a pass-through for the basic Erlang error_logger module.


-module (default_log_handler).
-behaviour (log_handler).
-export ([
    init/2,
    finish/2,
    info/3,
    warning/3,
    error/3
]).

init(_Config, State) ->
    {ok, State}.

finish(_Config, State) ->
    {ok, State}.

info(S, _Config, State) ->
    error_logger:info_msg([S, "\n"]),
    {ok, State}.

warning(S, _Config, State) ->
    error_logger:warning_msg([S, "\n"]),
    {ok, State}.

error(S, _Config, State) ->
    error_logger:error_msg([S, "\n"]),
    {ok, State}.

See Also



View Source or Submit Corrections for this Documentation Page
Copyright © 2008-2021 Nitrogen Web Framework. Released under the MIT License.