ucx/logging.c

changeset 54
f634f790661a
child 57
e18157c52985
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ucx/logging.c	Mon Oct 08 14:04:52 2012 +0200
     1.3 @@ -0,0 +1,19 @@
     1.4 +#include "logging.h"
     1.5 +#include <stdlib.h>
     1.6 +
     1.7 +UcxLogger *ucx_logger_new(FILE *stream, unsigned int level) {
     1.8 +    UcxLogger *logger = (UcxLogger*) malloc(sizeof(UcxLogger));
     1.9 +    if (logger != NULL) {
    1.10 +        logger->stream = stream;
    1.11 +        logger->level = level;
    1.12 +    }
    1.13 +
    1.14 +    return logger;
    1.15 +}
    1.16 +
    1.17 +void ucx_logger_log(UcxLogger *logger, unsigned int level, sstr_t message) {
    1.18 +    if (level <= logger->level) {
    1.19 +        fwrite(message.ptr, 1, message.length, logger->stream);
    1.20 +        fflush(logger->stream);
    1.21 +    }
    1.22 +}

mercurial