Make ipc_log_printf function working by adding _logsys_log_vprintf, which

is mostly same as _logsys_log_printf but takes va_list as argument.


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@2127 fd59a12c-fef9-0310-b244-a6a79926bd2f
This commit is contained in:
Jan Friesse 2009-04-23 12:29:26 +00:00
parent 65f8490350
commit 0dc4aed441
3 changed files with 67 additions and 3 deletions

View File

@ -1065,6 +1065,60 @@ void _logsys_log_rec (
records_written++;
}
void _logsys_log_vprintf (
int subsysid,
const char *function_name,
const char *file_name,
int file_line,
unsigned int level,
const char *format,
va_list ap)
{
char logsys_print_buffer[COMBINE_BUFFER_SIZE];
unsigned int len;
if (subsysid <= -1) {
subsysid = LOGSYS_MAX_SUBSYS_COUNT;
}
if ((level > logsys_loggers[subsysid].syslog_priority) &&
(level > logsys_loggers[subsysid].logfile_priority)) {
return;
}
len = vsprintf (logsys_print_buffer, format, ap);
if (logsys_print_buffer[len - 1] == '\n') {
logsys_print_buffer[len - 1] = '\0';
len -= 1;
}
/*
* Create a log record
*/
_logsys_log_rec (subsysid,
function_name,
file_name,
file_line,
(level+1) << 28,
logsys_print_buffer, len + 1,
LOGSYS_REC_END);
if ((logsys_loggers[LOGSYS_MAX_SUBSYS_COUNT].mode & LOGSYS_MODE_THREADED) == 0) {
/*
* Output (and block) if the log mode is not threaded otherwise
* expect the worker thread to output the log data once signaled
*/
log_printf_to_logs (logsys_loggers[subsysid].subsys,
file_name, function_name, file_line, level,
logsys_print_buffer);
} else {
/*
* Signal worker thread to display logging output
*/
wthread_signal ();
}
}
void _logsys_log_printf (
int subsysid,
const char *function_name,

View File

@ -604,12 +604,13 @@ static void corosync_sending_allowed_release (void *sending_allowed_private_data
static int ipc_subsys_id = -1;
static void ipc_log_printf (const char *format, ...) __attribute__((format(printf, 1, 2)));
static void ipc_log_printf (const char *format, ...) {
va_list ap;
va_list ap;
va_start (ap, format);
va_start (ap, format);
_logsys_log_printf (ipc_subsys_id, __FUNCTION__,
_logsys_log_vprintf (ipc_subsys_id, __FUNCTION__,
__FILE__, __LINE__, LOGSYS_LEVEL_ERROR, format, ap);
va_end (ap);

View File

@ -114,6 +114,15 @@ extern unsigned int _logsys_subsys_create (const char *subsys);
extern int _logsys_rec_init (unsigned int size);
extern void _logsys_log_vprintf (
int subsysid,
const char *function_name,
const char *file_name,
int file_line,
unsigned int level,
const char *format,
va_list ap) __attribute__((format(printf, 6, 0)));
extern void _logsys_log_printf (
int subsysid,
const char *function_name,