2 * vim:ts=4:sw=4:expandtab
4 * i3 - an improved dynamic tiling window manager
5 * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
7 * log.c: Logging functions.
15 /* We will include libi3.h which define its own version of LOG, ELOG.
16 * We want *our* version, so we undef the libi3 one. */
26 /** ##__VA_ARGS__ means: leave out __VA_ARGS__ completely if it is empty, that
27 is, delete the preceding comma */
28 #define LOG(fmt, ...) verboselog(fmt, ##__VA_ARGS__)
29 #define ELOG(fmt, ...) errorlog("ERROR: " fmt, ##__VA_ARGS__)
30 #define DLOG(fmt, ...) debuglog("%s:%s:%d - " fmt, I3__FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__)
32 extern char *errorfilename;
33 extern char *shmlogname;
34 extern int shmlog_size;
37 * Initializes logging by creating an error logfile in /tmp (or
38 * XDG_RUNTIME_DIR, see get_process_filename()).
41 void init_logging(void);
44 * Opens the logbuffer.
47 void open_logbuffer(void);
50 * Closes the logbuffer.
53 void close_logbuffer(void);
56 * Checks if debug logging is active.
59 bool get_debug_logging(void);
65 void set_debug_logging(const bool _debug_logging);
68 * Set verbosity of i3. If verbose is set to true, informative messages will
69 * be printed to stdout. If verbose is set to false, only errors will be
73 void set_verbosity(bool _verbose);
76 * Logs the given message to stdout while prefixing the current time to it,
77 * but only if debug logging was activated.
80 void debuglog(char *fmt, ...)
81 __attribute__((format(printf, 1, 2)));
84 * Logs the given message to stdout while prefixing the current time to it.
87 void errorlog(char *fmt, ...)
88 __attribute__((format(printf, 1, 2)));
91 * Logs the given message to stdout while prefixing the current time to it,
92 * but only if verbose mode is activated.
95 void verboselog(char *fmt, ...)
96 __attribute__((format(printf, 1, 2)));
99 * Deletes the unused log files. Useful if i3 exits immediately, eg.
100 * because --get-socketpath was called. We don't care for syscall
101 * failures. This function is invoked automatically when exiting.
103 void purge_zerobyte_logfile(void);