2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 06:15:24 +00:00

log: Add log-levels

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Cyrill Gorcunov
2012-02-17 22:51:23 +04:00
parent fe99f501ef
commit ef97467da9
5 changed files with 83 additions and 42 deletions

20
log.c
View File

@@ -67,11 +67,23 @@ void fini_log(void)
logfd = STDERR_FILENO;
}
void printk(const char *format, ...)
static unsigned int loglevel = LOG_WARN;
void set_loglevel(unsigned int level)
{
if (!level)
loglevel = LOG_ERROR;
else
loglevel = level;
}
void printk_level(unsigned int level, const char *format, ...)
{
va_list params;
va_start(params, format);
vdprintf(get_logfd(), format, params);
va_end(params);
if (level <= loglevel) {
va_start(params, format);
vdprintf(get_logfd(), format, params);
va_end(params);
}
}