ucx/logging.h

Fri, 08 Feb 2013 17:09:12 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 08 Feb 2013 17:09:12 +0100
changeset 83
3b552d7a9610
parent 82
6068d965328b
child 103
08018864fb91
permissions
-rw-r--r--

modified code to compile with -pedantic

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 {
universe@83 24 void *stream;
universe@82 25 write_func writer;
universe@82 26 char *dateformat;
olaf@57 27 unsigned int level;
universe@80 28 unsigned int mask;
universe@80 29 UcxMap* levels;
olaf@57 30 } UcxLogger;
olaf@57 31
universe@83 32 UcxLogger *ucx_logger_new(void *stream, unsigned int level, unsigned int mask);
universe@80 33 void ucx_logger_free(UcxLogger* logger);
olaf@57 34
universe@81 35 void ucx_logger_logf(UcxLogger *logger, unsigned int level, const char* file,
universe@81 36 const unsigned int line, const char* format, ...);
universe@83 37 #define ucx_logger_log(logger, level, ...) \
universe@83 38 ucx_logger_logf(logger, level, __FILE__, __LINE__, __VA_ARGS__)
universe@83 39 #define ucx_logger_error(logger, ...) \
universe@83 40 ucx_logger_log(logger, UCX_LOGGER_ERROR, __VA_ARGS__)
universe@83 41 #define ucx_logger_info(logger, ...) \
universe@83 42 ucx_logger_log(logger, UCX_LOGGER_INFO, __VA_ARGS__)
universe@83 43 #define ucx_logger_warn(logger, ...) \
universe@83 44 ucx_logger_log(logger, UCX_LOGGER_WARN, __VA_ARGS__)
universe@83 45 #define ucx_logger_trace(logger, ...) \
universe@83 46 ucx_logger_log(logger, UCX_LOGGER_TRACE, __VA_ARGS__)
olaf@57 47
olaf@57 48 #ifdef __cplusplus
olaf@57 49 }
olaf@57 50 #endif
olaf@57 51
olaf@57 52 #endif /* LOGGING_H */

mercurial