log.c: fix indenting

This commit is contained in:
Michael Stapelberg 2010-11-29 22:28:23 +01:00
parent 38b231b848
commit 5625a2f17f

View File

@ -1,9 +1,9 @@
/* /*
* vim:ts=8:expandtab * vim:ts=4:sw=4:expandtab
* *
* i3 - an improved dynamic tiling window manager * i3 - an improved dynamic tiling window manager
* *
* © 2009 Michael Stapelberg and contributors * © 2009-2010 Michael Stapelberg and contributors
* *
* See file LICENSE for license information. * See file LICENSE for license information.
* *
@ -24,37 +24,37 @@
static uint64_t loglevel = 0; static uint64_t loglevel = 0;
static bool verbose = true; static bool verbose = true;
/** /*
* Set verbosity of i3. If verbose is set to true, informative messages will * Set verbosity of i3. If verbose is set to true, informative messages will
* be printed to stdout. If verbose is set to false, only errors will be * be printed to stdout. If verbose is set to false, only errors will be
* printed. * printed.
* *
*/ */
void set_verbosity(bool _verbose) { void set_verbosity(bool _verbose) {
verbose = _verbose; verbose = _verbose;
} }
/** /*
* Enables the given loglevel. * Enables the given loglevel.
* *
*/ */
void add_loglevel(const char *level) { void add_loglevel(const char *level) {
/* Handle the special loglevel "all" */ /* Handle the special loglevel "all" */
if (strcasecmp(level, "all") == 0) { if (strcasecmp(level, "all") == 0) {
loglevel = UINT64_MAX; loglevel = UINT64_MAX;
return; return;
} }
for (int i = 0; i < sizeof(loglevels) / sizeof(char*); i++) { for (int i = 0; i < sizeof(loglevels) / sizeof(char*); i++) {
if (strcasecmp(loglevels[i], level) != 0) if (strcasecmp(loglevels[i], level) != 0)
continue; continue;
/* The position in the array (plus one) is the amount of times /* The position in the array (plus one) is the amount of times
* which we need to shift 1 to the left to get our bitmask for * which we need to shift 1 to the left to get our bitmask for
* the specific loglevel. */ * the specific loglevel. */
loglevel |= (1 << (i+1)); loglevel |= (1 << (i+1));
break; break;
} }
} }
/* /*
@ -63,44 +63,44 @@ void add_loglevel(const char *level) {
* *
*/ */
void vlog(char *fmt, va_list args) { void vlog(char *fmt, va_list args) {
char timebuf[64]; char timebuf[64];
/* Get current time */ /* Get current time */
time_t t = time(NULL); time_t t = time(NULL);
/* Convert time to local time (determined by the locale) */ /* Convert time to local time (determined by the locale) */
struct tm *tmp = localtime(&t); struct tm *tmp = localtime(&t);
/* Generate time prefix */ /* Generate time prefix */
strftime(timebuf, sizeof(timebuf), "%x %X - ", tmp); strftime(timebuf, sizeof(timebuf), "%x %X - ", tmp);
printf("%s", timebuf); printf("%s", timebuf);
vprintf(fmt, args); vprintf(fmt, args);
} }
/** /*
* Logs the given message to stdout while prefixing the current time to it, * Logs the given message to stdout while prefixing the current time to it,
* but only if verbose mode is activated. * but only if verbose mode is activated.
* *
*/ */
void verboselog(char *fmt, ...) { void verboselog(char *fmt, ...) {
va_list args; va_list args;
if (!verbose) if (!verbose)
return; return;
va_start(args, fmt); va_start(args, fmt);
vlog(fmt, args); vlog(fmt, args);
va_end(args); va_end(args);
} }
/** /*
* Logs the given message to stdout while prefixing the current time to it. * Logs the given message to stdout while prefixing the current time to it.
* *
*/ */
void errorlog(char *fmt, ...) { void errorlog(char *fmt, ...) {
va_list args; va_list args;
va_start(args, fmt); va_start(args, fmt);
vlog(fmt, args); vlog(fmt, args);
va_end(args); va_end(args);
} }
/* /*
@ -110,12 +110,12 @@ void errorlog(char *fmt, ...) {
* *
*/ */
void debuglog(uint64_t lev, char *fmt, ...) { void debuglog(uint64_t lev, char *fmt, ...) {
va_list args; va_list args;
if ((loglevel & lev) == 0) if ((loglevel & lev) == 0)
return; return;
va_start(args, fmt); va_start(args, fmt);
vlog(fmt, args); vlog(fmt, args);
va_end(args); va_end(args);
} }