20 #define UCX_LOGGER_TIMESTAMP 0x02 |
20 #define UCX_LOGGER_TIMESTAMP 0x02 |
21 #define UCX_LOGGER_SOURCE 0x04 |
21 #define UCX_LOGGER_SOURCE 0x04 |
22 |
22 |
23 typedef struct { |
23 typedef struct { |
24 FILE *stream; |
24 FILE *stream; |
25 size_t(*writer)(const void*, size_t, size_t, FILE*); |
25 write_func writer; |
|
26 char *dateformat; |
26 unsigned int level; |
27 unsigned int level; |
27 unsigned int mask; |
28 unsigned int mask; |
28 UcxMap* levels; |
29 UcxMap* levels; |
29 } UcxLogger; |
30 } UcxLogger; |
30 |
31 |
31 UcxLogger *ucx_logger_new(FILE *stream, unsigned int level, unsigned int mask); |
32 UcxLogger *ucx_logger_new(FILE *stream, unsigned int level, unsigned int mask); |
32 void ucx_logger_free(UcxLogger* logger); |
33 void ucx_logger_free(UcxLogger* logger); |
33 |
|
34 /** |
|
35 * Sets the output stream and writer for this logger. |
|
36 * The parameters stream and writer may be NULL, if they shall remain unchanged |
|
37 * in the logger. |
|
38 * l |
|
39 * @param logger The logger |
|
40 * @param stream The stream the logger shall log to |
|
41 * @param writer A pointer to the write function |
|
42 */ |
|
43 void ucx_logger_setoutput(UcxLogger *logger, FILE *stream, |
|
44 size_t(*writer)(const void*,size_t,size_t,FILE*)); |
|
45 |
34 |
46 void ucx_logger_logf(UcxLogger *logger, unsigned int level, const char* file, |
35 void ucx_logger_logf(UcxLogger *logger, unsigned int level, const char* file, |
47 const unsigned int line, const char* format, ...); |
36 const unsigned int line, const char* format, ...); |
48 #define ucx_logger_log(logger, level, format...) \ |
37 #define ucx_logger_log(logger, level, format...) \ |
49 ucx_logger_logf(logger, level, __FILE__, __LINE__, format) |
38 ucx_logger_logf(logger, level, __FILE__, __LINE__, format) |