From: Cedric Le Goater <legoater@free.fr>

This patch defines a new log category in each file using logging and
replaced the former logging routines with the new ones.

Signed-off-by: Cedric Le Goater <legoater@free.fr>
Acked-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
---
 src/lxc/cgroup.c             |   10 +
 src/lxc/checkpoint.c         |   10 +
 src/lxc/conf.c               |  253 +++++++++++++++++++++----------------------
 src/lxc/confile.c            |   79 ++++++-------
 src/lxc/console.c            |   12 +-
 src/lxc/cr_plugin_columbia.c |   13 +-
 src/lxc/create.c             |   23 ++-
 src/lxc/destroy.c            |   11 +
 src/lxc/freezer.c            |    7 -
 src/lxc/lxc_console.c        |   15 +-
 src/lxc/lxc_start.c          |    7 -
 src/lxc/monitor.c            |   23 ++-
 src/lxc/parse.c              |    9 +
 src/lxc/restart.c            |   55 ++++-----
 src/lxc/start.c              |   84 +++++++-------
 src/lxc/state.c              |   21 ++-
 src/lxc/stop.c               |    9 +
 17 files changed, 349 insertions(+), 292 deletions(-)

Index: lxc/src/lxc/cgroup.c
===================================================================
--- lxc.orig/src/lxc/cgroup.c
+++ lxc/src/lxc/cgroup.c
@@ -37,7 +37,11 @@
 #include <net/if.h>

 #include "error.h"
+
 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
+lxc_log_define(lxc_cgroup, lxc);

 #define MTAB "/etc/mtab"

