xglcomp

view src/logger.h @ 0:d9b3fba68705

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