ucx/logging.h

Wed, 06 Feb 2013 14:35:15 +0100

author
Mike Becker <universe@uap-core.de>
date
Wed, 06 Feb 2013 14:35:15 +0100
changeset 80
0125e4089f88
parent 69
fb59270b1de3
child 81
86a23238d8a1
permissions
-rw-r--r--

Fixed map tests + added some formatting options to logger

olaf@57 1 #ifndef LOGGING_H
olaf@57 2 #define LOGGING_H
olaf@57 3
universe@69 4 #include "ucx.h"
universe@80 5 #include "map.h"
olaf@57 6 #include "string.h"
olaf@57 7 #include <stdio.h>
olaf@57 8
olaf@57 9 #ifdef __cplusplus
olaf@57 10 extern "C" {
olaf@57 11 #endif
olaf@57 12
olaf@57 13 /* leave enough space for custom log levels */
universe@80 14 #define UCX_LOGGER_ERROR 0x00
universe@80 15 #define UCX_LOGGER_WARN 0x10
universe@80 16 #define UCX_LOGGER_INFO 0x20
universe@80 17 #define UCX_LOGGER_TRACE 0x30
universe@80 18
universe@80 19 #define UCX_LOGGER_LEVEL 0x01
universe@80 20 #define UCX_LOGGER_TIMESTAMP 0x02
universe@80 21 #define UCX_LOGGER_SOURCE 0x04
olaf@57 22
olaf@57 23 typedef struct {
olaf@57 24 FILE *stream;
olaf@57 25 unsigned int level;
universe@80 26 unsigned int mask;
universe@80 27 UcxMap* levels;
olaf@57 28 } UcxLogger;
olaf@57 29
universe@80 30 UcxLogger *ucx_logger_new(FILE *stream, unsigned int level, unsigned int mask);
universe@80 31 void ucx_logger_free(UcxLogger* logger);
olaf@57 32
universe@67 33 void ucx_logger_log(UcxLogger *logger, unsigned int level,
universe@80 34 const sstr_t message, const char* file, const unsigned int line);
universe@80 35 #define ucx_logger_error(l,m) \
universe@80 36 ucx_logger_log(l, UCX_LOGGER_ERROR, m, __FILE__, __LINE__)
universe@80 37 #define ucx_logger_info(l,m) \
universe@80 38 ucx_logger_log(l, UCX_LOGGER_INFO, m, __FILE__, __LINE__)
universe@80 39 #define ucx_logger_warn(l,m) \
universe@80 40 ucx_logger_log(l, UCX_LOGGER_WARN, m, __FILE__, __LINE__)
universe@80 41 #define ucx_logger_trace(l,m) \
universe@80 42 ucx_logger_log(l, UCX_LOGGER_TRACE, m, __FILE__, __LINE__)
olaf@57 43
olaf@57 44 #ifdef __cplusplus
olaf@57 45 }
olaf@57 46 #endif
olaf@57 47
olaf@57 48 #endif /* LOGGING_H */

mercurial