7 UcxLogger *ucx_logger_new(void *stream, unsigned int level, unsigned int mask) { |
7 UcxLogger *ucx_logger_new(void *stream, unsigned int level, unsigned int mask) { |
8 UcxLogger *logger = (UcxLogger*) malloc(sizeof(UcxLogger)); |
8 UcxLogger *logger = (UcxLogger*) malloc(sizeof(UcxLogger)); |
9 if (logger != NULL) { |
9 if (logger != NULL) { |
10 logger->stream = stream; |
10 logger->stream = stream; |
11 logger->writer = (write_func)fwrite; |
11 logger->writer = (write_func)fwrite; |
12 logger->dateformat = "%F %T %z "; |
12 logger->dateformat = (char*) "%F %T %z "; |
13 logger->level = level; |
13 logger->level = level; |
14 logger->mask = mask; |
14 logger->mask = mask; |
15 logger->levels = ucx_map_new(8); |
15 logger->levels = ucx_map_new(8); |
16 |
16 |
17 unsigned int l; |
17 unsigned int l; |
18 l = UCX_LOGGER_ERROR; |
18 l = UCX_LOGGER_ERROR; |
19 ucx_map_int_put(logger->levels, l, "[ERROR]"); |
19 ucx_map_int_put(logger->levels, l, (void*) "[ERROR]"); |
20 l = UCX_LOGGER_WARN; |
20 l = UCX_LOGGER_WARN; |
21 ucx_map_int_put(logger->levels, l, "[WARNING]"); |
21 ucx_map_int_put(logger->levels, l, (void*) "[WARNING]"); |
22 l = UCX_LOGGER_INFO; |
22 l = UCX_LOGGER_INFO; |
23 ucx_map_int_put(logger->levels, l, "[INFO]"); |
23 ucx_map_int_put(logger->levels, l, (void*) "[INFO]"); |
24 l = UCX_LOGGER_TRACE; |
24 l = UCX_LOGGER_TRACE; |
25 ucx_map_int_put(logger->levels, l, "[TRACE]"); |
25 ucx_map_int_put(logger->levels, l, (void*) "[TRACE]"); |
26 } |
26 } |
27 |
27 |
28 return logger; |
28 return logger; |
29 } |
29 } |
30 |
30 |