@@ -49,7 +53,7 @@ static int get_cgroup_mount(const char *

         file = setmntent(mtab, "r");
         if (!file) {
-                lxc_log_syserror("failed to open %s", mtab);
+                SYSERROR("failed to open %s", mtab);
                 goto out;
         }

@@ -74,7 +78,7 @@ int lxc_link_nsgroup(const char *name, p
 	int ret;

 	if (get_cgroup_mount(MTAB, cgroup)) {
-		lxc_log_info("cgroup is not mounted");
+		INFO("cgroup is not mounted");
 		return -1;
 	}

@@ -84,7 +88,7 @@ int lxc_link_nsgroup(const char *name, p
 	unlink(lxc);
 	ret = symlink(nsgroup, lxc);
 	if (ret)
-		lxc_log_syserror("failed to create symlink %s->%s",
+		SYSERROR("failed to create symlink %s->%s",
 				 nsgroup, lxc);
       return ret;
 }
Index: lxc/src/lxc/checkpoint.c
===================================================================
--- lxc.orig/src/lxc/checkpoint.c
+++ lxc/src/lxc/checkpoint.c
@@ -40,6 +40,10 @@
 #include "lxc_plugin.h"
 #include <lxc.h>

+#include <lxc/log.h>
+
+lxc_log_define(lxc_checkpoint, lxc);
+
 #define MAXPIDLEN 20

 int lxc_checkpoint(const char *name, const char *statefile, 
@@ -62,19 +66,19 @@ int lxc_checkpoint(const char *name, con
 	snprintf(init, MAXPATHLEN, LXCPATH "/%s/init", name);
 	fd = open(init, O_RDONLY);
 	if (fd < 0) {
-		lxc_log_syserror("failed to open init file for %s", name);
+		SYSERROR("failed to open init file for %s", name);
 		goto out_close;
 	}
 	
 	if (read(fd, val, sizeof(val)) < 0) {
-		lxc_log_syserror("failed to read %s", init);
+		SYSERROR("failed to read %s", init);
 		goto out_close;
 	}

 	pid = atoi(val);

 	if (lxc_plugin_checkpoint(pid, statefile, flags) < 0) {
-		lxc_log_syserror("failed to checkpoint %zd", pid);
+		SYSERROR("failed to checkpoint %zd", pid);
 		goto out_close;
 	}

Index: lxc/src/lxc/conf.c
===================================================================
--- lxc.orig/src/lxc/conf.c
+++ lxc/src/lxc/conf.c
@@ -50,6 +50,9 @@
 #include "parse.h"

 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
+lxc_log_define(lxc_conf, lxc);

 #define MAXHWLEN    18
 #define MAXINDEXLEN 20
@@ -180,12 +183,12 @@ static int configure_ip4addr(int fd, str
 	int err = -1;

 	if (!inet_ntop(AF_INET, &in->addr, addr, sizeof(addr))) {
-		lxc_log_syserror("failed to convert ipv4 address");
+		SYSERROR("failed to convert ipv4 address");
 		goto err;
 	}

 	if (!inet_ntop(AF_INET, &in->bcast, bcast, sizeof(bcast))) {
-		lxc_log_syserror("failed to convert ipv4 broadcast");
+		SYSERROR("failed to convert ipv4 broadcast");
 		goto err;
 	}

@@ -195,7 +198,7 @@ static int configure_ip4addr(int fd, str
 		snprintf(line, MAXLINELEN, "%s %s\n", addr, bcast);

 	if (write(fd, line, strlen(line)) < 0) {
-		lxc_log_syserror("failed to write address info");
+		SYSERROR("failed to write address info");
 		goto err;
 	}

@@ -211,14 +214,14 @@ static int configure_ip6addr(int fd, str
 	int err = -1;

 	if (!inet_ntop(AF_INET6, &in6->addr, addr, sizeof(addr))) {
-		lxc_log_syserror("failed to convert ipv4 address");
+		SYSERROR("failed to convert ipv4 address");
 		goto err;
 	}

 	snprintf(line, MAXLINELEN, "%s/%d\n", addr, in6->prefix?in6->prefix:64);

 	if (write(fd, line, strlen(line)) < 0) {
-		lxc_log_syserror("failed to write address info");
+		SYSERROR("failed to write address info");
 		goto err;
 	}

@@ -234,14 +237,14 @@ static int configure_ip_address(const ch
 	int fd, err = -1;

 	if (mkdir(path, 0755)) {
-		lxc_log_syserror("failed to create directory %s", path);
+		SYSERROR("failed to create directory %s", path);
 		return -1;
 	}

 	snprintf(file, MAXPATHLEN, "%s/addresses", path);
 	fd = creat(file, 0755);
 	if (fd < 0) {
-		lxc_log_syserror("failed to create %s file", file);
+		SYSERROR("failed to create %s file", file);
 		goto err;
 	}

@@ -267,7 +270,7 @@ static int configure_netdev(const char *
 	char dir[MAXPATHLEN];

 	if (mkdir(path, 0755)) {
-		lxc_log_syserror("failed to create %s directory", path);
+		SYSERROR("failed to create %s directory", path);
 		return -1;
 	}

@@ -334,7 +337,7 @@ static int configure_utsname(const char 
 	snprintf(path, MAXPATHLEN, LXCPATH "/%s", name);

 	if (write_info(path, "utsname", utsname->nodename)) {
-		lxc_log_error("failed to write the utsname info");
+		ERROR("failed to write the utsname info");
 		return -1;
 	}

@@ -354,7 +357,7 @@ static int configure_network(const char 

 	snprintf(networkpath, MAXPATHLEN, LXCPATH "/%s/network", name);
 	if (mkdir(networkpath, 0755)) {
-		lxc_log_syserror("failed to create %s directory", networkpath);
+		SYSERROR("failed to create %s directory", networkpath);
 		goto out;
 	}

@@ -363,7 +366,7 @@ static int configure_network(const char 
 		n = iterator->elem;

 		if (n->type < 0 || n->type > MAXCONFTYPE) {
-			lxc_log_error("invalid network configuration type '%d'",
+			ERROR("invalid network configuration type '%d'",
 				      n->type);
 			goto out;
 		}
@@ -373,7 +376,7 @@ static int configure_network(const char 
 			 netdev_conf[n->type].count++);

 		if (configure_netdev(path, lxc_list_first_elem(&n->netdev))) {
-			lxc_log_error("failed to configure network type %s",
+			ERROR("failed to configure network type %s",
 				      netdev_conf[n->type].type);
 			goto out;
 		}
@@ -398,7 +401,7 @@ static int configure_cgroup(const char *

 	file = fopen(path, "w+");
 	if (!file) {
-		lxc_log_syserror("failed to open '%s'", path);
+		SYSERROR("failed to open '%s'", path);
 		return -1;
 	}

@@ -419,7 +422,7 @@ static int configure_tty(const char *nam
 	int ret;

 	if (asprintf(&nbtty, "%d", tty) < 0) {
-		lxc_log_error("failed to convert tty number");
+		ERROR("failed to convert tty number");
 		return -1;
 	}

@@ -427,7 +430,7 @@ static int configure_tty(const char *nam

 	ret = write_info(path, "tty", nbtty);
 	if (ret)
-		lxc_log_error("failed to write the tty info");
+		ERROR("failed to write the tty info");

 	free(nbtty);

@@ -490,12 +493,12 @@ static int configure_find_fstype(const c

 	cbarg.testdir = tempnam("/tmp", "lxc-");
 	if (!cbarg.testdir) {
-		lxc_log_syserror("failed to build a temp name");
+		SYSERROR("failed to build a temp name");
 		return -1;
 	}

 	if (mkdir(cbarg.testdir, 0755)) {
-		lxc_log_syserror("failed to create temporary directory");
+		SYSERROR("failed to create temporary directory");
 		return -1;
 	}

@@ -506,7 +509,7 @@ static int configure_find_fstype(const c
 					       buffer, sizeof(buffer), &cbarg);

 		if (found < 0) {
-			lxc_log_syserror("failed to read '%s'", fsfile[i]);
+			SYSERROR("failed to read '%s'", fsfile[i]);
 			goto out;
 		}

@@ -515,7 +518,7 @@ static int configure_find_fstype(const c
 	}

 	if (!found) {
-		lxc_log_error("failed to determine fs type for '%s'", rootfs);
+		ERROR("failed to determine fs type for '%s'", rootfs);
 		goto out;
 	}

@@ -536,7 +539,7 @@ static int configure_rootfs_blk_cb(const
 	char fstype[MAXPATHLEN];

 	if (configure_find_fstype(absrootfs, fstype, 0)) {
-		lxc_log_error("failed to configure mount for block device '%s'",
+		ERROR("failed to configure mount for block device '%s'",
 			      absrootfs);
 		return -1;
 	}
@@ -564,24 +567,24 @@ static int configure_rootfs(const char *
 	};

 	if (!realpath(rootfs, absrootfs)) {
-		lxc_log_syserror("failed to get real path for '%s'", rootfs);
+		SYSERROR("failed to get real path for '%s'", rootfs);
 		return -1;
 	}

 	snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs", name);

 	if (mkdir(path, 0755)) {
-		lxc_log_syserror("failed to create the '%s' directory", path);
+		SYSERROR("failed to create the '%s' directory", path);
 		return -1;
 	}

 	if (access(absrootfs, F_OK)) {
-		lxc_log_syserror("'%s' is not accessible", absrootfs);
+		SYSERROR("'%s' is not accessible", absrootfs);
 		return -1;
 	}

 	if (stat(absrootfs, &s)) {
-		lxc_log_syserror("failed to stat '%s'", absrootfs);
+		SYSERROR("failed to stat '%s'", absrootfs);
 		return -1;
 	}

@@ -594,7 +597,7 @@ static int configure_rootfs(const char *

 		f = fopen(fstab, "a+");
 		if (!f) {
-			lxc_log_syserror("failed to open fstab file");
+			SYSERROR("failed to open fstab file");
 			return -1;
 		}

@@ -603,7 +606,7 @@ static int configure_rootfs(const char *
 		fclose(f);

 		if (ret < 0) {
-			lxc_log_error("failed to add rootfs mount in fstab");
+			ERROR("failed to add rootfs mount in fstab");
 			return -1;
 		}

@@ -612,7 +615,7 @@ static int configure_rootfs(const char *
 		return symlink(absrootfs, path);
 	}

-	lxc_log_error("unsupported rootfs type for '%s'", absrootfs);
+	ERROR("unsupported rootfs type for '%s'", absrootfs);
 	return -1;
 }

@@ -623,7 +626,7 @@ static int configure_pts(const char *nam
 	int ret;

 	if (asprintf(&maxpts, "%d", pts) < 0) {
-		lxc_log_error("failed to convert max pts number");
+		ERROR("failed to convert max pts number");
 		return -1;
 	}

@@ -631,7 +634,7 @@ static int configure_pts(const char *nam

 	ret = write_info(path, "pts", maxpts);
 	if (ret)
-		lxc_log_error("failed to write the pts info");
+		ERROR("failed to write the pts info");

 	free(maxpts);

@@ -651,41 +654,41 @@ static int configure_mount(const char *n

 	outfd = open(path, O_RDWR|O_CREAT|O_EXCL, 0640);
 	if (outfd < 0) {
-		lxc_log_syserror("failed to creat '%s'", path);
+		SYSERROR("failed to creat '%s'", path);
 		goto out;
 	}

 	infd = open(fstab, O_RDONLY);
 	if (infd < 0) {
-		lxc_log_syserror("failed to open '%s'", fstab);
+		SYSERROR("failed to open '%s'", fstab);
 		goto out_open;
 	}

 	if (fstat(infd, &stat)) {
-		lxc_log_syserror("failed to stat '%s'", fstab);
+		SYSERROR("failed to stat '%s'", fstab);
 		goto out_open2;
 	}

 	if (lseek(outfd, stat.st_size - 1, SEEK_SET) < 0) {
-		lxc_log_syserror("failed to seek dest file '%s'", path);
+		SYSERROR("failed to seek dest file '%s'", path);
 		goto out_open2;
 	}

 	/* fixup length */
 	if (write(outfd, &c, 1) < 0) {
-		lxc_log_syserror("failed to write to '%s'", path);
+		SYSERROR("failed to write to '%s'", path);
 		goto out_open2;
 	}

 	src = mmap(NULL, stat.st_size, PROT_READ, MAP_SHARED, infd, 0L);
 	if (src == MAP_FAILED) {
-		lxc_log_syserror("failed to mmap '%s'", fstab);
+		SYSERROR("failed to mmap '%s'", fstab);
 		goto out_open2;
 	}

 	dst = mmap(NULL, stat.st_size, PROT_WRITE, MAP_SHARED, outfd, 0L);
 	if (dst == MAP_FAILED) {
-		lxc_log_syserror("failed to mmap '%s'", path);
+		SYSERROR("failed to mmap '%s'", path);
 		goto out_mmap;
 	}

@@ -767,7 +770,7 @@ static int unconfigure_cgroup(const char
 	snprintf(filename, MAXPATHLEN, LXCPATH "/%s/cgroup", name);

 	if (stat(filename, &s)) {
-		lxc_log_syserror("failed to stat '%s'", filename);
+		SYSERROR("failed to stat '%s'", filename);
 		return -1;
 	}

@@ -849,12 +852,12 @@ static int setup_utsname(const char *nam
 	ret = read_info(path, "utsname", utsname.nodename,
 			sizeof(utsname.nodename));
 	if (ret < 0) {
-		lxc_log_syserror("failed to read utsname info");
+		SYSERROR("failed to read utsname info");
 		return -1;
 	}

 	if (!ret && sethostname(utsname.nodename, strlen(utsname.nodename))) {
-		lxc_log_syserror("failed to set the hostname to '%s'",
+		SYSERROR("failed to set the hostname to '%s'",
 				 utsname.nodename);
 		return -1;
 	}
@@ -882,7 +885,7 @@ static int setup_tty(const char *name, c
 		 * with EACCES errno and I don't know why :( */

 		if (mount(pty_info->name, path, "none", MS_BIND, 0)) {
-			lxc_log_warning("failed to mount '%s'->'%s'",
+			WARN("failed to mount '%s'->'%s'",
 					pty_info->name, path);
 			continue;
 		}
@@ -898,12 +901,12 @@ static int setup_rootfs(const char *name
 	snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs", name);

 	if (chroot(path)) {
-		lxc_log_syserror("failed to set chroot %s", path);
+		SYSERROR("failed to set chroot %s", path);
 		return -1;
 	}

 	if (chdir(getenv("HOME")) && chdir("/")) {
-		lxc_log_syserror("failed to change to home directory");
+		SYSERROR("failed to change to home directory");
 		return -1;
 	}

@@ -915,32 +918,32 @@ static int setup_pts(const char *name)
 	char mountname[MAXPATHLEN];

 	if (!access("/dev/pts/ptmx", F_OK) && umount("/dev/pts")) {
-		lxc_log_syserror("failed to umount 'dev/pts'");
+		SYSERROR("failed to umount 'dev/pts'");
 		return -1;
 	}

 	snprintf(mountname, MAXPATHLEN, "%spts", name);

 	if (mount(mountname, "/dev/pts", "devpts", MS_MGC_VAL, "newinstance")) {
-		lxc_log_syserror("failed to mount a new instance of '/dev/pts'");
+		SYSERROR("failed to mount a new instance of '/dev/pts'");
 		return -1;
 	}

 	if (chmod("/dev/pts/ptmx", 0666)) {
-		lxc_log_syserror("failed to set permission for '/dev/pts/ptmx'");
+		SYSERROR("failed to set permission for '/dev/pts/ptmx'");
 		return -1;
 	}

 	if (access("/dev/ptmx", F_OK)) {
 		if (!symlink("/dev/pts/ptmx", "/dev/ptmx"))
 			goto out;
-		lxc_log_syserror("failed to symlink '/dev/pts/ptmx'->'/dev/ptmx'");
+		SYSERROR("failed to symlink '/dev/pts/ptmx'->'/dev/ptmx'");
 		return -1;
 	}

 	/* fallback here, /dev/pts/ptmx exists just mount bind */
 	if (mount("/dev/pts/ptmx", "/dev/ptmx", "none", MS_BIND, 0)) {
-		lxc_log_syserror("mount failed '/dev/pts/ptmx'->'/dev/ptmx'");
+		SYSERROR("mount failed '/dev/pts/ptmx'->'/dev/ptmx'");
 		return -1;
 	}
 out:
@@ -957,7 +960,7 @@ static int setup_console(const char *nam
 		return 0;

 	if (mount(tty, console, "none", MS_BIND, 0)) {
-		lxc_log_error("failed to mount the console");
+		ERROR("failed to mount the console");
 		return -1;
 	}

@@ -979,7 +982,7 @@ static int setup_cgroup_cb(void* buffer,

 	ret = lxc_cgroup_set(name, key, value);
 	if (ret)
-		lxc_log_syserror("failed to set cgroup '%s' = '%s' for '%s'",
+		SYSERROR("failed to set cgroup '%s' = '%s' for '%s'",
 				 key, value, name);
 	return ret;
 }
@@ -991,7 +994,7 @@ static int setup_convert_cgroup_cb(const
 	char line[MAXPATHLEN];

 	if (read_info(directory, file, line, MAXPATHLEN)) {
-		lxc_log_error("failed to read %s", file);
+		ERROR("failed to read %s", file);
 		return -1;
 	}

@@ -1041,13 +1044,13 @@ static int setup_cgroup(const char *name
 	snprintf(filename, MAXPATHLEN, LXCPATH "/%s/cgroup", name);

 	if (stat(filename, &s)) {
-		lxc_log_syserror("failed to stat '%s'", filename);
+		SYSERROR("failed to stat '%s'", filename);
 		return -1;
 	}

 	if (S_ISDIR(s.st_mode)) {
 		if (setup_convert_cgroup(name, filename)) {
-			lxc_log_error("failed to convert old cgroup configuration");
+			ERROR("failed to convert old cgroup configuration");
 			return -1;
 		}
 	}
@@ -1089,13 +1092,13 @@ static int parse_mntopts(struct mntent *

 	s = strdup(mntent->mnt_opts);
 	if (!s) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		return -1;
 	}

 	data = malloc(strlen(s) + 1);
 	if (!data) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		free(s);
 		return -1;
 	}
@@ -1129,7 +1132,7 @@ static int setup_mount(const char *name)
 	if (!file) {
 		if (errno == ENOENT)
 			return 0;
-		lxc_log_syserror("failed to open '%s'", path);
+		SYSERROR("failed to open '%s'", path);
 		goto out;
 	}

@@ -1137,14 +1140,14 @@ static int setup_mount(const char *name)
 		mntflags = 0;
 		mntdata = NULL;
 		if (parse_mntopts(mntent, &mntflags, &mntdata) < 0) {
-			lxc_log_error("failed to parse mount option '%s'",
+			ERROR("failed to parse mount option '%s'",
 				      mntent->mnt_opts);
 			goto out;
 		}

 		if (mount(mntent->mnt_fsname, mntent->mnt_dir,
 			  mntent->mnt_type, mntflags, mntdata)) {
-			lxc_log_syserror("failed to mount '%s' on '%s'",
+			SYSERROR("failed to mount '%s' on '%s'",
 					 mntent->mnt_fsname, mntent->mnt_dir);
 			goto out;
 		}
@@ -1183,7 +1186,7 @@ static int setup_ipv4_addr_cb(void *buff
 		p = atoi(prefix);

 	if (lxc_ip_addr_add(ifname, addr, p, bcast)) {
-		lxc_log_error("failed to set %s to addr %s/%d %s", ifname,
+		ERROR("failed to set %s to addr %s/%d %s", ifname,
 			      addr, p, bcast?bcast:"");
 		return -1;
 	}
@@ -1217,7 +1220,7 @@ static int setup_ipv6_addr_cb(void *buff
 		p = atoi(prefix);

 	if (lxc_ip6_addr_add(ifname, addr, p, bcast)) {
-		lxc_log_error("failed to set %s to addr %s/%d %s", ifname,
+		ERROR("failed to set %s to addr %s/%d %s", ifname,
 			      addr, p, bcast?bcast:"");
 		return -1;
 	}
@@ -1293,7 +1296,7 @@ static int setup_network_cb(const char *
 	snprintf(path, MAXPATHLEN, "%s/%s", directory, file);

 	if (read_info(path, "ifindex", strindex, sizeof(strindex))) {
-		lxc_log_error("failed to read ifindex info");
+		ERROR("failed to read ifindex info");
 		return -1;
 	}

@@ -1301,21 +1304,21 @@ static int setup_network_cb(const char *
 	if (!ifindex) {
 		if (!read_info(path, "up", strindex, sizeof(strindex)))
 		    if (lxc_device_up("lo")) {
-			    lxc_log_error("failed to set the loopback up");
+			    ERROR("failed to set the loopback up");
 			    return -1;
 		    }
 		    return 0;
 	}

 	if (!if_indextoname(ifindex, current_ifname)) {
-		lxc_log_error("no interface corresponding to index '%d'",
+		ERROR("no interface corresponding to index '%d'",
 			      ifindex);
 		return -1;
 	}

 	if (!read_info(path, "name", newname, sizeof(newname))) {
 		if (lxc_device_rename(ifname, newname)) {
-			lxc_log_error("failed to rename %s->%s",
+			ERROR("failed to rename %s->%s",
 				      ifname, newname);
 			return -1;
 		}
@@ -1324,33 +1327,33 @@ static int setup_network_cb(const char *

 	if (!read_info(path, "hwaddr", hwaddr, sizeof(hwaddr))) {
 		if (setup_hw_addr(hwaddr, current_ifname)) {
-			lxc_log_error("failed to setup hw address for '%s'",
+			ERROR("failed to setup hw address for '%s'",
 				      current_ifname);
 			return -1;
 		}
 	}

 	if (setup_ip_addr(path, current_ifname)) {
-		lxc_log_error("failed to setup ip addresses for '%s'",
+		ERROR("failed to setup ip addresses for '%s'",
 			      ifname);
 		return -1;
 	}

 	if (setup_ip6_addr(path, current_ifname)) {
-		lxc_log_error("failed to setup ipv6 addresses for '%s'",
+		ERROR("failed to setup ipv6 addresses for '%s'",
 			      ifname);
 		return -1;
 	}

 	if (!read_info(path, "up", strindex, sizeof(strindex))) {
 		if (lxc_device_up(current_ifname)) {
-			lxc_log_error("failed to set '%s' up", current_ifname);
+			ERROR("failed to set '%s' up", current_ifname);
 			return -1;
 		}

 		/* the network is up, make the loopback up too */
 		if (lxc_device_up("lo")) {
-			lxc_log_error("failed to set the loopback up");
+			ERROR("failed to set the loopback up");
 			return -1;
 		}
 	}
@@ -1384,7 +1387,7 @@ int conf_has(const char *name, const cha
 		goto out;
 	}

-	lxc_log_syserror("failed to stat %s info", info);
+	SYSERROR("failed to stat %s info", info);
 out:
 	return ret;
 }
@@ -1407,37 +1410,37 @@ int lxc_configure(const char *name, stru
 		return 0;

 	if (conf->utsname && configure_utsname(name, conf->utsname)) {
-		lxc_log_error("failed to configure the utsname");
+		ERROR("failed to configure the utsname");
 		return -LXC_ERROR_CONF_UTSNAME;
 	}

 	if (configure_cgroup(name, &conf->cgroup)) {
-		lxc_log_error("failed to configure the control group");
+		ERROR("failed to configure the control group");
 		return -LXC_ERROR_CONF_CGROUP;
 	}

 	if (configure_network(name, &conf->networks)) {
-		lxc_log_error("failed to configure the network");
+		ERROR("failed to configure the network");
 		return -LXC_ERROR_CONF_NETWORK;
 	}

 	if (conf->tty && configure_tty(name, conf->tty)) {
-		lxc_log_error("failed to configure the tty");
+		ERROR("failed to configure the tty");
 		return -LXC_ERROR_CONF_TTY;
 	}

 	if (conf->fstab && configure_mount(name, conf->fstab)) {
-		lxc_log_error("failed to configure the mount points");
+		ERROR("failed to configure the mount points");
 		return -LXC_ERROR_CONF_MOUNT;
 	}

 	if (conf->rootfs && configure_rootfs(name, conf->rootfs)) {
-		lxc_log_error("failed to configure the rootfs");
+		ERROR("failed to configure the rootfs");
 		return -LXC_ERROR_CONF_ROOTFS;
 	}

 	if (conf->pts && configure_pts(name, conf->pts)) {
-		lxc_log_error("failed to configure a new pts instance");
+		ERROR("failed to configure a new pts instance");
 		return -LXC_ERROR_CONF_PTS;
 	}

@@ -1447,25 +1450,25 @@ int lxc_configure(const char *name, stru
 int lxc_unconfigure(const char *name)
 {
 	if (conf_has_utsname(name) && unconfigure_utsname(name))
-		lxc_log_error("failed to cleanup utsname");
+		ERROR("failed to cleanup utsname");

 	if (conf_has_network(name) && unconfigure_network(name))
-		lxc_log_error("failed to cleanup the network");
+		ERROR("failed to cleanup the network");

 	if (conf_has_cgroup(name) && unconfigure_cgroup(name))
-		lxc_log_error("failed to cleanup cgroup");
+		ERROR("failed to cleanup cgroup");

 	if (conf_has_tty(name) && unconfigure_tty(name))
-		lxc_log_error("failed to cleanup tty");
+		ERROR("failed to cleanup tty");

 	if (conf_has_rootfs(name) && unconfigure_rootfs(name))
-		lxc_log_error("failed to cleanup rootfs");
+		ERROR("failed to cleanup rootfs");

 	if (conf_has_fstab(name) && unconfigure_mount(name))
-		lxc_log_error("failed to cleanup mount");
+		ERROR("failed to cleanup mount");

 	if (conf_has_pts(name) && unconfigure_pts(name))
-		lxc_log_error("failed to cleanup pts");
+		ERROR("failed to cleanup pts");

 	return 0;
 }
@@ -1480,62 +1483,62 @@ static int instanciate_veth(const char *
 	if (!asprintf(&veth1, "%s_%d", file, pid) ||
 	    !asprintf(&veth2, "%s~%d", file, pid) ||
 	    !asprintf(&path, "%s/%s", directory, file)) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		goto out;
 	}

 	if (read_info(path, "link", bridge, IFNAMSIZ)) {
-		lxc_log_error("failed to read bridge info");
+		ERROR("failed to read bridge info");
 		goto out;
 	}

 	if (lxc_veth_create(veth1, veth2)) {
-		lxc_log_error("failed to create %s-%s/%s", veth1, veth2, bridge);
+		ERROR("failed to create %s-%s/%s", veth1, veth2, bridge);
 		goto out;
 	}

 	if (!read_info(path, "mtu", strmtu, MAXMTULEN)) {
 		if (sscanf(strmtu, "%u", &mtu) < 1) {
-			lxc_log_error("invalid mtu size '%d'", mtu);
+			ERROR("invalid mtu size '%d'", mtu);
 			goto out_delete;
 		}

 		if (lxc_device_set_mtu(veth1, mtu)) {
-			lxc_log_error("failed to set mtu for '%s'", veth1);
+			ERROR("failed to set mtu for '%s'", veth1);
 			goto out_delete;
 		}

 		if (lxc_device_set_mtu(veth2, mtu)) {
-			lxc_log_error("failed to set mtu for '%s'", veth2);
+			ERROR("failed to set mtu for '%s'", veth2);
 			goto out_delete;
 		}
 	}

 	if (lxc_bridge_attach(bridge, veth1)) {
-		lxc_log_error("failed to attach '%s' to the bridge '%s'",
+		ERROR("failed to attach '%s' to the bridge '%s'",
 			      veth1, bridge);
 		goto out_delete;
 	}

 	ifindex = if_nametoindex(veth2);
 	if (!ifindex) {
-		lxc_log_error("failed to retrieve the index for %s", veth2);
+		ERROR("failed to retrieve the index for %s", veth2);
 		goto out_delete;
 	}

 	if (!asprintf(&strindex, "%d", ifindex)) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		goto out_delete;
 	}

 	if (write_info(path, "ifindex", strindex)) {
-		lxc_log_error("failed to write interface index to %s", path);
+		ERROR("failed to write interface index to %s", path);
 		goto out_delete;
 	}

 	if (!read_info(path, "up", strindex, sizeof(strindex))) {
 		if (lxc_device_up(veth1)) {
-			lxc_log_error("failed to set %s up", veth1);
+			ERROR("failed to set %s up", veth1);
 			goto out_delete;
 		}
 	}
@@ -1559,35 +1562,35 @@ static int instanciate_macvlan(const cha
 	int ifindex, ret = -1;

 	if (!asprintf(&peer, "%s~%d", file, pid)) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		return -1;
 	}

 	snprintf(path, MAXPATHLEN, "%s/%s", directory, file);
 	if (read_info(path, "link", link, IFNAMSIZ)) {
-		lxc_log_error("failed to read bridge info");
+		ERROR("failed to read bridge info");
 		goto out;
 	}

 	if (lxc_macvlan_create(link, peer)) {
-		lxc_log_error("failed to create macvlan interface '%s' on '%s'",
+		ERROR("failed to create macvlan interface '%s' on '%s'",
 			      peer, link);
 		goto out;
 	}

 	ifindex = if_nametoindex(peer);
 	if (!ifindex) {
-		lxc_log_error("failed to retrieve the index for %s", peer);
+		ERROR("failed to retrieve the index for %s", peer);
 		goto out;
 	}

 	if (!asprintf(&strindex, "%d", ifindex)) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		return -1;
 	}

 	if (write_info(path, "ifindex", strindex)) {
-		lxc_log_error("failed to write interface index to %s", path);
+		ERROR("failed to write interface index to %s", path);
 		goto out;
 	}

@@ -1606,23 +1609,23 @@ static int instanciate_phys(const char *

 	snprintf(path, MAXPATHLEN, "%s/%s", directory, file);
 	if (read_info(path, "link", link, IFNAMSIZ)) {
-		lxc_log_error("failed to read link info");
+		ERROR("failed to read link info");
 		goto out;
 	}

 	ifindex = if_nametoindex(link);
 	if (!ifindex) {
-		lxc_log_error("failed to retrieve the index for %s", link);
+		ERROR("failed to retrieve the index for %s", link);
 		goto out;
 	}

 	if (!asprintf(&strindex, "%d", ifindex)) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		return -1;
 	}

 	if (write_info(path, "ifindex", strindex)) {
-		lxc_log_error("failed to write interface index to %s", path);
+		ERROR("failed to write interface index to %s", path);
 		goto out;
 	}

@@ -1639,12 +1642,12 @@ static int instanciate_empty(const char 

 	snprintf(path, MAXPATHLEN, "%s/%s", directory, file);
 	if (!asprintf(&strindex, "%d", 0)) {
-		lxc_log_error("not enough memory");
+		ERROR("not enough memory");
 		return -1;
 	}

 	if (write_info(path, "ifindex", strindex)) {
-		lxc_log_error("failed to write interface index to %s", path);
+		ERROR("failed to write interface index to %s", path);
 		goto out;
 	}

@@ -1688,7 +1691,7 @@ static int move_netdev_cb(const char *na

 	snprintf(path, MAXPATHLEN, "%s/%s", directory, file);
 	if (read_info(path, "ifindex", strindex, MAXINDEXLEN) < 0) {
-		lxc_log_error("failed to read index to from %s", path);
+		ERROR("failed to read index to from %s", path);
 		return -1;
 	}

@@ -1697,13 +1700,13 @@ static int move_netdev_cb(const char *na
 		return 0;

 	if (!if_indextoname(ifindex, ifname)) {
-		lxc_log_error("interface with index %d does not exist",
+		ERROR("interface with index %d does not exist",
 			      ifindex);
 		return -1;
 	}

 	if (lxc_device_move(ifname, *pid)) {
-		lxc_log_error("failed to move %s to %d", ifname, *pid);
+		ERROR("failed to move %s to %d", ifname, *pid);
 		return -1;
 	}

@@ -1720,12 +1723,12 @@ static int move_netdev(const char *name,
 int conf_create_network(const char *name, pid_t pid)
 {
 	if (instanciate_netdev(name, pid)) {
-		lxc_log_error("failed to instantiate the network devices");
+		ERROR("failed to instantiate the network devices");
 		return -1;
 	}

 	if (move_netdev(name, pid)) {
-		lxc_log_error("failed to move the netdev to the container");
+		ERROR("failed to move the netdev to the container");
 		return -1;
 	}

@@ -1744,7 +1747,7 @@ static int delete_netdev_cb(const char *
 	snprintf(path, MAXPATHLEN, "%s/%s", directory, file);

 	if (read_info(path, "ifindex", strindex, MAXINDEXLEN)) {
-		lxc_log_error("failed to read ifindex info");
+		ERROR("failed to read ifindex info");
 		return -1;
 	}

@@ -1766,7 +1769,7 @@ static int delete_netdev_cb(const char *
 	/* do not delete a physical network device */
 	if (strncmp("phys", file, strlen("phys")))
 		if (lxc_device_delete(ifname)) {
-			lxc_log_error("failed to remove the netdev %s", ifname);
+			ERROR("failed to remove the netdev %s", ifname);
 		}

 	delete_info(path, "ifindex");
@@ -1783,7 +1786,7 @@ int conf_destroy_network(const char *nam
 	snprintf(directory, MAXPATHLEN, LXCPATH "/%s/network", name);

 	if (lxc_dir_for_each(name, directory, delete_netdev_cb, NULL)) {
-		lxc_log_error("failed to remove the network devices");
+		ERROR("failed to remove the network devices");
 		return -1;
 	}
 #endif
@@ -1804,7 +1807,7 @@ int lxc_create_tty(const char *name, str
 	snprintf(path, MAXPATHLEN, LXCPATH "/%s", name);

 	if (read_info(path, "tty", tty, sizeof(tty)) < 0) {
-		lxc_log_syserror("failed to read tty info");
+		SYSERROR("failed to read tty info");
 		goto out;
 	}

@@ -1813,7 +1816,7 @@ int lxc_create_tty(const char *name, str
 		malloc(sizeof(*tty_info->pty_info)*tty_info->nbtty);

 	if (!tty_info->pty_info) {
-		lxc_log_syserror("failed to allocate pty_info");
+		SYSERROR("failed to allocate pty_info");
 		goto out;
 	}

@@ -1823,7 +1826,7 @@ int lxc_create_tty(const char *name, str

 		if (openpty(&pty_info->master, &pty_info->slave,
 			    pty_info->name, NULL, NULL)) {
-			lxc_log_syserror("failed to create pty #%d", i);
+			SYSERROR("failed to create pty #%d", i);
 			goto out_free;
 		}

@@ -1911,42 +1914,42 @@ int lxc_setup(const char *name, const ch
 	long flags = make_conf_flagset(name, cons, tty_info);

 	if (conf_is_set(flags, utsname) && setup_utsname(name)) {
-		lxc_log_error("failed to setup the utsname for '%s'", name);
+		ERROR("failed to setup the utsname for '%s'", name);
 		return -LXC_ERROR_SETUP_UTSNAME;
 	}

 	if (conf_is_set(flags, network) && setup_network(name)) {
-		lxc_log_error("failed to setup the network for '%s'", name);
+		ERROR("failed to setup the network for '%s'", name);
 		return -LXC_ERROR_SETUP_NETWORK;
 	}

 	if (conf_is_set(flags, cgroup) && setup_cgroup(name)) {
-		lxc_log_error("failed to setup the cgroups for '%s'", name);
+		ERROR("failed to setup the cgroups for '%s'", name);
 		return -LXC_ERROR_SETUP_CGROUP;
 	}

 	if (conf_is_set(flags, fstab) && setup_mount(name)) {
-		lxc_log_error("failed to setup the mounts for '%s'", name);
+		ERROR("failed to setup the mounts for '%s'", name);
 		return -LXC_ERROR_SETUP_MOUNT;
 	}

 	if (conf_is_set(flags, console) && setup_console(name, cons)) {
-		lxc_log_error("failed to setup the console for '%s'", name);
+		ERROR("failed to setup the console for '%s'", name);
 		return -LXC_ERROR_SETUP_CONSOLE;
 	}

 	if (conf_is_set(flags, tty) && setup_tty(name, tty_info)) {
-		lxc_log_error("failed to setup the ttys for '%s'", name);
+		ERROR("failed to setup the ttys for '%s'", name);
 		return -LXC_ERROR_SETUP_TTY;
 	}

 	if (conf_is_set(flags, rootfs) && setup_rootfs(name)) {
-		lxc_log_error("failed to set rootfs for '%s'", name);
+		ERROR("failed to set rootfs for '%s'", name);
 		return -LXC_ERROR_SETUP_ROOTFS;
 	}

 	if (conf_is_set(flags, pts) && setup_pts(name)) {
-		lxc_log_error("failed to setup the new pts instance");
+		ERROR("failed to setup the new pts instance");
 		return -LXC_ERROR_SETUP_PTS;
 	}

Index: lxc/src/lxc/confile.c
===================================================================
--- lxc.orig/src/lxc/confile.c
+++ lxc/src/lxc/confile.c
@@ -35,6 +35,9 @@
 #include "parse.h"

 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
+lxc_log_define(lxc_confile, lxc);

 static int config_pts(const char *, char *, struct lxc_conf *);
 static int config_tty(const char *, char *, struct lxc_conf *);
@@ -99,7 +102,7 @@ static int config_network_type(const cha

 	network = malloc(sizeof(*network));
 	if (!network) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		return -1;
 	}

@@ -107,7 +110,7 @@ static int config_network_type(const cha

 	netdev = malloc(sizeof(*netdev));
 	if (!netdev) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		return -1;
 	}

@@ -118,7 +121,7 @@ static int config_network_type(const cha

 	ndlist = malloc(sizeof(*ndlist));
 	if (!ndlist) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		return -1;
 	}

@@ -128,7 +131,7 @@ static int config_network_type(const cha

 	list = malloc(sizeof(*list));
 	if (!list) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		return -1;
 	}

@@ -146,7 +149,7 @@ static int config_network_type(const cha
 	else if (!strcmp(value, "empty"))
 		network->type = EMPTY;
 	else {
-		lxc_log_error("invalid network type %s", value);
+		ERROR("invalid network type %s", value);
 		return -1;
 	}
 	return 0;
@@ -159,13 +162,13 @@ static int config_network_flags(const ch
 	struct lxc_netdev *netdev;

 	if (lxc_list_empty(networks)) {
-		lxc_log_error("network is not created for '%s' option", value);
+		ERROR("network is not created for '%s' option", value);
 		return -1;
 	}

 	network = lxc_list_first_elem(networks);
 	if (!network) {
-		lxc_log_error("no network defined for '%s' option", value);
+		ERROR("no network defined for '%s' option", value);
 		return -1;
 	}

@@ -181,18 +184,18 @@ static int config_network_link(const cha
 	struct lxc_netdev *netdev;

 	if (lxc_list_empty(networks)) {
-		lxc_log_error("network is not created for %s", value);
+		ERROR("network is not created for %s", value);
 		return -1;
 	}

 	network = lxc_list_first_elem(networks);
 	if (!network) {
-		lxc_log_error("no network defined for %s", value);
+		ERROR("no network defined for %s", value);
 		return -1;
 	}

 	if (strlen(value) > IFNAMSIZ) {
-		lxc_log_error("invalid interface name: %s", value);
+		ERROR("invalid interface name: %s", value);
 		return -1;
 	}

@@ -208,18 +211,18 @@ static int config_network_name(const cha
 	struct lxc_netdev *netdev;

 	if (lxc_list_empty(networks)) {
-		lxc_log_error("network is not created for %s", value);
+		ERROR("network is not created for %s", value);
 		return -1;
 	}

 	network = lxc_list_first_elem(networks);
 	if (!network) {
-		lxc_log_error("no network defined for %s", value);
+		ERROR("no network defined for %s", value);
 		return -1;
 	}

 	if (strlen(value) > IFNAMSIZ) {
-		lxc_log_error("invalid interface name: %s", value);
+		ERROR("invalid interface name: %s", value);
 		return -1;
 	}

@@ -235,13 +238,13 @@ static int config_network_hwaddr(const c
 	struct lxc_netdev *netdev;

 	if (lxc_list_empty(networks)) {
-		lxc_log_error("network is not created for %s", value);
+		ERROR("network is not created for %s", value);
 		return -1;
 	}

 	network = lxc_list_first_elem(networks);
 	if (!network) {
-		lxc_log_error("no network defined for %s", value);
+		ERROR("no network defined for %s", value);
 		return -1;
 	}

@@ -257,13 +260,13 @@ static int config_network_mtu(const char
 	struct lxc_netdev *netdev;

 	if (lxc_list_empty(networks)) {
-		lxc_log_error("network is not created for %s", value);
+		ERROR("network is not created for %s", value);
 		return -1;
 	}

 	network = lxc_list_first_elem(networks);
 	if (!network) {
-		lxc_log_error("no network defined for %s", value);
+		ERROR("no network defined for %s", value);
 		return -1;
 	}

@@ -282,31 +285,31 @@ static int config_network_ipv4(const cha
 	char *cursor, *slash, *addr = NULL, *bcast = NULL, *prefix = NULL;

 	if (lxc_list_empty(networks)) {
-		lxc_log_error("network is not created for '%s'", value);
+		ERROR("network is not created for '%s'", value);
 		return -1;
 	}

 	network = lxc_list_first_elem(networks);
 	if (!network) {
-		lxc_log_error("no network defined for '%s'", value);
+		ERROR("no network defined for '%s'", value);
 		return -1;
 	}

 	netdev = lxc_list_first_elem(&network->netdev);
 	if (!netdev) {
-		lxc_log_error("no netdev defined for '%s'", value);
+		ERROR("no netdev defined for '%s'", value);
 	}

 	inetdev = malloc(sizeof(*inetdev));
 	if (!inetdev) {
-		lxc_log_syserror("failed to allocate ipv4 address");
+		SYSERROR("failed to allocate ipv4 address");
 		return -1;
 	}
 	memset(inetdev, 0, sizeof(*inetdev));

 	list = malloc(sizeof(*list));
 	if (!list) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		return -1;
 	}

@@ -328,18 +331,18 @@ static int config_network_ipv4(const cha
 	}

 	if (!addr) {
-		lxc_log_error("no address specified");
+		ERROR("no address specified");
 		return -1;
 	}

 	if (!inet_pton(AF_INET, addr, &inetdev->addr)) {
-		lxc_log_syserror("invalid ipv4 address: %s", value);
+		SYSERROR("invalid ipv4 address: %s", value);
 		return -1;
 	}

 	if (bcast)
 		if (!inet_pton(AF_INET, bcast, &inetdev->bcast)) {
-			lxc_log_syserror("invalid ipv4 address: %s", value);
+			SYSERROR("invalid ipv4 address: %s", value);
 			return -1;
 		}

@@ -362,26 +365,26 @@ static int config_network_ipv6(const cha
 	char *netmask;

 	if (lxc_list_empty(networks)) {
-		lxc_log_error("network is not created for %s", value);
+		ERROR("network is not created for %s", value);
 		return -1;
 	}

 	network = lxc_list_first_elem(networks);
 	if (!network) {
-		lxc_log_error("no network defined for %s", value);
+		ERROR("no network defined for %s", value);
 		return -1;
 	}

 	inet6dev = malloc(sizeof(*inet6dev));
 	if (!inet6dev) {
-		lxc_log_syserror("failed to allocate ipv6 address");
+		SYSERROR("failed to allocate ipv6 address");
 		return -1;
 	}
 	memset(inet6dev, 0, sizeof(*inet6dev));

 	list = malloc(sizeof(*list));
 	if (!list) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		return -1;
 	}

@@ -396,7 +399,7 @@ static int config_network_ipv6(const cha
 	}

 	if (!inet_pton(AF_INET6, value, &inet6dev->addr)) {
-		lxc_log_syserror("invalid ipv6 address: %s", value);
+		SYSERROR("invalid ipv6 address: %s", value);
 		return -1;
 	}

@@ -467,13 +470,13 @@ static int config_cgroup(const char *key
 static int config_mount(const char *key, char *value, struct lxc_conf *lxc_conf)
 {
 	if (strlen(value) >= MAXPATHLEN) {
-		lxc_log_error("%s path is too long", value);
+		ERROR("%s path is too long", value);
 		return -1;
 	}

 	lxc_conf->fstab = strdup(value);
 	if (!lxc_conf->fstab) {
-		lxc_log_syserror("failed to duplicate string %s", value);
+		SYSERROR("failed to duplicate string %s", value);
 		return -1;
 	}

@@ -483,13 +486,13 @@ static int config_mount(const char *key,
 static int config_rootfs(const char *key, char *value, struct lxc_conf *lxc_conf)
 {
 	if (strlen(value) >= MAXPATHLEN) {
-		lxc_log_error("%s path is too long", value);
+		ERROR("%s path is too long", value);
 		return -1;
 	}

 	lxc_conf->rootfs = strdup(value);
 	if (!lxc_conf->rootfs) {
-		lxc_log_syserror("failed to duplicate string %s", value);
+		SYSERROR("failed to duplicate string %s", value);
 		return -1;
 	}

@@ -502,12 +505,12 @@ static int config_utsname(const char *ke

 	utsname = malloc(sizeof(*utsname));
 	if (!utsname) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		return -1;
 	}

 	if (strlen(value) >= sizeof(utsname->nodename)) {
-		lxc_log_error("node name '%s' is too long",
+		ERROR("node name '%s' is too long",
 			      utsname->nodename);
 		return -1;
 	}
@@ -535,7 +538,7 @@ static int parse_line(void *buffer, void

 	dot = strstr(line, "=");
 	if (!dot) {
-		lxc_log_error("invalid configuration line: %s", line);
+		ERROR("invalid configuration line: %s", line);
 		return -1;
 	}

@@ -550,7 +553,7 @@ static int parse_line(void *buffer, void

 	config = getconfig(key);
 	if (!config) {
-		lxc_log_error("unknow key %s", key);
+		ERROR("unknow key %s", key);
 		return -1;
 	}

Index: lxc/src/lxc/console.c
===================================================================
--- lxc.orig/src/lxc/console.c
+++ lxc/src/lxc/console.c
@@ -31,6 +31,10 @@
 #include "af_unix.h"
 #include "error.h"

+#include <lxc/log.h>
+
+lxc_log_define(lxc_console, lxc);
+
 extern int lxc_console(const char *name, int ttynum, int *fd)
 {
 	struct sockaddr_un addr = { 0 };
@@ -41,24 +45,24 @@ extern int lxc_console(const char *name,

 	sock = lxc_af_unix_connect(addr.sun_path);
 	if (sock < 0) {
-		lxc_log_error("failed to connect to the tty service");
+		ERROR("failed to connect to the tty service");
 		goto out_err;
 	}

 	ret = lxc_af_unix_send_credential(sock, &ttynum, sizeof(ttynum));
 	if (ret < 0) {
-		lxc_log_syserror("failed to send credentials");
+		SYSERROR("failed to send credentials");
 		goto out_err;
 	}

 	ret = lxc_af_unix_recv_fd(sock, fd, NULL, 0);
 	if (ret < 0) {
-		lxc_log_error("failed to connect to the tty");
+		ERROR("failed to connect to the tty");
 		goto out_err;
 	}

 	if (!ret) {
-		lxc_log_error("tty%d denied by '%s'", ttynum, name);
+		ERROR("tty%d denied by '%s'", ttynum, name);
 		ret = -LXC_ERROR_TTY_DENIED;
 		goto out_err;
 	}
Index: lxc/src/lxc/cr_plugin_columbia.c
===================================================================
--- lxc.orig/src/lxc/cr_plugin_columbia.c
+++ lxc/src/lxc/cr_plugin_columbia.c
@@ -36,6 +36,11 @@

 #include "error.h"
 #include <lxc.h>
+#include <lxc/log.h>
+
+lxc_log_define(lxc_columbia, lxc);
+
+

 #if __i386__
 #    define __NR_checkpoint 333
@@ -82,13 +87,13 @@ int lxc_plugin_checkpoint(pid_t pid, con

 	fd = open(statefile, O_RDWR);
 	if (fd < 0) {
-		lxc_log_syserror("failed to open init file for %s", statefile);
+		SYSERROR("failed to open init file for %s", statefile);
 		return -1;
 	}
 	
 	ret = sys_checkpoint(pid, fd, flags);
 	if (ret < 0) {
-		lxc_log_syserror("failed to checkpoint %d", pid);
+		SYSERROR("failed to checkpoint %d", pid);
 		goto out_close;
 	}

@@ -105,12 +110,12 @@ int lxc_plugin_restart(pid_t pid, const 

 	fd = open(statefile, O_RDONLY);
 	if (fd < 0) {
-		lxc_log_syserror("failed to open init file for %s", statefile);
+		SYSERROR("failed to open init file for %s", statefile);
 		return -1;
 	}
 	
 	sys_restart(pid, fd, flags);
-	lxc_log_syserror("failed to restart %d", pid);
+	SYSERROR("failed to restart %d", pid);
 	close(fd);
 	return -1;
 }
Index: lxc/src/lxc/create.c
===================================================================
--- lxc.orig/src/lxc/create.c
+++ lxc/src/lxc/create.c
@@ -32,6 +32,9 @@

 #include "error.h"
 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
+lxc_log_define(lxc_create, lxc);

 static int dir_filter(const struct dirent *dirent)
 {
@@ -48,7 +51,7 @@ static int is_empty_directory(const char

 	n = scandir(dirname, &namelist, dir_filter, alphasort);
 	if (n < 0)
-		lxc_log_syserror("failed to scan %s directory", dirname);
+		SYSERROR("failed to scan %s directory", dirname);
 	return n == 0;
 }

@@ -57,14 +60,14 @@ static int create_lxc_directory(const ch
 	char path[MAXPATHLEN];

 	if (mkdir(LXCPATH, 0755) && errno != EEXIST) {
-		lxc_log_syserror("failed to create %s directory", LXCPATH);
+		SYSERROR("failed to create %s directory", LXCPATH);
 		return -errno;
 	}

 	sprintf(path, LXCPATH "/%s", dirname);

 	if (mkdir(path, 0755)) {
-		lxc_log_syserror("failed to create %s directory", path);
+		SYSERROR("failed to create %s directory", path);
 		return -errno;
 	}

@@ -78,13 +81,13 @@ static int remove_lxc_directory(const ch
 	sprintf(path, LXCPATH "/%s", dirname);

 	if (rmdir(path)) {
-		lxc_log_syserror("failed to remove %s directory", path);
+		SYSERROR("failed to remove %s directory", path);
 		return -1;
 	}

 	if (is_empty_directory(LXCPATH)) {
 		if (rmdir(LXCPATH)) {
-			lxc_log_syserror("failed to remove %s directory", LXCPATH);
+			SYSERROR("failed to remove %s directory", LXCPATH);
 			return -1;
 		}
 	}
@@ -107,18 +110,18 @@ int lxc_create(const char *name, struct 

 	err = LXC_ERROR_INTERNAL;
 	if (lxc_mkstate(name)) {
-		lxc_log_error("failed to create the state file for %s", name);
+		ERROR("failed to create the state file for %s", name);
 		goto err;
 	}

 	if (lxc_setstate(name, STOPPED)) {
-		lxc_log_error("failed to set state for %s", name);
+		ERROR("failed to set state for %s", name);
 		goto err_state;
 	}

 	err = lxc_configure(name, conf);
 	if (err) {
-		lxc_log_error("failed to set configuration for %s", name);
+		ERROR("failed to set configuration for %s", name);
 		goto err_state;
 	}

@@ -131,9 +134,9 @@ err_state:
 	lxc_unconfigure(name);

 	if (lxc_rmstate(name))
-		lxc_log_error("failed to remove state file for %s", name);
+		ERROR("failed to remove state file for %s", name);
 err:
 	if (remove_lxc_directory(name))
-		lxc_log_error("failed to cleanup lxc directory for %s", name);
+		ERROR("failed to cleanup lxc directory for %s", name);
 	goto out;
 }
Index: lxc/src/lxc/destroy.c
===================================================================
--- lxc.orig/src/lxc/destroy.c
+++ lxc/src/lxc/destroy.c
@@ -31,6 +31,9 @@

 #include "error.h"
 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
+lxc_log_define(lxc_destroy, lxc);

 static int remove_lxc_directory(const char *dirname)
 {
@@ -39,7 +42,7 @@ static int remove_lxc_directory(const ch
 	sprintf(path, LXCPATH "/%s", dirname);

 	if (rmdir(path)) {
-		lxc_log_syserror("failed to remove %s directory", path);
+		SYSERROR("failed to remove %s directory", path);
 		return -1;
 	}

@@ -56,7 +59,7 @@ int lxc_destroy(const char *name)
 		return lock;

 	if (lxc_rmstate(name)) {
-		lxc_log_error("failed to remove state file for %s", name);
+		ERROR("failed to remove state file for %s", name);
 		goto out_lock;
 	}
 	
@@ -65,12 +68,12 @@ int lxc_destroy(const char *name)
 	lxc_unlink_nsgroup(name);

 	if (lxc_unconfigure(name)) {
-		lxc_log_error("failed to cleanup %s", name);
+		ERROR("failed to cleanup %s", name);
 		goto out_lock;
 	}

 	if (remove_lxc_directory(name)) {
-		lxc_log_syserror("failed to remove '%s'", name);
+		SYSERROR("failed to remove '%s'", name);
 		goto out_lock;
 	}

Index: lxc/src/lxc/freezer.c
===================================================================
--- lxc.orig/src/lxc/freezer.c
+++ lxc/src/lxc/freezer.c
@@ -33,6 +33,9 @@

 #include "error.h"
 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
+lxc_log_define(lxc_freezer, lxc);

 static int freeze_unfreeze(const char *name, int freeze)
 {
@@ -44,7 +47,7 @@ static int freeze_unfreeze(const char *n

 	fd = open(freezer, O_WRONLY);
 	if (fd < 0) {
-		lxc_log_syserror("failed to open freezer for '%s'", name);
+		SYSERROR("failed to open freezer for '%s'", name);
 		return -1;
 	}

@@ -64,7 +67,7 @@ static int freeze_unfreeze(const char *n

 	close(fd);
 	if (ret) 
-		lxc_log_syserror("failed to write to '%s'", freezer);
+		SYSERROR("failed to write to '%s'", freezer);

 	return 0;
 }
Index: lxc/src/lxc/lxc_console.c
===================================================================
--- lxc.orig/src/lxc/lxc_console.c
+++ lxc/src/lxc/lxc_console.c
@@ -39,6 +39,9 @@

 #include "error.h"
 #include "lxc.h"
+#include <lxc/log.h>
+
+lxc_log_define(lxc_console, lxc);

 void usage(char *cmd)
 {
@@ -77,7 +80,7 @@ int main(int argc, char *argv[])

 	/* Get current termios */
 	if (tcgetattr(0, &tios)) {
-		lxc_log_error("failed to get current terminal settings");
+		ERROR("failed to get current terminal settings");
 		fprintf(stderr, "%s\n", lxc_strerror(err));
 		return 1;
 	}
@@ -94,7 +97,7 @@ int main(int argc, char *argv[])

 	/* Set new attributes */
 	if (tcsetattr(0, TCSAFLUSH, &tios)) {
-		lxc_log_syserror("failed to set new terminal settings");
+		SYSERROR("failed to set new terminal settings");
 		fprintf(stderr, "%s\n", lxc_strerror(err));
 		return 1;
 	}
@@ -126,7 +129,7 @@ int main(int argc, char *argv[])
 		if (poll(pfd, 2, -1) < 0) {
 			if (errno == EINTR)
 				continue;
-			lxc_log_syserror("failed to poll");
+			SYSERROR("failed to poll");
 			goto out_err;
 		}
 		
@@ -134,7 +137,7 @@ int main(int argc, char *argv[])
 		 */
 		if (pfd[0].revents & POLLIN) {
 			if (read(0, &c, 1) < 0) {
-				lxc_log_syserror("failed to read");
+				SYSERROR("failed to read");
 				goto out_err;
 			}

@@ -149,7 +152,7 @@ int main(int argc, char *argv[])

 			wait4q = 0;
 			if (write(master, &c, 1) < 0) {
-				lxc_log_syserror("failed to write");
+				SYSERROR("failed to write");
 				goto out_err;
 			}
 		}
@@ -161,7 +164,7 @@ int main(int argc, char *argv[])
 		/* read the master and write to "stdout" */
 		if (pfd[1].revents & POLLIN) {
 			if (read(master, &c, 1) < 0) {
-				lxc_log_syserror("failed to read");
+				SYSERROR("failed to read");
 				goto out_err;
 			}
 			printf("%c", c);
Index: lxc/src/lxc/lxc_start.c
===================================================================
--- lxc.orig/src/lxc/lxc_start.c
+++ lxc/src/lxc/lxc_start.c
@@ -35,6 +35,9 @@
 #include <net/if.h>

 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
+lxc_log_define(lxc_start, lxc);

 void usage(char *cmd)
 {
@@ -76,7 +79,7 @@ int main(int argc, char *argv[])
 		usage(argv[0]);

 	if (tcgetattr(0, &tios)) {
-		lxc_log_error("failed to get current terminal settings");
+		ERROR("failed to get current terminal settings");
 		fprintf(stderr, "%s\n", lxc_strerror(err));
 		return 1;
 	}
@@ -88,7 +91,7 @@ int main(int argc, char *argv[])
 	}

 	if (tcsetattr(0, TCSAFLUSH, &tios))
-		lxc_log_syserror("failed to restore terminal attributes");
+		SYSERROR("failed to restore terminal attributes");

 	return err;
 }
Index: lxc/src/lxc/monitor.c
===================================================================
--- lxc.orig/src/lxc/monitor.c
+++ lxc/src/lxc/monitor.c
@@ -38,6 +38,9 @@

 #include "error.h"
 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
+lxc_log_define(lxc_monitor, lxc);

 #ifndef UNIX_PATH_MAX
 #define UNIX_PATH_MAX 108
@@ -59,7 +62,7 @@ int lxc_monitor(const char *name, int ou

 	nfd = inotify_init();
 	if (nfd < 0) {
-		lxc_log_syserror("failed to initialize inotify");
+		SYSERROR("failed to initialize inotify");
 		return -1;
 	}

@@ -67,7 +70,7 @@ int lxc_monitor(const char *name, int ou

 	wfd = inotify_add_watch(nfd, path, IN_DELETE_SELF|IN_CLOSE_WRITE);
 	if (wfd < 0) {
-		lxc_log_syserror("failed to add a watch on %s", path);
+		SYSERROR("failed to add a watch on %s", path);
 		goto out;
 	}

@@ -75,7 +78,7 @@ int lxc_monitor(const char *name, int ou
 		struct inotify_event evt;

 		if (read(nfd, &evt, sizeof(evt)) < 0) {
-			lxc_log_syserror("failed to read inotify event");
+			SYSERROR("failed to read inotify event");
 			goto out;
 		}

@@ -83,13 +86,13 @@ int lxc_monitor(const char *name, int ou

 			state = lxc_getstate(name);
 			if (state < 0) {
-				lxc_log_error("failed to get the state for %s",
+				ERROR("failed to get the state for %s",
 					      name);
 				goto out;
 			}

 			if (write(output_fd, &state, sizeof(state)) < 0) {
-				lxc_log_syserror("failed to send state to %d", 
+				SYSERROR("failed to send state to %d",
 						 output_fd);
 				goto out;
 			}
@@ -102,7 +105,7 @@ int lxc_monitor(const char *name, int ou
 			goto out;
 		}

-		lxc_log_error("unknown evt for inotity (%d)", evt.mask);
+		ERROR("unknown evt for inotity (%d)", evt.mask);
 		goto out;
 	}

@@ -119,7 +122,7 @@ static void lxc_monitor_send(struct lxc_

 	fd = socket(PF_NETLINK, SOCK_RAW, 0);
 	if (fd < 0) {
-		lxc_log_syserror("failed to create notification socket");
+		SYSERROR("failed to create notification socket");
 		return;
 	}

@@ -151,7 +154,7 @@ int lxc_monitor_open(void)

 	fd = socket(PF_NETLINK, SOCK_RAW, 0);
 	if (fd < 0) {
-		lxc_log_syserror("failed to create notification socket");
+		SYSERROR("failed to create notification socket");
 		return -LXC_ERROR_INTERNAL;
 	}

@@ -162,7 +165,7 @@ int lxc_monitor_open(void)
   	addr.nl_groups = MONITOR_MCGROUP;

 	if (bind(fd, (const struct sockaddr *)&addr, sizeof(addr))) {
-		lxc_log_syserror("failed to bind to multicast group '%d'",
+		SYSERROR("failed to bind to multicast group '%d'",
 			addr.nl_groups);
 		close(fd);
 		return -1;
@@ -180,7 +183,7 @@ int lxc_monitor_read(int fd, struct lxc_
 	ret = recvfrom(fd, msg, sizeof(*msg), 0, 
 		       (struct sockaddr *)&from, &len);
 	if (ret < 0) {
-		lxc_log_syserror("failed to received state");
+		SYSERROR("failed to received state");
 		return -LXC_ERROR_INTERNAL;
 	}

Index: lxc/src/lxc/parse.c
===================================================================
--- lxc.orig/src/lxc/parse.c
+++ lxc/src/lxc/parse.c
@@ -28,6 +28,9 @@

 #include "parse.h"
 #include "log.h"
+#include <lxc/log.h>
+
+lxc_log_define(lxc_parse, lxc);

 static int dir_filter(const struct dirent *dirent)
 {
@@ -45,13 +48,13 @@ int lxc_dir_for_each(const char *name, c

 	n = scandir(directory, &namelist, dir_filter, alphasort);
 	if (n < 0) {
-		lxc_log_syserror("failed to scan %s directory", directory);
+		SYSERROR("failed to scan %s directory", directory);
 		return -1;
 	}

 	while (n--) {
 		if (callback(name, directory, namelist[n]->d_name, data)) {
-			lxc_log_error("callback failed");
+			ERROR("callback failed");
 			free(namelist[n]);
 			return -1;
 		}
@@ -69,7 +72,7 @@ int lxc_file_for_each_line(const char *f

 	f = fopen(file, "r");
 	if (!f) {
-		lxc_log_syserror("failed to open %s", file);
+		SYSERROR("failed to open %s", file);
 		return -1;
 	}

Index: lxc/src/lxc/restart.c
===================================================================
--- lxc.orig/src/lxc/restart.c
+++ lxc/src/lxc/restart.c
@@ -40,6 +40,9 @@
 #include "error.h"
 #include "lxc_plugin.h"
 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
+lxc_log_define(lxc_restart, lxc);

 LXC_TTY_HANDLER(SIGINT);
 LXC_TTY_HANDLER(SIGQUIT);
@@ -60,19 +63,19 @@ int lxc_restart(const char *name, const 

 	/* Begin the set the state to STARTING*/
 	if (lxc_setstate(name, STARTING)) {
-		lxc_log_error("failed to set state %s", 
+		ERROR("failed to set state %s",
 			      lxc_state2str(STARTING));
 		goto out;
 	}

 	if (ttyname_r(0, tty, sizeof(tty))) {
 		tty[0] = '\0';
-		lxc_log_warning("failed to get tty name");
+		WARN("failed to get tty name");
 	}

 	/* Synchro socketpair */
 	if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sv)) {
-		lxc_log_syserror("failed to create communication socketpair");
+		SYSERROR("failed to create communication socketpair");
 		goto out;
 	}

@@ -89,7 +92,7 @@ int lxc_restart(const char *name, const 
 	/* Create a process in a new set of namespaces */
 	pid = fork_ns(clone_flags);
 	if (pid < 0) {
-		lxc_log_syserror("failed to fork into a new namespace");
+		SYSERROR("failed to fork into a new namespace");
 		goto err_fork_ns;
 	}

@@ -102,30 +105,30 @@ int lxc_restart(const char *name, const 
 		
 		/* Tell our father he can begin to configure the container */
 		if (write(sv[0], &sync, sizeof(sync)) < 0) {
-			lxc_log_syserror("failed to write socket");
+			SYSERROR("failed to write socket");
 			return 1;
 		}

 		/* Wait for the father to finish the configuration */
 		if (read(sv[0], &sync, sizeof(sync)) < 0) {
-			lxc_log_syserror("failed to read socket");
+			SYSERROR("failed to read socket");
 			return 1;
 		}

 		/* Setup the container, ip, names, utsname, ... */
 		if (lxc_setup(name, tty, &tty_info)) {
-			lxc_log_error("failed to setup the container");
+			ERROR("failed to setup the container");
 			if (write(sv[0], &sync, sizeof(sync)) < 0)
-				lxc_log_syserror("failed to write the socket");
+				SYSERROR("failed to write the socket");
 			return -1;
 		}

 		lxc_plugin_restart(getpid(), statefile, flags);
-		lxc_log_syserror("failed to restart");
+		SYSERROR("failed to restart");
   
 		/* If the exec fails, tell that to our father */
 		if (write(sv[0], &sync, sizeof(sync)) < 0)
-			lxc_log_syserror("failed to write the socket");
+			SYSERROR("failed to write the socket");
 		
 		exit(1);
 	}
@@ -134,62 +137,62 @@ int lxc_restart(const char *name, const 
 	
 	/* Wait for the child to be ready */
 	if (read(sv[1], &sync, sizeof(sync)) < 0) {
-		lxc_log_syserror("failed to read the socket");
+		SYSERROR("failed to read the socket");
 		goto err_pipe_read;
 	}

 	/* Create the network configuration */
 	if (clone_flags & CLONE_NEWNET && conf_create_network(name, pid)) {
-		lxc_log_error("failed to create the configured network");
+		ERROR("failed to create the configured network");
 		goto err_create_network;
 	}

 	/* Tell the child to continue its initialization */
 	if (write(sv[1], &sync, sizeof(sync)) < 0) {
-		lxc_log_syserror("failed to write the socket");
+		SYSERROR("failed to write the socket");
 		goto err_pipe_write;
 	}

 	/* Wait for the child to exec or returning an error */
 	err = read(sv[1], &sync, sizeof(sync));
 	if (err < 0) {
-		lxc_log_error("failed to read the socket");
+		ERROR("failed to read the socket");
 		goto err_pipe_read2;
 	}

 	if (err > 0) {
-		lxc_log_error("something went wrong with %d", pid);
+		ERROR("something went wrong with %d", pid);
 		/* TODO : check status etc ... */
 		waitpid(pid, NULL, 0);
 		goto err_child_failed;
 	}

 	if (!asprintf(&val, "%d\n", pid)) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		goto err_child_failed;
 	}
 	if (!asprintf(&init, LXCPATH "/%s/init", name)) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		goto err_child_failed;
 	}
 	fd = open(init, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);
 	if (fd < 0) {
-		lxc_log_syserror("failed to open '%s'", init);
+		SYSERROR("failed to open '%s'", init);
 		goto err_write;
 	}
 	
 	if (write(fd, val, strlen(val)) < 0) {
-		lxc_log_syserror("failed to write the init pid");
+		SYSERROR("failed to write the init pid");
 		goto err_write;
 	}

 	close(fd);

 	if (lxc_link_nsgroup(name, pid))
-		lxc_log_warning("cgroupfs not found: cgroup disabled");
+		WARN("cgroupfs not found: cgroup disabled");

 	if (lxc_setstate(name, RUNNING)) {
-		lxc_log_error("failed to set state to %s", 
+		ERROR("failed to set state to %s",
 			      lxc_state2str(RUNNING));
 		goto err_state_failed;
 	}
@@ -198,20 +201,20 @@ wait_again:
 	if (waitpid(pid, NULL, 0) < 0) {
 		if (errno == EINTR) 
 			goto wait_again;
-		lxc_log_syserror("failed to wait the pid %d", pid);
+		SYSERROR("failed to wait the pid %d", pid);
 		goto err_waitpid_failed;
 	}

 	if (lxc_setstate(name, STOPPING))
-		lxc_log_error("failed to set state %s", lxc_state2str(STOPPING));
+		ERROR("failed to set state %s", lxc_state2str(STOPPING));

 	if (clone_flags & CLONE_NEWNET && conf_destroy_network(name))
-		lxc_log_error("failed to destroy the network");
+		ERROR("failed to destroy the network");

 	err = 0;
 out:
 	if (lxc_setstate(name, STOPPED))
-		lxc_log_error("failed to set state %s", lxc_state2str(STOPPED));
+		ERROR("failed to set state %s", lxc_state2str(STOPPED));

 	lxc_unlink_nsgroup(name);
 	unlink(init);
@@ -234,7 +237,7 @@ err_create_network:
 err_pipe_read:
 err_waitpid_failed:
 	if (lxc_setstate(name, ABORTING))
-		lxc_log_error("failed to set state %s", lxc_state2str(STOPPED));
+		ERROR("failed to set state %s", lxc_state2str(STOPPED));

 	kill(pid, SIGKILL);
 err_fork_ns:
Index: lxc/src/lxc/start.c
===================================================================
--- lxc.orig/src/lxc/start.c
+++ lxc/src/lxc/start.c
@@ -91,6 +91,10 @@ int signalfd(int fd, const sigset_t *mas
 #include "mainloop.h"

 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
+lxc_log_define(lxc_start, lxc);
+

 LXC_TTY_HANDLER(SIGINT);
 LXC_TTY_HANDLER(SIGQUIT);
@@ -101,23 +105,23 @@ static int setup_sigchld_fd(sigset_t *ol
 	int fd;

 	if (sigprocmask(SIG_BLOCK, NULL, &mask)) {
-		lxc_log_syserror("failed to get mask signal");
+		SYSERROR("failed to get mask signal");
 		return -1;
 	}

 	if (sigaddset(&mask, SIGCHLD) || sigprocmask(SIG_BLOCK, &mask, oldmask)) {
-		lxc_log_syserror("failed to set mask signal");
+		SYSERROR("failed to set mask signal");
 		return -1;
 	}

 	fd = signalfd(-1, &mask, 0);
 	if (fd < 0) {
-		lxc_log_syserror("failed to create the signal fd");
+		SYSERROR("failed to create the signal fd");
 		return -1;
 	}

 	if (fcntl(fd, F_SETFD, FD_CLOEXEC)) {
-		lxc_log_syserror("failed to set sigfd to close-on-exec");
+		SYSERROR("failed to set sigfd to close-on-exec");
 		close(fd);
 		return -1;
 	}
@@ -139,7 +143,7 @@ static int setup_tty_service(const char 
 		return -1;

 	if (fcntl(fd, F_SETFD, FD_CLOEXEC)) {
-		lxc_log_syserror("failed to close-on-exec flag");
+		SYSERROR("failed to close-on-exec flag");
 		close(fd);
 		return -1;
 	}
@@ -186,12 +190,12 @@ static int ttyservice_handler(int fd, vo
 	
 	conn = accept(fd, NULL, 0);
 	if (conn < 0) {
-		lxc_log_syserror("failed to accept tty client");
+		SYSERROR("failed to accept tty client");
 		return -1;
 	}
 	
 	if (setsockopt(conn, SOL_SOCKET, SO_PASSCRED, &val, sizeof(val))) {
-		lxc_log_syserror("failed to enable credential on socket");
+		SYSERROR("failed to enable credential on socket");
 		goto out_close;
 	}

@@ -209,13 +213,13 @@ static int ttyservice_handler(int fd, vo

 	if (lxc_af_unix_send_fd(conn, tty_info->pty_info[ttynum].master, 
 				NULL, 0) < 0) {
-		lxc_log_error("failed to send tty to client");
+		ERROR("failed to send tty to client");
 		goto out_close;
 	}

 	if (lxc_mainloop_add_handler(descr, conn, 
 				     ttyclient_handler, tty_info)) {
-		lxc_log_error("failed to add tty client handler");
+		ERROR("failed to add tty client handler");
 		goto out_close;
 	}

@@ -237,7 +241,7 @@ static int mainloop(const char *name, pi
 	struct lxc_epoll_descr descr;

 	if (tty_info->nbtty && setup_tty_service(name, &ttyfd)) {
-		lxc_log_error("failed to create the tty service point");
+		ERROR("failed to create the tty service point");
 		goto out_sigfd;
 	}

@@ -246,12 +250,12 @@ static int mainloop(const char *name, pi
 	nfds = tty_info->nbtty + 1 + tty_info->nbtty ? 1 : 0;

 	if (lxc_mainloop_open(nfds, &descr)) {
-		lxc_log_error("failed to create mainloop");
+		ERROR("failed to create mainloop");
 		goto out_ttyfd;
 	}

 	if (lxc_mainloop_add_handler(&descr, sigfd, sigchld_handler, &pid)) {
-		lxc_log_error("failed to add handler for the signal");
+		ERROR("failed to add handler for the signal");
 		goto out_mainloop_open;
 	}

@@ -259,7 +263,7 @@ static int mainloop(const char *name, pi
 		if (lxc_mainloop_add_handler(&descr, ttyfd, 
 					     ttyservice_handler, 
 					     (void *)tty_info)) {
-			lxc_log_error("failed to add handler for the tty");
+			ERROR("failed to add handler for the tty");
 			goto out_mainloop_open;
 		}
 	}
@@ -295,7 +299,7 @@ int lxc_start(const char *name, char *ar

 	/* Begin the set the state to STARTING*/
 	if (lxc_setstate(name, STARTING)) {
-		lxc_log_error("failed to set state '%s'", 
+		ERROR("failed to set state '%s'",
 			      lxc_state2str(STARTING));
 		goto out;
 	}
@@ -305,7 +309,7 @@ int lxc_start(const char *name, char *ar
 		tty[0] = '\0';

 	if (lxc_create_tty(name, &tty_info)) {
-		lxc_log_error("failed to create the ttys");
+		ERROR("failed to create the ttys");
 		goto out;
 	}

@@ -314,13 +318,13 @@ int lxc_start(const char *name, char *ar
 	 * the event will be lost and the command will be stuck */
 	sigfd = setup_sigchld_fd(&oldmask);
 	if (sigfd < 0) {
-		lxc_log_error("failed to set sigchild fd handler");
+		ERROR("failed to set sigchild fd handler");
 		return -1;
 	}

 	/* Synchro socketpair */
 	if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sv)) {
-		lxc_log_syserror("failed to create communication socketpair");
+		SYSERROR("failed to create communication socketpair");
 		goto out;
 	}

@@ -337,14 +341,14 @@ int lxc_start(const char *name, char *ar
 	/* Create a process in a new set of namespaces */
 	pid = fork_ns(clone_flags);
 	if (pid < 0) {
-		lxc_log_syserror("failed to fork into a new namespace");
+		SYSERROR("failed to fork into a new namespace");
 		goto err_fork_ns;
 	}

 	if (!pid) {

 		if (sigprocmask(SIG_SETMASK, &oldmask, NULL)) {
-			lxc_log_syserror("failed to set sigprocmask");
+			SYSERROR("failed to set sigprocmask");
 			return -1;
 		}

@@ -355,37 +359,37 @@ int lxc_start(const char *name, char *ar
 		
 		/* Tell our father he can begin to configure the container */
 		if (write(sv[0], &sync, sizeof(sync)) < 0) {
-			lxc_log_syserror("failed to write socket");
+			SYSERROR("failed to write socket");
 			goto out_child;
 		}

 		/* Wait for the father to finish the configuration */
 		if (read(sv[0], &sync, sizeof(sync)) < 0) {
-			lxc_log_syserror("failed to read socket");
+			SYSERROR("failed to read socket");
 			goto out_child;
 		}

 		/* Setup the container, ip, names, utsname, ... */
 		err = lxc_setup(name, tty, &tty_info);
 		if (err) {
-			lxc_log_error("failed to setup the container");
+			ERROR("failed to setup the container");
 			if (write(sv[0], &err, sizeof(err)) < 0)
-				lxc_log_syserror("failed to write the socket");
+				SYSERROR("failed to write the socket");
 			goto out_child;
 		}

 		if (prctl(PR_CAPBSET_DROP, CAP_SYS_BOOT, 0, 0, 0)) {
-			lxc_log_syserror("failed to remove CAP_SYS_BOOT capability");
+			SYSERROR("failed to remove CAP_SYS_BOOT capability");
 			goto out_child;
 		}

 		execvp(argv[0], argv);
-		lxc_log_syserror("failed to exec %s", argv[0]);
+		SYSERROR("failed to exec %s", argv[0]);

 		err = LXC_ERROR_WRONG_COMMAND;
 		/* If the exec fails, tell that to our father */
 		if (write(sv[0], &err, sizeof(err)) < 0)
-			lxc_log_syserror("failed to write the socket");
+			SYSERROR("failed to write the socket");
 		
 	out_child:
 		exit(err);
@@ -395,29 +399,29 @@ int lxc_start(const char *name, char *ar
 	
 	/* Wait for the child to be ready */
 	if (read(sv[1], &sync, sizeof(sync)) < 0) {
-		lxc_log_syserror("failed to read the socket");
+		SYSERROR("failed to read the socket");
 		goto err_pipe_read;
 	}

 	if (lxc_link_nsgroup(name, pid))
-		lxc_log_warning("cgroupfs not found: cgroup disabled");
+		WARN("cgroupfs not found: cgroup disabled");

 	/* Create the network configuration */
 	if (clone_flags & CLONE_NEWNET && conf_create_network(name, pid)) {
-		lxc_log_error("failed to create the configured network");
+		ERROR("failed to create the configured network");
 		goto err_create_network;
 	}

 	/* Tell the child to continue its initialization */
 	if (write(sv[1], &sync, sizeof(sync)) < 0) {
-		lxc_log_syserror("failed to write the socket");
+		SYSERROR("failed to write the socket");
 		goto err_pipe_write;
 	}

 	/* Wait for the child to exec or returning an error */
 	err = read(sv[1], &sync, sizeof(sync));
 	if (err < 0) {
-		lxc_log_error("failed to read the socket");
+		ERROR("failed to read the socket");
 		goto err_pipe_read2;
 	}

@@ -428,7 +432,7 @@ int lxc_start(const char *name, char *ar
 	}

 	if (!asprintf(&val, "%d\n", pid)) {
-		lxc_log_syserror("failed to allocate memory");
+		SYSERROR("failed to allocate memory");
 		goto err_child_failed;
 	}

@@ -436,38 +440,38 @@ int lxc_start(const char *name, char *ar

 	fd = open(init, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);
 	if (fd < 0) {
-		lxc_log_syserror("failed to open '%s'", init);
+		SYSERROR("failed to open '%s'", init);
 		goto err_write;
 	}
 	
 	if (write(fd, val, strlen(val)) < 0) {
-		lxc_log_syserror("failed to write the init pid");
+		SYSERROR("failed to write the init pid");
 		goto err_write;
 	}

 	close(fd);

 	if (lxc_setstate(name, RUNNING)) {
-		lxc_log_error("failed to set state to %s", 
+		ERROR("failed to set state to %s",
 			      lxc_state2str(RUNNING));
 		goto err_state_failed;
 	}

 	if (mainloop(name, pid, sigfd, &tty_info)) {
-		lxc_log_error("mainloop exited with an error");
+		ERROR("mainloop exited with an error");
 		goto err_mailoop_failed;
 	}

 	if (lxc_setstate(name, STOPPING))
-		lxc_log_error("failed to set state %s", lxc_state2str(STOPPING));
+		ERROR("failed to set state %s", lxc_state2str(STOPPING));

 	if (clone_flags & CLONE_NEWNET && conf_destroy_network(name))
-		lxc_log_error("failed to destroy the network");
+		ERROR("failed to destroy the network");

 	err = 0;
 out:
 	if (lxc_setstate(name, STOPPED))
-		lxc_log_error("failed to set state %s", lxc_state2str(STOPPED));
+		ERROR("failed to set state %s", lxc_state2str(STOPPED));

 	lxc_delete_tty(&tty_info);
 	lxc_unlink_nsgroup(name);
@@ -492,7 +496,7 @@ err_create_network:
 err_pipe_read:
 err_mailoop_failed:
 	if (lxc_setstate(name, ABORTING))
-		lxc_log_error("failed to set state %s", lxc_state2str(STOPPED));
+		ERROR("failed to set state %s", lxc_state2str(STOPPED));

 	kill(pid, SIGKILL);
 err_fork_ns:
Index: lxc/src/lxc/state.c
===================================================================
--- lxc.orig/src/lxc/state.c
+++ lxc/src/lxc/state.c
@@ -32,6 +32,9 @@
 #include <sys/file.h>

 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
+lxc_log_define(lxc_state, lxc);

 static char *strstate[] = {
 	"STOPPED", "STARTING", "RUNNING", "STOPPING",
@@ -68,22 +71,22 @@ int lxc_setstate(const char *name, lxc_s

 	fd = open(file, O_WRONLY);
 	if (fd < 0) {
-		lxc_log_syserror("failed to open %s file", file);
+		SYSERROR("failed to open %s file", file);
 		return -1;
 	}

 	if (flock(fd, LOCK_EX)) {
-		lxc_log_syserror("failed to take the lock to %s", file);
+		SYSERROR("failed to take the lock to %s", file);
 		goto out;
 	}

 	if (ftruncate(fd, 0)) {
-		lxc_log_syserror("failed to truncate the file %s", file);
+		SYSERROR("failed to truncate the file %s", file);
 		goto out;
 	}

 	if (write(fd, str, strlen(str)) < 0) {
-		lxc_log_syserror("failed to write state to %s", file);
+		SYSERROR("failed to write state to %s", file);
 		goto out;
 	}

@@ -104,7 +107,7 @@ int lxc_mkstate(const char *name)
 	snprintf(file, MAXPATHLEN, LXCPATH "/%s/state", name);
 	fd = creat(file, S_IRUSR|S_IWUSR);
 	if (fd < 0) {
-		lxc_log_syserror("failed to create file %s", file);
+		SYSERROR("failed to create file %s", file);
 		return -1;
 	}
 	close(fd);
@@ -128,19 +131,19 @@ lxc_state_t lxc_getstate(const char *nam

 	fd = open(file, O_RDONLY);
 	if (fd < 0) {
-		lxc_log_syserror("failed to open %s", file);
+		SYSERROR("failed to open %s", file);
 		return -1;
 	}

 	if (flock(fd, LOCK_SH)) {
-		lxc_log_syserror("failed to take the lock to %s", file);
+		SYSERROR("failed to take the lock to %s", file);
 		close(fd);
 		return -1;
 	}

 	err = read(fd, file, strlen(file));
 	if (err < 0) {
-		lxc_log_syserror("failed to read file %s", file);
+		SYSERROR("failed to read file %s", file);
 		close(fd);
 		return -1;
 	}
@@ -168,7 +171,7 @@ static int freezer_state(const char *nam
 	fclose(file);

 	if (err == EOF) {
-		lxc_log_syserror("failed to read %s", freezer);
+		SYSERROR("failed to read %s", freezer);
 		return -1;
 	}

Index: lxc/src/lxc/stop.c
===================================================================
--- lxc.orig/src/lxc/stop.c
+++ lxc/src/lxc/stop.c
@@ -32,6 +32,9 @@
 #include <fcntl.h>

 #include <lxc/lxc.h>
+#include <lxc/log.h>
+
+lxc_log_define(lxc_stop, lxc);

 #define MAXPIDLEN 20

@@ -54,19 +57,19 @@ int lxc_stop(const char *name)
 	snprintf(init, MAXPATHLEN, LXCPATH "/%s/init", name);
 	fd = open(init, O_RDONLY);
 	if (fd < 0) {
-		lxc_log_syserror("failed to open init file for %s", name);
+		SYSERROR("failed to open init file for %s", name);
 		goto out_close;
 	}
 	
 	if (read(fd, val, sizeof(val)) < 0) {
-		lxc_log_syserror("failed to read %s", init);
+		SYSERROR("failed to read %s", init);
 		goto out_close;
 	}

 	pid = atoi(val);

 	if (kill(pid, SIGKILL)) {
-		lxc_log_syserror("failed to kill %zd", pid);
+		SYSERROR("failed to kill %zd", pid);
 		goto out_close;
 	}






