From: Peter Schiffer Date: Tue, 2 Apr 2013 08:54:24 +0000 (+0200) Subject: Enabled default logging X-Git-Tag: v0.41~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb2edb652c4deef345a1a9ff6a821d4e5ab667ff;p=thirdparty%2Flibcgroup.git Enabled default logging Default target of log messages is stdout and ERRORs are sent there by default. This is quite a change from the behavior of previous versions - no logging was sent anywhere unless --enable-debug was specified at ./configure time. Signed-off-by: Peter Schiffer Acked-by: Ivana Hutarova Varekova --- diff --git a/include/libcgroup/init.h b/include/libcgroup/init.h index 37090965..5150f2fc 100644 --- a/include/libcgroup/init.h +++ b/include/libcgroup/init.h @@ -35,6 +35,10 @@ __BEGIN_DECLS /** * Initialize libcgroup. Information about mounted hierarchies are examined * and cached internally (just what's mounted where, not the groups themselves). + * + * If the cgroup logging was not set using cgroup_set_logger() or + * cgroup_set_default_logger() before calling cgroup_init(), the default logger + * is automatically set, logging CGROUP_LOG_ERROR messages. */ int cgroup_init(void); diff --git a/include/libcgroup/log.h b/include/libcgroup/log.h index d504ae33..356eefb8 100644 --- a/include/libcgroup/log.h +++ b/include/libcgroup/log.h @@ -29,6 +29,8 @@ __BEGIN_DECLS * @par * The logging callback can be set at any time, but setting the callback before * any other libcgroup function (including cgroup_init()) is highly recommended. + * If no logger is set before cgroup_init() is called, default logger is + * automatically set, logging CGROUP_LOG_ERROR messages to stdout. * * @par Setting log level * Some of the functions below set the log level as integer. diff --git a/src/api.c b/src/api.c index 2851efd0..43acd32d 100644 --- a/src/api.c +++ b/src/api.c @@ -854,6 +854,8 @@ int cgroup_init(void) char mntent_buffer[4 * FILENAME_MAX]; char *strtok_buffer = NULL; + cgroup_set_default_logger(-1); + pthread_rwlock_wrlock(&cg_mount_table_lock); /* free global variables filled by previous cgroup_init() */