[sr-dev] [tracker] Comment added: patch to add method masking to xlog function

sip-router admin at sip-router.org
Tue Jul 27 16:08:43 CEST 2010


THIS IS AN AUTOMATED MESSAGE, DO NOT REPLY.

The following task has a new comment added:

FS#81 - patch to add method masking to xlog function
User who did this - Daniel-Constantin Mierla (miconda)

----------
It affects all configs, maybe it does not require changes in config to get it, but there is impact on every xlog function.

Anyhow, back to subject, you can call existing functions from new function, so no copy of existing code -- by having an extra parameter, like flags (i.e., log level, flag, message), you can control everything. I don't think a search/replace is a big stopper for one that wants to enable such filtering in his config. Is what I do for cases where I want to print the cfg name and line -- there was added a new function called xlogl().

The case now is not only about method based filtering, this is really a particular case for your specific needs. Tomorrow someone else might come and say he wants to extend the filtering with other rules (source ip, time of the day, user, etc...). Furthermore, enabling it makes no option of printing messages -- say I want to print a message for each incoming request (e.g., tracing everything for security reasons) but then skip the rest of messages which can be just for troubleshooting.

I think there must be the basic function available, as it is since 2003, small wrappers around them harm less than making these functions too heavy.

And since we got in this discussion, there is a pretty nice solution already for your case:
- say $shv(request_filter) is the shared variable holding the methods mask
- use: xlog("$var(log)", "your message");
- at the top of your main route do:
if($shv(request_filter) & $rm)
   $var(log) = 0; # or your desired log level (see the readme of xlog)
else
   $var(log) = 100; # the message won't be printed by exceeding 'debug' value

So you are set, the all xlog functions using $var(log) as parameter will not print anything if the bitmask is matched.
----------

More information can be found at the following URL:
http://sip-router.org/tracker/index.php?do=details&task_id=81#comment103

You are receiving this message because you have requested it from the Flyspray bugtracking system.  If you did not expect this message or don't want to receive mails in future, you can change your notification settings at the URL shown above.



More information about the sr-dev mailing list