When trying to debug the configuration file of OpenSER might turn out that the amount of debug messages printed is very large and it is hard to spot the lines printed by xlog()/xdbg().
The debug level is controlled by ‘debug’ global parameter. A higher value make the number of printed message to increase.
debug=7
debug=3 is the usual value for live environments. debug=0 will suppress any debug message but errors or reporting critical situations. So, to debug the script, the value of ‘debug’ parameter should be higher than 3 (7 ensures that everything is printed out).
To be able to spot certain debug messages, the xlog module gives the functionality of printing colourful messages, via escape sequences. Any Unix standard terminal will be able to interpret and display messages highlighted.
$Cxy – reference to an escape sequence. “x” represents the foreground color and “y” represents the background color.
Colours could be:
- x : default color of the terminal
- s : Black
- r : Red
- g : Green
- y : Yellow
- b : Blue
- p : Purple
- c : Cyan
- w : White
Once an escape sequence is printed, next text will be displayed using those foreground and background colors until meeting another escape sequence. It is better to reset it, after the text wanted to be highlighted, via $Cxx, so the terminal gets back to default properties.
Example:
xdbg("$(Cbg)blue on green$(Cxx) default colors $(Cbr)blue on red(Cxx)\n");
# print From URI in red
xdbg("From URI: $(Crx)$fu(Cxx)\n");