ucx/logging.h

Fri, 30 Nov 2012 21:18:13 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 30 Nov 2012 21:18:13 +0100
changeset 1
1bcaac272cdf
child 5
88625853ae74
permissions
-rw-r--r--

added existing source code

#ifndef LOGGING_H
#define LOGGING_H

#include "ucx.h"
#include "string.h"
#include <stdio.h>

#ifdef __cplusplus
extern "C" {
#endif

/* leave enough space for custom log levels */
#define UCX_LOGGER_ERROR    0x00
#define UCX_LOGGER_WARN     0x10
#define UCX_LOGGER_INFO     0x20
#define UCX_LOGGER_TRACE    0x30

typedef struct {
    FILE *stream;
    unsigned int level;
} UcxLogger;

UcxLogger *ucx_logger_new(FILE *stream, unsigned int level);
/* neither provide a free function nor a parameter for an allocator */

void ucx_logger_log(UcxLogger *logger, unsigned int level,
        const sstr_t message);
#define ucx_logger_error(l,m) ucx_logger_log(l, UCX_LOGGER_ERROR, m)
#define ucx_logger_info(l,m) ucx_logger_log(l, UCX_LOGGER_INFO, m)
#define ucx_logger_warn(l,m) ucx_logger_log(l, UCX_LOGGER_WARN, m)
#define ucx_logger_trace(l,m) ucx_logger_log(l, UCX_LOGGER_TRACE, m)

#ifdef __cplusplus
}
#endif

#endif /* LOGGING_H */

mercurial