ucx/logging.h

Tue, 09 Oct 2012 16:46:29 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 09 Oct 2012 16:46:29 +0200
changeset 57
e18157c52985
parent 54
f634f790661a
child 67
27e67e725d35
permissions
-rw-r--r--

some fixes

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

mercurial