Permalink
Browse files

Log: Turn off the default log file if a real one is specified

  • Loading branch information...
beekhof committed Jul 21, 2014
1 parent bed0ddb commit dae7bb73424dbb48cb39fb10f103efc485fc8385
Showing with 20 additions and 3 deletions.
  1. +20 −3 lib/common/logging.c
View
@@ -223,16 +223,19 @@ set_format_string(int method, const char *daemon)
gboolean
crm_add_logfile(const char *filename)
{
bool is_default = false;
static int default_fd = -1;
static gboolean have_logfile = FALSE;
const char *default_logfile = "/var/log/pacemaker.log";
struct stat parent;
int fd = 0, rc = 0;
FILE *logfile = NULL;
char *parent_dir = NULL;
char *filename_cp;
static gboolean have_logfile = FALSE;
if (filename == NULL && have_logfile == FALSE) {
filename = "/var/log/pacemaker.log";
filename = default_logfile;
}
if (filename == NULL) {
@@ -241,6 +244,12 @@ crm_add_logfile(const char *filename)
return FALSE; /* Nothing to do */
} else if(safe_str_eq(filename, "/dev/null")) {
return FALSE; /* Nothing to do */
} else if(safe_str_eq(filename, default_logfile)) {
is_default = TRUE;
}
if(is_default && default_fd >= 0) {
return FALSE; /* Nothing to do */
}
/* Check the parent directory */
@@ -317,6 +326,14 @@ crm_add_logfile(const char *filename)
return FALSE;
}
if(is_default) {
default_fd = fd;
} else if(default_fd >= 0) {
crm_notice("Switching to %s", filename);
qb_log_ctl(default_fd, QB_LOG_CONF_ENABLED, QB_FALSE);
}
crm_notice("Additional logging available in %s", filename);
qb_log_ctl(fd, QB_LOG_CONF_ENABLED, QB_TRUE);
/* qb_log_ctl(fd, QB_LOG_CONF_FILE_SYNC, 1); Turn on synchronous writes */

0 comments on commit dae7bb7

Please sign in to comment.