Argus PEP client API  2.3
Macros | Typedefs
Log Level and Output

Sets PEP client log levels and log output. More...

Macros

#define PEP_LOGLEVEL_DEBUG   3
 Logs ERROR, WARN, INFO and DEBUG messages.
#define PEP_LOGLEVEL_ERROR   0
 Logs only ERROR messages.
#define PEP_LOGLEVEL_INFO   2
 Logs ERROR, WARN and INFO messages.
#define PEP_LOGLEVEL_NONE   -1
 No logging at all.
#define PEP_LOGLEVEL_WARN   1
 Logs ERROR and WARN messages.

Typedefs

typedef int pep_log_handler_callback (int level, const char *format, va_list args)
 Optional log handler function callback prototype.

Detailed Description

Sets PEP client log levels and log output.

By default the log level is PEP_LOGLEVEL_NONE and the log output is NULL, therefore, the PEP client doesn't log anything.

See Error Reporting for example how to handle error in your code.

Example to debug in a log file:

...
// set log output to mylogfile
rc= pep_setoption(pep,PEP_OPTION_LOG_STDERR, my_logfile);
if (rc != PEP_OK) {
fprintf(stderr,"ERROR: %s\n",pep_strerror(rc));
}
// set log level to DEBUG
if (rc != PEP_OK) {
fprintf(stderr,"ERROR: %s\n",pep_strerror(rc));
}
...

Macro Definition Documentation

#define PEP_LOGLEVEL_DEBUG   3

Logs ERROR, WARN, INFO and DEBUG messages.

Examples:
pep_client_example.c.
#define PEP_LOGLEVEL_ERROR   0

Logs only ERROR messages.

#define PEP_LOGLEVEL_INFO   2

Logs ERROR, WARN and INFO messages.

#define PEP_LOGLEVEL_NONE   -1

No logging at all.

#define PEP_LOGLEVEL_WARN   1

Logs ERROR and WARN messages.

Typedef Documentation

typedef int pep_log_handler_callback(int level, const char *format, va_list args)

Optional log handler function callback prototype.

You can implement your own callback function to replace the default log handler. The PEP log message are not terminated with a "\n".

Parameters
levelThe log level to log
formatThe format string
argsThe variable arguments list
Returns
int 0 or an error code.

Example to use your own logging callback function:

...
// functions to log messages to my log file
int my_vlog(int level, const char *fmt, va_list args) {
if (level >= my_log_level) {
vfprintf(my_logfile,fmt,args);
}
return 0;
}
int my_log_error(const char *fmt, ...) {
va_list args;
va_start(args,fmt);
int rc= my_vlog(MY_LOG_ERROR,fmt,args);
va_end(args);
return rc;
}
...
// set my log function as log handler callback function
if (rc != PEP_OK) {
my_log_error("pep_setoption(PEP_OPTION_LOG_HANDLER,...) failed: %s\n",pep_strerror(rc));
}
...
See Also
pep_setoption(pep,pep_option_t option,...)
pep_log_handler_callback function prototype