Fri, 08 Feb 2013 17:09:12 +0100
modified code to compile with -pedantic
1 #ifndef LOGGING_H
2 #define LOGGING_H
4 #include "ucx.h"
5 #include "map.h"
6 #include "string.h"
7 #include <stdio.h>
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
13 /* leave enough space for custom log levels */
14 #define UCX_LOGGER_ERROR 0x00
15 #define UCX_LOGGER_WARN 0x10
16 #define UCX_LOGGER_INFO 0x20
17 #define UCX_LOGGER_TRACE 0x30
19 #define UCX_LOGGER_LEVEL 0x01
20 #define UCX_LOGGER_TIMESTAMP 0x02
21 #define UCX_LOGGER_SOURCE 0x04
23 typedef struct {
24 void *stream;
25 write_func writer;
26 char *dateformat;
27 unsigned int level;
28 unsigned int mask;
29 UcxMap* levels;
30 } UcxLogger;
32 UcxLogger *ucx_logger_new(void *stream, unsigned int level, unsigned int mask);
33 void ucx_logger_free(UcxLogger* logger);
35 void ucx_logger_logf(UcxLogger *logger, unsigned int level, const char* file,
36 const unsigned int line, const char* format, ...);
37 #define ucx_logger_log(logger, level, ...) \
38 ucx_logger_logf(logger, level, __FILE__, __LINE__, __VA_ARGS__)
39 #define ucx_logger_error(logger, ...) \
40 ucx_logger_log(logger, UCX_LOGGER_ERROR, __VA_ARGS__)
41 #define ucx_logger_info(logger, ...) \
42 ucx_logger_log(logger, UCX_LOGGER_INFO, __VA_ARGS__)
43 #define ucx_logger_warn(logger, ...) \
44 ucx_logger_log(logger, UCX_LOGGER_WARN, __VA_ARGS__)
45 #define ucx_logger_trace(logger, ...) \
46 ucx_logger_log(logger, UCX_LOGGER_TRACE, __VA_ARGS__)
48 #ifdef __cplusplus
49 }
50 #endif
52 #endif /* LOGGING_H */