xglcomp

annotate src/logger.h @ 8:b0081a0c211f

damage issues
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 30 Jan 2016 07:58:07 +0200
parents
children
rev   line source
nuclear@0 1 #ifndef LOGGER_H_
nuclear@0 2 #define LOGGER_H_
nuclear@0 3
nuclear@0 4 #include <stdio.h>
nuclear@0 5 #include <stdarg.h>
nuclear@0 6
nuclear@0 7 enum {
nuclear@0 8 LOG_INFO = 1,
nuclear@0 9 LOG_WARNING = 2,
nuclear@0 10 LOG_ERROR = 4,
nuclear@0 11 LOG_DEBUG = 8
nuclear@0 12 };
nuclear@0 13
nuclear@0 14 #ifdef __cplusplus
nuclear@0 15 extern "C" {
nuclear@0 16 #endif
nuclear@0 17
nuclear@0 18 /* Clear log outputs. Initially info/debug messages go to stdout, and
nuclear@0 19 * warning/error messages to stderr.
nuclear@0 20 */
nuclear@0 21 void log_clear_targets(void);
nuclear@0 22
nuclear@0 23 /* set logging outputs for any combination of message types.
nuclear@0 24 * type_mask expects a bitmask.
nuclear@0 25 */
nuclear@0 26 int log_add_stream(unsigned int type_mask, FILE *fp);
nuclear@0 27 int log_add_file(unsigned int type_mask, const char *fname);
nuclear@0 28 int log_add_func(unsigned int type_mask, void (*func)(const char*, void*), void *cls);
nuclear@0 29
nuclear@0 30 void log_msg(unsigned int type, const char *fmt, ...);
nuclear@0 31 /* log_msg helpers */
nuclear@0 32 void log_info(const char *fmt, ...);
nuclear@0 33 void log_warning(const char *fmt, ...);
nuclear@0 34 void log_error(const char *fmt, ...);
nuclear@0 35 void log_debug(const char *fmt, ...);
nuclear@0 36
nuclear@0 37 void log_va_msg(unsigned int type, const char *fmt, va_list va);
nuclear@0 38 /* log_va_msg helpers */
nuclear@0 39 void log_va_info(const char *fmt, va_list ap);
nuclear@0 40 void log_va_warning(const char *fmt, va_list ap);
nuclear@0 41 void log_va_error(const char *fmt, va_list ap);
nuclear@0 42 void log_va_debug(const char *fmt, va_list ap);
nuclear@0 43
nuclear@0 44 /* Intercept stdout/stderr and handle them through the logger. stdout as an
nuclear@0 45 * info log, and stderr as an error log. This only works on UNIX.
nuclear@0 46 */
nuclear@0 47 void log_grab_stdout(void);
nuclear@0 48 void log_grab_stderr(void);
nuclear@0 49
nuclear@0 50 #ifdef __cplusplus
nuclear@0 51 }
nuclear@0 52 #endif
nuclear@0 53
nuclear@0 54 #endif /* LOGGER_H_ */