]> git.sur5r.net Git - i3/i3/blob - include/log.h
add log.c/log.h which contain all the log related macros and functions
[i3/i3] / include / log.h
1 /*
2  * vim:ts=8:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  *
6  * © 2009 Michael Stapelberg and contributors
7  *
8  * See file LICENSE for license information.
9  *
10  */
11 #ifndef _LOG_H
12 #define _LOG_H
13
14 #include <stdarg.h>
15
16 /** ##__VA_ARGS__ means: leave out __VA_ARGS__ completely if it is empty, that
17    is, delete the preceding comma */
18 #define LOG(fmt, ...) verboselog(fmt, ##__VA_ARGS__)
19 #define ELOG(fmt, ...) errorlog("ERROR: " fmt, ##__VA_ARGS__)
20 #define DLOG(fmt, ...) debuglog(LOGLEVEL, "%s:%s:%d - " fmt, __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
21
22 extern char *loglevels[];
23
24 /**
25  * Enables the given loglevel.
26  *
27  */
28 void add_loglevel(const char *level);
29
30 /**
31  * Set verbosity of i3. If verbose is set to true, informative messages will
32  * be printed to stdout. If verbose is set to false, only errors will be
33  * printed.
34  *
35  */
36 void set_verbosity(bool _verbose);
37
38 /**
39  * Logs the given message to stdout while prefixing the current time to it,
40  * but only if the corresponding debug loglevel was activated.
41  *
42  */
43 void debuglog(int lev, char *fmt, ...);
44
45 /**
46  * Logs the given message to stdout while prefixing the current time to it.
47  *
48  */
49 void errorlog(char *fmt, ...);
50
51 /**
52  * Logs the given message to stdout while prefixing the current time to it,
53  * but only if verbose mode is activated.
54  *
55  */
56 void verboselog(char *fmt, ...);
57
58 /**
59  * Logs the given message to stdout while prefixing the current time to it.
60  * This is to be called by LOG() which includes filename/linenumber
61  *
62  */
63 void slog(char *fmt, va_list args);
64
65 #endif