Add two new modes LOG_MODE_SHORT_FILELINE and LOG_MODE_NOSUBSYS.

LOG_MODE_SHORT_FILELINE strips the leading path from the file name in
a debug output.  LOG_MODE_NOSUBSYS removes a global variable and provides
the ability to set or unset this via config_mode_set.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1570 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
Steven Dake 2008-07-01 22:08:15 +00:00
parent e1c909598d
commit 5f31ffa559
2 changed files with 10 additions and 4 deletions

View File

@ -69,8 +69,6 @@ static FILE *logsys_file_fp = NULL;
static int logsys_facility = LOG_DAEMON;
static int logsys_nosubsys = 0;
static int logsys_wthread_active = 0;
static pthread_mutex_t logsys_config_mutex = PTHREAD_MUTEX_INITIALIZER;
@ -121,7 +119,7 @@ static void logsys_buffer_flush (void);
void _logsys_nosubsys_set (void)
{
logsys_nosubsys = 1;
logsys_mode |= LOG_MODE_NOSUBSYS;
}
int logsys_facility_id_get (const char *name)
@ -298,6 +296,7 @@ static void _log_printf (
char newstring[4096];
char log_string[4096];
char char_time[512];
char *p = NULL;
struct timeval tv;
int i = 0;
int len;
@ -331,9 +330,14 @@ static void _log_printf (
}
if ((priority == LOG_LEVEL_DEBUG) || (logsys_mode & LOG_MODE_DISPLAY_FILELINE)) {
if (logsys_mode & LOG_MODE_SHORT_FILELINE) {
p = strrchr(file, '/');
if (p)
file = ++p;
}
sprintf (&newstring[i], "[%s:%04u] %s", file, line, format);
} else {
if (logsys_nosubsys == 1) {
if (logsys_mode & LOG_MODE_NOSUBSYS) {
sprintf (&newstring[i], "%s", format);
} else {
sprintf (&newstring[i], "[%-5s] %s", logsys_loggers[id].subsys, format);

View File

@ -52,6 +52,8 @@
#define LOG_MODE_DISPLAY_TIMESTAMP (1<<7)
#define LOG_MODE_BUFFER_BEFORE_CONFIG (1<<8)
#define LOG_MODE_FLUSH_AFTER_CONFIG (1<<9)
#define LOG_MODE_SHORT_FILELINE (1<<10)
#define LOG_MODE_NOSUBSYS (1<<11)
/*
* Log priorities, compliant with syslog and SA Forum Log spec.