]> git.sur5r.net Git - i3/i3/blob - include/log.h
Merge branch 'master' into next
[i3/i3] / include / log.h
1 /*
2  * vim:ts=4:sw=4:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
6  *
7  * log.c: Setting of loglevels, logging functions.
8  *
9  */
10 #ifndef _LOG_H
11 #define _LOG_H
12
13 #include <stdarg.h>
14 #include <stdbool.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 extern char *errorfilename;
24 extern char *shmlogname;
25 extern int shmlog_size;
26
27 /**
28  * Initializes logging by creating an error logfile in /tmp (or
29  * XDG_RUNTIME_DIR, see get_process_filename()).
30  *
31  */
32 void init_logging();
33
34 /**
35  * Enables the given loglevel.
36  *
37  */
38 void add_loglevel(const char *level);
39
40 /**
41  * Returns the offsets for the next write and for the last wrap.
42  * Necessary to print the i3 SHM log in the correct order.
43  *
44  */
45 void get_log_markers(int *offset_next_write, int *offset_last_wrap, int *size);
46
47 /**
48  * Set verbosity of i3. If verbose is set to true, informative messages will
49  * be printed to stdout. If verbose is set to false, only errors will be
50  * printed.
51  *
52  */
53 void set_verbosity(bool _verbose);
54
55 /**
56  * Logs the given message to stdout while prefixing the current time to it,
57  * but only if the corresponding debug loglevel was activated.
58  *
59  */
60 void debuglog(uint64_t lev, char *fmt, ...);
61
62 /**
63  * Logs the given message to stdout while prefixing the current time to it.
64  *
65  */
66 void errorlog(char *fmt, ...);
67
68 /**
69  * Logs the given message to stdout while prefixing the current time to it,
70  * but only if verbose mode is activated.
71  *
72  */
73 void verboselog(char *fmt, ...);
74
75 /**
76  * Logs the given message to stdout while prefixing the current time to it.
77  * This is to be called by LOG() which includes filename/linenumber
78  *
79  */
80 void slog(char *fmt, va_list args);
81
82 #endif