Files
libucore/test/logging.c
T
2012-11-08 23:33:17 +01:00

61 lines
1.4 KiB
C

#include "ucore_logging.h"
#include "ucore_utils.h"
#include <syslog.h>
enum {
MAIN,
CC,
HO
};
struct uc_log_module module_arr[] = {
{
MAIN,
"MAIN",
"Main module",
UC_LL_WARNING
},
{
CC,
"CC",
"Call Control module",
UC_LL_DEBUG,
},
{
HO,
"HO",
"Handover module",
UC_LL_DEBUG
}
};
struct uc_log_modules modules = {
.mods = module_arr,
.cnt = ARRAY_SIZE(module_arr),
};
int main(int argc, char *argv[])
{
struct uc_log_destination *dest = uc_log_new_stderr(UC_LL_INFO, 0);
uc_log_init(&modules);
uc_log_add_destination(dest);
dest = uc_log_new_file("test.log", UC_LL_INFO, 1);
uc_log_add_destination(dest);
dest = uc_log_new_syslog("log.test", LOG_DAEMON, UC_LL_INFO, 0);
uc_log_add_destination(dest);
UC_LOGF( UC_LL_INFO, CC, "Test cc info %d\n", 2);
UC_LOGF( UC_LL_WARNING, HO, "Test HO warning%d\n", 2);
UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN info \n" );
UC_LOGF( UC_LL_WARNING, MAIN, "Test MAIN warning\n" );
uc_log_module_set_loglevel(MAIN, UC_LL_INFO);
UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN INFO 2\n" );
UC_LOGFR(UC_LL_INFO, MAIN, "Test RAW logging 1\n" );
uc_log_module_set_loglevel(MAIN, UC_LL_WARNING);
UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN INFO 3\n" );
return 1;
}