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

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

mercurial