Log Handler

Home | Getting Started | API | Elements | Actions | Validators | Handlers | Configuration Options | Plugins | Mobile | Troubleshooting | About

Table of Contents

1 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 errorlogger 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}.

Date: 2013-10-03 13:41:13 CDT

Author: Jesse Gumm (@jessegumm)

Org version 7.8.02 with Emacs version 23

Validate XHTML 1.0

Comments

Note:To specify code blocks, just use the generic code block syntax:
<pre><code>your code here</code></pre>


comments powered by Disqus