if (strlen(fname) == 0) {
log_fname = NULL;
- return 0;
+ return -1;
}
#if USE_CONFIGPATH_LOGS
int ret;
int lxc_priority = LXC_LOG_LEVEL_ERROR;
+ if (!log)
+ return -1;
+
if (lxc_log_fd != -1) {
WARN("Log already initialized");
return 0;
lxc_loglevel_specified = 1;
}
- if (!lxc_quiet_specified) {
+ if (!lxc_quiet_specified)
if (!log->quiet)
lxc_log_category_lxc.appender->next = &log_appender_stderr;
- }
if (log->prefix)
lxc_log_set_prefix(log->prefix);
return 0;
ret = __lxc_log_set_file(log->file, 1);
+ if (ret < 0) {
+ ERROR("Failed to enable logfile");
+ return -1;
+ }
+
lxc_log_use_global_fd = 1;
} else {
/* if no name was specified, there nothing to do */
ret = 0;
}
+ if (lxc_log_fd != -1) {
+ lxc_log_category_lxc.appender = &log_appender_logfile;
+ lxc_log_category_lxc.appender->next = &log_appender_stderr;
+ }
+
return ret;
}
char *const argv[])
{
int ret = 0;
+ bool logfile = false;
char shortopts[256];
ret = build_shortopts(args->options, shortopts, sizeof(shortopts));
break;
case 'o':
args->log_file = optarg;
+ logfile = true;
break;
case 'l':
args->log_priority = optarg;
+ if (!logfile &&
+ args->log_file &&
+ strcmp(args->log_file, "none") == 0)
+ args->log_file = NULL;
break;
case 'q':
args->quiet = 1;