xlog

Keywords: 2.0.x | Module | xlog

Standard-dep

This module provides the possibility to print user formatted log or debug messages from SERi scripts, similar to printf function but now a specifier is replaced with a part of the SIP request. the section called "Implemented Specifiers" shows what can be printed out.


Elena-Ramona Modroiu


Xlog Module

Elena-Ramona Modroiu

Voice Sistem
Revision History
Revision $Revision: 1.4 $ $Date: 2006/05/11 13:44:13 $

Overview

This module provides the possibility to print user formatted log or debug messages from SERi scripts, similar to printf function but now a specifier is replaced with a part of the SIP request. the section called “Implemented Specifiers” shows what can be printed out.

Implemented Specifiers

  • %% : '%'

  • %br : request's first branchi

  • %bR : request's all branches

  • %ci : call-id

  • %cs : cseq

  • %ct : contact header

  • %Cxy : color printing based on escape sequences (x - foreground color, y - background color). The values for colors: x - default color of the terminal; s - Black; r - Red; g - Green; y - Yellow; b - Blue; p - Purple; c - Cyan; w - White

  • %ds : destination set

  • %fu : 'From' uri

  • %ft : 'From' tagi

  • %Hn : host's hostname (if system hostname is FQDN, part before first .)

  • %Hd : host's domain (if system hosntame is FQDN, part behind first .)

  • %Hf : host's FQDN hostname

  • %Hi : host's IP address

  • %mb : whole SIP message buffer

  • %mf : flags set for current SIP request

  • %mi : SIP message id

  • %ml : SIP message length

  • %mx : SIP message id (in hex notation)

  • %nh : message's next hop

  • %pp : process id (pid)

  • %px : process id (pid) (in hex notation)

  • %rm : request's method

  • %ru : request's r-uri

  • %rr : reply's reason

  • %rs : reply's status

  • %rt : 'Refer-To' uri

  • %Ri : IP address of the interface where the request has been received

  • %Rp : received port

  • %si : IP source address

  • %sp : source port

  • %tu : 'To' uri

  • %tt : 'To' tag

  • %Ts : unix time stamp

  • %Tf : string formatted time

  • %Tx : unix time stamp (in hex notation)

  • %ua : User agent header field

  • %uq : unique id (per SER's process) - to make really unique id use %uq-%px-%mx or %uq-%px-%Tx

  • %{name[N]} : print the body of the Nth header identified by 'name'. If [N] is omitted then the body of the first header is printed. The first header is got when N=0, for the second N=1, a.s.o. To print the last header of that type, use -1, no other negative values are supported now. No white spaces are allowed inside the specifier (before }, before or after {, [, ] symbols). When N='*', all headers of that type are printed.

    The module should identify most of compact header names (the ones recognized by seri which should be all at this moment), if not, the compact form has to be specified explicitely. It is recommended to use dedicated specifiers for headers (e.g., %ua for user agent header), if they are available -- they are faster.

  • %<name[N]> : print the value of AVP optionally %indexed by the [N] value It uses AVPs subindexing, e.g. if you don't specify subindex and there are more AVPs with the same name, the result is NULL. To specify first AVP use [1], negative values are indexes counted backward through the list.

  • %@select.framework[N].value : print the value of select framework call. For detailed info what calls are available see select framework documentation (and modules documentation, as modules can extend select framework calls).

  • %| or %(space) : end of %@select.framework identifier. If you need to concatenate select framework call and another non-whitespace literal, you need to explicitelly set the end of the select framework identifier.

    E.g. %@ruri.user%|@%@ruri.host converts all featured request uri into user@host form only.

Parameters

Revision History
Revision $Revision: 1.2 $ $Date: 2005/08/24 13:24:35 $

buf_size (integer)

Maximum size of the log message.

Default value is 4096.

Example� 1.� Set buf_size parameter

...
modparam("xlog", "buf_size", 8192)
...

Functions

Revision History
Revision $Revision: 1.3 $ $Date: 2005/08/24 22:26:21 $

xlog(level, format)

Print a formated message using LOG function.

Meaning of the parameters is as follows:

  • level - The level that will be used in LOG function. It can be:

    • L_ALERT

    • L_CRIT

    • L_ERR

    • L_WARN

    • L_NOTICE

    • L_INFO

    • L_DBG

    What really matters is the third letter of the value.

  • format - The formatted string to be printed.

Example� 2.� xlog usage

...
xlog("L_ERR", "time [%Tf] method <%rm> r-uri <%ru> 2nd via <%{via[1]}>\n");
...

xdbg(format)

Print a formatted message using DBG function.

Meaning of the parameters is as follows:

  • format - The formatted string to be printed.

Example� 3.� xdbg usage

...
xdbg("time [%Tf] method <%rm> r-uri <%ru>\n");
...