Tip #1 - global parameter: log_prefix
It can be used to specify the text to be prefixed to each log message printed by Kamailio while processing the SIP message.
An immediate benefit could be for log messages added in kamailio.cfg via xlog module functions. If you want to match the log message with packets from a network trace, you have to print several details from SIP packet. For example, such list of details can be:
- sip message type
- source ip
- sequence number
- sip method type
In addition, the xlog message would have some extra text to describing its role.
With older versions, that was possible by listing those elements in each xlog, like:
xlog("$mt $si $cs $rm $ci - extra text one\n");
xlog("$mt $si $cs $rm $ci - extra text two\n");
With 4.2, it can be done like:
log_prefix="$mt $si $cs $rm $ci - "
xlog("extra text one\n");
xlog("extra text two\n");
An useful effect is that log messages printed from inside the C code will be prefixed as well. Many of the error messages in C code don't print any details of the SIP message processed at that moment, now you can overcome it without touching the C code.
As a bonus, remember that you can have different log level for core and each of loaded modules by using debugger module and setting the appropriate mod_level parameter, even in v4.1.x.
Post a Comment