Sets PEP client log levels and log output. More...
Defines | |
#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. |
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 rc= pep_setoption(pep,PEP_OPTION_LOG_LEVEL, PEP_LOGLEVEL_DEBUG); if (rc != PEP_OK) { fprintf(stderr,"ERROR: %s\n",pep_strerror(rc)); } ...
#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.
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".
level | The log level to log | |
format | The format string | |
args | The variable arguments list |
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 rc= pep_setoption(pep,PEP_OPTION_LOG_HANDLER, (pep_log_handler_callback)my_vlog); if (rc != PEP_OK) { my_log_error("pep_setoption(PEP_OPTION_LOG_HANDLER,...) failed: %s\n",pep_strerror(rc)); } ...