[erlang-questions] is there any logging module for erlang?

devdoer bird <>
Thu Jun 12 15:36:48 CEST 2008


thanks but it also doesn't support log filtering.
Here is the explanation of filtering from python manual.
"

Filters can be used by Handlers and Loggers for more sophisticated filtering
than is provided by levels. The base filter class only allows events which
are below a certain point in the logger hierarchy. For example, a filter
initialized with "A.B" will allow events logged by loggers "A.B", "A.B.C",
"A.B.C.D", "A.B.D" etc. but not "A.BB", "B.A.B" etc. If initialized with the
empty string, all events are passed.

   *class Filter*( [name]) Returns an instance of the Filter class. If
nameis specified, it names a logger which, together with its children,
will have
its events allowed through the filter. If no name is specified, allows every
event.

   *filter*( record) Is the specified record to be logged? Returns zero for
no, nonzero for yes. If deemed appropriate, the record may be modified
in-place by this method.
"
 I think I need write one by myself.
Thank you .


2008/6/12, Ulf Wiger (TN/EAB) <>:
>
> devdoer bird skrev:
>
>> Thanks.
>> I've seen the error logger,but I  need code something to make It support
>> ciritcal levelt setting(info/debug/warming/error)  and filterting(which can
>> define conditions control  whether one specific log record should be printed
>> )
>>  What I need is more like log4cpp or python's logging module.
>>  And I've stolen some logging code from couchdb and ejabbered ,but they
>> only support critical level setting .
>>  Is any other logging package you guys know?
>>
>
> You can take a look at how mnesia does it.
> Basically, it's this code in mnesia_lib.erl.
>
> BR,
> Ulf W
>
>
> report_system_event({'EXIT', Reason}, Event) ->
>    Mod = mnesia_monitor:get_env(event_module),
>    case mnesia_sup:start_event() of
>        {ok, Pid} ->
>            link(Pid),
>            gen_event:call(mnesia_event, Mod, Event, infinity),
>            unlink(Pid),
>
>            %% We get an exit signal if server dies
>            receive
>                {'EXIT', Pid, _Reason} ->
>                    {error, {node_not_running, node()}}
>            after 0 ->
>                    gen_event:stop(mnesia_event),
>                    ok
>            end;
>
>        Error ->
>            Msg = "Mnesia(~p): Cannot report event ~p: ~p (~p)~n",
>            error_logger:format(Msg, [node(), Event, Reason, Error])
>    end;
> report_system_event(_Res, _Event) ->
>    ignore.
>
> %% important messages are reported regardless of debug level
> important(Format, Args) ->
>    save({Format, Args}),
>    report_system_event({mnesia_info, Format, Args}).
>
> %% Warning messages are reported regardless of debug level
> warning(Format, Args) ->
>    save({Format, Args}),
>    report_system_event({mnesia_warning, Format, Args}).
>
> %% error messages are reported regardless of debug level
> error(Format, Args) ->
>    save({Format, Args}),
>    report_system_event({mnesia_error, Format, Args}).
>
> %% verbose messages are reported if debug level == debug or verbose
> verbose(Format, Args) ->
>    case mnesia_monitor:get_env(debug) of
>        none ->    save({Format, Args});
>        verbose -> important(Format, Args);
>        debug ->   important(Format, Args);
>        trace ->   important(Format, Args)
>    end.
>
> %% debug message are display if debug level == 2
> dbg_out(Format, Args) ->
>    case mnesia_monitor:get_env(debug) of
>        none ->    ignore;
>        verbose -> save({Format, Args});
>        _ ->  report_system_event({mnesia_info, Format, Args})
>    end.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080612/347148de/attachment.html>


More information about the erlang-questions mailing list