xlog Module

Elena-Ramona Modroiu

Edited by

Elena-Ramona Modroiu


Table of Contents
1. User's Guide
1.1. Overview
1.2. Implemented Specifiers
1.3. Dependencies
1.3.1. OpenSER Modules
1.3.2. External Libraries or Applications
1.4. Exported Parameters
1.4.1. buf_size (integer)
1.4.2. force_color (integer)
1.5. Exported Functions
1.5.1. xlog([level,] format)
1.5.2. xdbg(format)
2. Developer's Guide
3. Frequently Asked Questions
List of Examples
1-1. Set buf_size parameter
1-2. Set force_color parameter
1-3. xlog usage
1-4. xdbg usage

Chapter 1. User's Guide

1.1. Overview

This module provides the possibility to print user formatted log or debug messages from OpenSER scripts, similar to printf function but now a specifier is replaced with a part of the SIP request or other variables from system. Section 1.2 shows what can be printed out.


1.2. Implemented Specifiers

The specifiers have been replaced by pseudo-variables which are now part of OpenSER core and are used by other modules as well (e.g., avpops in the function avp_printf())

The most important changes are:

  • - '%' has been replaced by '$'

  • - to print a header, use now $hdr(header_name[index]) instead of %{header_name[index]}

  • - to print an AVP, use now $avp([si]:avp_id[index]) instead of %{[si]:avp_id[index]} or $avp([$avp_alias[index]) instead of %{[$avp_alias[index]}

The full list of available pseudo-variables in OpenSER is availabe at: http://openser.org/docs/pseudo-variables.html


1.3. Dependencies

1.3.1. OpenSER Modules

The following modules must be loaded before this module:

  • No dependencies on other OpenSER modules.


1.3.2. External Libraries or Applications

The following libraries or applications must be installed before running OpenSER with this module loaded:

  • None.


1.4. Exported Parameters

1.4.1. buf_size (integer)

Maximum size of the log message.

Default value is 4096.

Example 1-1. Set buf_size parameter

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

1.4.2. force_color (integer)

When set to 1, forces color printing even if log_stderror=0.

Default value is 0.

Example 1-2. Set force_color parameter

...
modparam("xlog", "force_color", 0)
...

1.5. Exported Functions

1.5.1. 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.

    If this parameter is missing, the implicit log level is 'L_ERR'.

  • format - The formatted string to be printed.

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, ONREPLY_ROUTE, BRANCH_ROUTE.

Example 1-3. xlog usage

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

1.5.2. xdbg(format)

Print a formatted message using DBG function.

Meaning of the parameters is as follows:

  • format - The formatted string to be printed.

This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, ONREPLY_ROUTE, BRANCH_ROUTE.

Example 1-4. xdbg usage

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

Chapter 2. Developer's Guide

The module does not provide any API to use in other OpenSER modules.


Chapter 3. Frequently Asked Questions

3.1. Where can I find more about OpenSER?
3.2. Where can I post a question about this module?
3.3. How can I report a bug?

3.1. Where can I find more about OpenSER?

Take a look at http://openser.org/.

3.2. Where can I post a question about this module?

First at all check if your question was already answered on one of our mailing lists:

E-mails regarding any stable OpenSER release should be sent to and e-mails regarding development versions should be sent to .

If you want to keep the mail private, send it to .

3.3. How can I report a bug?

Please follow the guidelines provided at: http://openser.org/bugs.