add i3-nagbar. tells you about config file errors (for example)

This commit is contained in:
Michael Stapelberg
2011-07-10 14:33:19 +02:00
parent b63a559c28
commit c55abca115
17 changed files with 864 additions and 45 deletions

View File

@ -14,6 +14,7 @@
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
#include "util.h"
#include "log.h"
@ -23,6 +24,23 @@
static uint64_t loglevel = 0;
static bool verbose = true;
static FILE *errorfile;
char *errorfilename;
/*
* Initializes logging by creating an error logfile in /tmp (or
* XDG_RUNTIME_DIR, see get_process_filename()).
*
*/
void init_logging() {
errorfilename = get_process_filename("errorlog");
if (errorfilename == NULL) {
ELOG("Could not initialize errorlog\n");
return;
}
errorfile = fopen(errorfilename, "w");
}
/*
* Set verbosity of i3. If verbose is set to true, informative messages will
@ -101,6 +119,12 @@ void errorlog(char *fmt, ...) {
va_start(args, fmt);
vlog(fmt, args);
va_end(args);
/* also log to the error logfile, if opened */
va_start(args, fmt);
vfprintf(errorfile, fmt, args);
fflush(errorfile);
va_end(args);
}
/*