|
1 #ifndef LOGGING_H |
|
2 #define LOGGING_H |
|
3 |
|
4 #include "ucx.h" |
|
5 #include "string.h" |
|
6 #include <stdio.h> |
|
7 |
|
8 #ifdef __cplusplus |
|
9 extern "C" { |
|
10 #endif |
|
11 |
|
12 /* leave enough space for custom log levels */ |
|
13 #define UCX_LOGGER_ERROR 0x00 |
|
14 #define UCX_LOGGER_WARN 0x10 |
|
15 #define UCX_LOGGER_INFO 0x20 |
|
16 #define UCX_LOGGER_TRACE 0x30 |
|
17 |
|
18 typedef struct { |
|
19 FILE *stream; |
|
20 unsigned int level; |
|
21 } UcxLogger; |
|
22 |
|
23 UcxLogger *ucx_logger_new(FILE *stream, unsigned int level); |
|
24 /* neither provide a free function nor a parameter for an allocator */ |
|
25 |
|
26 void ucx_logger_log(UcxLogger *logger, unsigned int level, |
|
27 const sstr_t message); |
|
28 #define ucx_logger_error(l,m) ucx_logger_log(l, UCX_LOGGER_ERROR, m) |
|
29 #define ucx_logger_info(l,m) ucx_logger_log(l, UCX_LOGGER_INFO, m) |
|
30 #define ucx_logger_warn(l,m) ucx_logger_log(l, UCX_LOGGER_WARN, m) |
|
31 #define ucx_logger_trace(l,m) ucx_logger_log(l, UCX_LOGGER_TRACE, m) |
|
32 |
|
33 #ifdef __cplusplus |
|
34 } |
|
35 #endif |
|
36 |
|
37 #endif /* LOGGING_H */ |