ucx/logging.h

changeset 81
86a23238d8a1
parent 80
0125e4089f88
child 82
6068d965328b
     1.1 --- a/ucx/logging.h	Wed Feb 06 14:35:15 2013 +0100
     1.2 +++ b/ucx/logging.h	Fri Feb 08 10:37:24 2013 +0100
     1.3 @@ -22,6 +22,7 @@
     1.4  
     1.5  typedef struct {
     1.6      FILE *stream;
     1.7 +    size_t(*writer)(const void*, size_t, size_t, FILE*);
     1.8      unsigned int level;
     1.9      unsigned int mask;
    1.10      UcxMap* levels;
    1.11 @@ -30,16 +31,30 @@
    1.12  UcxLogger *ucx_logger_new(FILE *stream, unsigned int level, unsigned int mask);
    1.13  void ucx_logger_free(UcxLogger* logger);
    1.14  
    1.15 -void ucx_logger_log(UcxLogger *logger, unsigned int level,
    1.16 -        const sstr_t message, const char* file, const unsigned int line);
    1.17 -#define ucx_logger_error(l,m) \
    1.18 -    ucx_logger_log(l, UCX_LOGGER_ERROR, m, __FILE__, __LINE__)
    1.19 -#define ucx_logger_info(l,m) \
    1.20 -    ucx_logger_log(l, UCX_LOGGER_INFO, m, __FILE__, __LINE__)
    1.21 -#define ucx_logger_warn(l,m) \
    1.22 -    ucx_logger_log(l, UCX_LOGGER_WARN, m, __FILE__, __LINE__)
    1.23 -#define ucx_logger_trace(l,m) \
    1.24 -    ucx_logger_log(l, UCX_LOGGER_TRACE, m, __FILE__, __LINE__)
    1.25 +/**
    1.26 + * Sets the output stream and writer for this logger.
    1.27 + * The parameters stream and writer may be NULL, if they shall remain unchanged
    1.28 + * in the logger.
    1.29 + * l
    1.30 + * @param logger The logger
    1.31 + * @param stream The stream the logger shall log to
    1.32 + * @param writer A pointer to the write function
    1.33 + */
    1.34 +void ucx_logger_setoutput(UcxLogger *logger, FILE *stream,
    1.35 +        size_t(*writer)(const void*,size_t,size_t,FILE*));
    1.36 +
    1.37 +void ucx_logger_logf(UcxLogger *logger, unsigned int level, const char* file,
    1.38 +        const unsigned int line, const char* format, ...);
    1.39 +#define ucx_logger_log(logger, level, format...) \
    1.40 +    ucx_logger_logf(logger, level, __FILE__, __LINE__, format)
    1.41 +#define ucx_logger_error(logger,format...) \
    1.42 +    ucx_logger_log(logger, UCX_LOGGER_ERROR, format)
    1.43 +#define ucx_logger_info(logger,format...) \
    1.44 +    ucx_logger_log(logger, UCX_LOGGER_INFO, format)
    1.45 +#define ucx_logger_warn(logger,format...) \
    1.46 +    ucx_logger_log(logger, UCX_LOGGER_WARN, format)
    1.47 +#define ucx_logger_trace(logger,format...) \
    1.48 +    ucx_logger_log(logger, UCX_LOGGER_TRACE, format)
    1.49  
    1.50  #ifdef __cplusplus
    1.51  }

mercurial