ucx/logging.h

Mon, 08 Oct 2012 14:04:52 +0200

author
Mike Becker <universe@uap-core.de>
date
Mon, 08 Oct 2012 14:04:52 +0200
changeset 54
f634f790661a
child 57
e18157c52985
permissions
-rw-r--r--

added logging API

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

mercurial