<div>thanks but it also doesn't support log filtering.</div>
<div>Here is the explanation of filtering from python manual.</div>
<div>"</div>
<div>
<p><tt class="class">Filter</tt>s can be used by <tt class="class">Handler</tt>s and <tt class="class">Logger</tt>s 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 href="http://A.BB">A.BB</a>", "B.A.B" etc. If initialized with the empty string, all events are passed.
<p>
<dl>
<dt>
<table cellspacing="0" cellpadding="0">
<tbody>
<tr valign="baseline">
<td><b><span class="typelabel">class</span> <tt class="class" id="l2h-2560">Filter</tt></b>(</td>
<td><var></var><big>[</big><var>name</var><big>]</big><var></var>)</td></tr></tbody></table>
<dd>Returns an instance of the <tt class="class">Filter</tt> class. If <var>name</var> is 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. </dd>
</dt></dl>
<p>
<dl>
<dt>
<table cellspacing="0" cellpadding="0">
<tbody>
<tr valign="baseline">
<td><b><tt class="method" id="l2h-2561">filter</tt></b>(</td>
<td><var>record</var>)</td></tr></tbody></table>
<dd>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. </dd></dt></dl></p></p></p></div>
<div>"</div>
<div> I think I need write one by myself.</div>
<div>Thank you .<br><br> </div>
<div><span class="gmail_quote">2008/6/12, Ulf Wiger (TN/EAB) <<a href="mailto:ulf.wiger@ericsson.com">ulf.wiger@ericsson.com</a>>:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">devdoer bird skrev:<span class="q"><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Thanks.<br>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 )<br>
What I need is more like log4cpp or python's logging module.<br> And I've stolen some logging code from couchdb and ejabbered ,but they only support critical level setting .<br> Is any other logging package you guys know?<br>
</blockquote><br></span>You can take a look at how mnesia does it.<br>Basically, it's this code in mnesia_lib.erl.<br><br>BR,<br>Ulf W<br><br><br>report_system_event({'EXIT', Reason}, Event) -><br> Mod = mnesia_monitor:get_env(event_module),<br>
case mnesia_sup:start_event() of<br> {ok, Pid} -><br> link(Pid),<br> gen_event:call(mnesia_event, Mod, Event, infinity),<br> unlink(Pid),<br><br> %% We get an exit signal if server dies<br>
receive<br> {'EXIT', Pid, _Reason} -><br> {error, {node_not_running, node()}}<br> after 0 -><br> gen_event:stop(mnesia_event),<br> ok<br>
end;<br><br> Error -><br> Msg = "Mnesia(~p): Cannot report event ~p: ~p (~p)~n",<br> error_logger:format(Msg, [node(), Event, Reason, Error])<br> end;<br>report_system_event(_Res, _Event) -><br>
ignore.<br><br>%% important messages are reported regardless of debug level<br>important(Format, Args) -><br> save({Format, Args}),<br> report_system_event({mnesia_info, Format, Args}).<br><br>%% Warning messages are reported regardless of debug level<br>
warning(Format, Args) -><br> save({Format, Args}),<br> report_system_event({mnesia_warning, Format, Args}).<br><br>%% error messages are reported regardless of debug level<br>error(Format, Args) -><br> save({Format, Args}),<br>
report_system_event({mnesia_error, Format, Args}).<br><br>%% verbose messages are reported if debug level == debug or verbose<br>verbose(Format, Args) -><br> case mnesia_monitor:get_env(debug) of<br> none -> save({Format, Args});<br>
verbose -> important(Format, Args);<br> debug -> important(Format, Args);<br> trace -> important(Format, Args)<br> end.<br><br>%% debug message are display if debug level == 2<br>dbg_out(Format, Args) -><br>
case mnesia_monitor:get_env(debug) of<br> none -> ignore;<br> verbose -> save({Format, Args});<br> _ -> report_system_event({mnesia_info, Format, Args})<br> end.<br></blockquote></div><br>