ucx/logging.h

Wed, 06 Feb 2013 12:55:56 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 06 Feb 2013 12:55:56 +0100
changeset 78
af355652f271
parent 69
fb59270b1de3
child 80
0125e4089f88
permissions
-rw-r--r--

some fixes

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

mercurial