ucx/logging.h

changeset 80
0125e4089f88
parent 69
fb59270b1de3
child 81
86a23238d8a1
     1.1 --- a/ucx/logging.h	Wed Feb 06 14:31:44 2013 +0100
     1.2 +++ b/ucx/logging.h	Wed Feb 06 14:35:15 2013 +0100
     1.3 @@ -2,6 +2,7 @@
     1.4  #define LOGGING_H
     1.5  
     1.6  #include "ucx.h"
     1.7 +#include "map.h"
     1.8  #include "string.h"
     1.9  #include <stdio.h>
    1.10  
    1.11 @@ -10,25 +11,35 @@
    1.12  #endif
    1.13  
    1.14  /* leave enough space for custom log levels */
    1.15 -#define UCX_LOGGER_ERROR    0x00
    1.16 -#define UCX_LOGGER_WARN     0x10
    1.17 -#define UCX_LOGGER_INFO     0x20
    1.18 -#define UCX_LOGGER_TRACE    0x30
    1.19 +#define UCX_LOGGER_ERROR        0x00
    1.20 +#define UCX_LOGGER_WARN         0x10
    1.21 +#define UCX_LOGGER_INFO         0x20
    1.22 +#define UCX_LOGGER_TRACE        0x30
    1.23 +
    1.24 +#define UCX_LOGGER_LEVEL        0x01
    1.25 +#define UCX_LOGGER_TIMESTAMP    0x02
    1.26 +#define UCX_LOGGER_SOURCE       0x04
    1.27  
    1.28  typedef struct {
    1.29      FILE *stream;
    1.30      unsigned int level;
    1.31 +    unsigned int mask;
    1.32 +    UcxMap* levels;
    1.33  } UcxLogger;
    1.34  
    1.35 -UcxLogger *ucx_logger_new(FILE *stream, unsigned int level);
    1.36 -/* neither provide a free function nor a parameter for an allocator */
    1.37 +UcxLogger *ucx_logger_new(FILE *stream, unsigned int level, unsigned int mask);
    1.38 +void ucx_logger_free(UcxLogger* logger);
    1.39  
    1.40  void ucx_logger_log(UcxLogger *logger, unsigned int level,
    1.41 -        const sstr_t message);
    1.42 -#define ucx_logger_error(l,m) ucx_logger_log(l, UCX_LOGGER_ERROR, m)
    1.43 -#define ucx_logger_info(l,m) ucx_logger_log(l, UCX_LOGGER_INFO, m)
    1.44 -#define ucx_logger_warn(l,m) ucx_logger_log(l, UCX_LOGGER_WARN, m)
    1.45 -#define ucx_logger_trace(l,m) ucx_logger_log(l, UCX_LOGGER_TRACE, m)
    1.46 +        const sstr_t message, const char* file, const unsigned int line);
    1.47 +#define ucx_logger_error(l,m) \
    1.48 +    ucx_logger_log(l, UCX_LOGGER_ERROR, m, __FILE__, __LINE__)
    1.49 +#define ucx_logger_info(l,m) \
    1.50 +    ucx_logger_log(l, UCX_LOGGER_INFO, m, __FILE__, __LINE__)
    1.51 +#define ucx_logger_warn(l,m) \
    1.52 +    ucx_logger_log(l, UCX_LOGGER_WARN, m, __FILE__, __LINE__)
    1.53 +#define ucx_logger_trace(l,m) \
    1.54 +    ucx_logger_log(l, UCX_LOGGER_TRACE, m, __FILE__, __LINE__)
    1.55  
    1.56  #ifdef __cplusplus
    1.57  }

mercurial