2
0
mirror of git://github.com/lxc/lxc synced 2025-08-31 07:37:54 +00:00

add a default stderror log appender

This is adding a stderror log appender that is used as default one.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
Michel Normand
2009-05-15 10:47:08 +02:00
committed by Daniel Lezcano
parent 5fd8380be6
commit d737c07495

View File

@@ -38,11 +38,24 @@
#define LXC_LOG_PREFIX_SIZE 32
#define LXC_LOG_BUFFER_SIZE 512
int lxc_log_fd = 2;
int lxc_log_fd = -1;
static char log_prefix[LXC_LOG_PREFIX_SIZE] = "lxc";
lxc_log_define(lxc_log, lxc);
/*---------------------------------------------------------------------------*/
static int log_append_stderr(const struct lxc_log_appender *appender,
struct lxc_log_event *event)
{
if (event->priority < LXC_LOG_PRIORITY_ERROR)
return 0;
fprintf(stderr, "%s: ", log_prefix);
vfprintf(stderr, event->fmt, *event->vap);
fprintf(stderr, "\n");
return 0;
}
/*---------------------------------------------------------------------------*/
static int log_append_logfile(const struct lxc_log_appender *appender,
struct lxc_log_event *event)
@@ -75,10 +88,16 @@ static int log_append_logfile(const struct lxc_log_appender *appender,
return write(lxc_log_fd, buffer, n + 1);
}
static struct lxc_log_appender log_appender_stderr = {
.name = "stderr",
.append = log_append_stderr,
.next = NULL,
};
static struct lxc_log_appender log_appender_logfile = {
.name = "logfile",
.append = log_append_logfile,
.next = NULL,
.next = &log_appender_stderr,
};
static struct lxc_log_category log_root = {