|
HOME
SIP/media Features
High Performance SIP
Small Footprint SIP
Symbian Port
FAQ
Documentation
Licensing
Download
Development (Trac)
Projects using pjsip
Mailing List
Open Source Links
About: PJLIB, PJLIB-UTIL, PJSIP, and PJMEDIA are created by: Benny Prijono <bennylp pjsip.org>
|
|
Home --> Documentations --> PJLIB Reference
Detailed Description
The PJLIB logging facility is a configurable, flexible, and convenient way to write logging or trace information.
To write to the log, one uses construct like below:
...
PJ_LOG(3, ("main.c", "Starting hello..."));
...
PJ_LOG(3, ("main.c", "Hello world from process %d", pj_getpid()));
...
In the above example, the number 3 controls the verbosity level of the information (which means "information", by convention). The string "main.c" specifies the source or sender of the message.
For examples, see:
|
Defines |
| #define | PJ_LOG(level, arg) |
Typedefs |
| typedef void | pj_log_func (int level, const char *data, int len) |
Enumerations |
| enum | pj_log_decoration {
PJ_LOG_HAS_DAY_NAME = 1,
PJ_LOG_HAS_YEAR = 2,
PJ_LOG_HAS_MONTH = 4,
PJ_LOG_HAS_DAY_OF_MON = 8,
PJ_LOG_HAS_TIME = 16,
PJ_LOG_HAS_MICRO_SEC = 32,
PJ_LOG_HAS_SENDER = 64,
PJ_LOG_HAS_NEWLINE = 128,
PJ_LOG_HAS_CR = 256
} |
Functions |
| void | pj_log_write (int level, const char *buffer, int len) |
| void | pj_log (const char *sender, int level, const char *format, va_list marker) |
| void | pj_log_set_log_func (pj_log_func *func) |
| pj_log_func * | pj_log_get_log_func (void) |
| void | pj_log_set_level (int level) |
| int | pj_log_get_level (void) |
| void | pj_log_set_decor (unsigned decor) |
| unsigned | pj_log_get_decor (void) |
Define Documentation
| #define PJ_LOG |
( |
level, |
|
|
arg |
|
) |
|
Write log message. This is the main macro used to write text to the logging backend.
- Parameters:
-
| level | The logging verbosity level. Lower number indicates higher importance, with level zero indicates fatal error. Only numeral argument is permitted (e.g. not variable). |
| arg | Enclosed 'printf' like arguments, with the first argument is the sender, the second argument is format string and the following arguments are variable number of arguments suitable for the format string. |
Sample:
PJ_LOG(2, (__FILE__, "current value is %d", value));
Typedef Documentation
| typedef void pj_log_func(int level, const char *data, int len) |
Signature for function to be registered to the logging subsystem to write the actual log message to some output device.
- Parameters:
-
| level | Log level. |
| data | Log message, which will be NULL terminated. |
| len | Message length. |
Enumeration Type Documentation
Log decoration flag, to be specified with pj_log_set_decor(). - Enumerator:
-
| PJ_LOG_HAS_DAY_NAME |
Include day name [default: no]. |
| PJ_LOG_HAS_YEAR |
Include year digit [default: no] |
| PJ_LOG_HAS_MONTH |
Include month [default: no] |
| PJ_LOG_HAS_DAY_OF_MON |
Include day of month [default: no] |
| PJ_LOG_HAS_TIME |
Include time [default: yes]. |
| PJ_LOG_HAS_MICRO_SEC |
Include microseconds [yes] |
| PJ_LOG_HAS_SENDER |
Include sender in the log [yes]. |
| PJ_LOG_HAS_NEWLINE |
Terminate each call with newline [yes]. |
| PJ_LOG_HAS_CR |
Include carriage return [no]. |
Function Documentation
| void pj_log |
( |
const char * |
sender, |
|
|
int |
level, |
|
|
const char * |
format, |
|
|
va_list |
marker | |
|
) |
| | |
Write to log.
- Parameters:
-
| sender | Source of the message. |
| level | Verbosity level. |
| format | Format. |
| marker | Marker. |
| unsigned pj_log_get_decor |
( |
void |
|
) |
|
Get current log decoration flag.
- Returns:
- Log decoration flag.
| int pj_log_get_level |
( |
void |
|
) |
|
Get current maximum log verbositylevel.
- Returns:
- Current log maximum level.
Get the current log output function that is used to write log messages.
- Returns:
- Current log output function.
| void pj_log_set_decor |
( |
unsigned |
decor |
) |
|
Set log decoration. The log decoration flag controls what are printed to output device alongside the actual message. For example, application can specify that date/time information should be displayed with each log message.
- Parameters:
-
| decor | Bitmask combination of pj_log_decoration to control the layout of the log message. |
| void pj_log_set_level |
( |
int |
level |
) |
|
Set maximum log level. Application can call this function to set the desired level of verbosity of the logging messages. The bigger the value, the more verbose the logging messages will be printed. However, the maximum level of verbosity can not exceed compile time value of PJ_LOG_MAX_LEVEL.
- Parameters:
-
| level | The maximum level of verbosity of the logging messages (6=very detailed..1=error only, 0=disabled) |
Change log output function. The front-end logging functions will call this function to write the actual message to the desired device. By default, the front-end functions use pj_log_write() to write the messages, unless it's changed by calling this function.
- Parameters:
-
| func | The function that will be called to write the log messages to the desired device. |
| void pj_log_write |
( |
int |
level, |
|
|
const char * |
buffer, |
|
|
int |
len | |
|
) |
| | |
Default logging writer function used by front end logger function. This function will print the log message to stdout only. Application normally should NOT need to call this function, but rather use the PJ_LOG macro.
- Parameters:
-
| level | Log level. |
| buffer | Log message. |
| len | Message length. |
PJLIB Open Source, high performance, small footprint, and very very portable framework
(C)2001-2008 Benny Prijono
|
|