ucx/logging.h

changeset 54
f634f790661a
child 57
e18157c52985
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ucx/logging.h	Mon Oct 08 14:04:52 2012 +0200
     1.3 @@ -0,0 +1,35 @@
     1.4 +#ifndef LOGGING_H
     1.5 +#define LOGGING_H
     1.6 +
     1.7 +#include "string.h"
     1.8 +#include <stdio.h>
     1.9 +
    1.10 +#ifdef __cplusplus
    1.11 +extern "C" {
    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 +
    1.20 +typedef struct {
    1.21 +    FILE *stream;
    1.22 +    unsigned int level;
    1.23 +} UcxLogger;
    1.24 +
    1.25 +UcxLogger *ucx_logger_new(FILE *stream, unsigned int level);
    1.26 +/* neither provide a free function nor a parameter for an allocator */
    1.27 +
    1.28 +void ucx_logger_log(UcxLogger *logger, unsigned int level, sstr_t message);
    1.29 +#define ucx_logger_error(l,m) ucx_logger_log(l, UCX_LOGGER_ERROR, m)
    1.30 +#define ucx_logger_info(l,m) ucx_logger_log(l, UCX_LOGGER_INFO, m)
    1.31 +#define ucx_logger_warn(l,m) ucx_logger_log(l, UCX_LOGGER_WARN, m)
    1.32 +#define ucx_logger_trace(l,m) ucx_logger_log(l, UCX_LOGGER_TRACE, m)
    1.33 +
    1.34 +#ifdef __cplusplus
    1.35 +}
    1.36 +#endif
    1.37 +
    1.38 +#endif /* LOGGING_H */

mercurial