From fb4dcd08dc4eead97fb222e2177985fc647d313c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 12 Nov 2003 16:11:50 +0000 Subject: [PATCH] Now checks in the argument's options as well for LOG_CONS. The LOG_MASK() macro is now used correctly. The non-standard LOG_PERROR is always visible in stderr as well (in BeOS, so we copied it). Added a newline for stderr output. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5332 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/syslog.cpp | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/kernel/libroot/posix/syslog.cpp b/src/kernel/libroot/posix/syslog.cpp index b1af229dfa..e6811d4f2c 100644 --- a/src/kernel/libroot/posix/syslog.cpp +++ b/src/kernel/libroot/posix/syslog.cpp @@ -96,23 +96,28 @@ get_context() */ static void -send_syslog_message(syslog_context *context, int priority, const char *text, va_list args) +send_syslog_message(syslog_context *context, int options, const char *text, va_list args) { // do we have to do anything? - if ((context->mask & LOG_MASK(priority)) == 0) + if ((context->mask & LOG_MASK(SYSLOG_PRIORITY(options))) == 0) return; + options |= context->options; port_id port = find_port(SYSLOG_PORT_NAME); + + if ((options & LOG_PERROR) != 0 + || ((options & LOG_CONS) != 0 && port < B_OK)) { + // if asked for, print out the (simplified) message on stderr + if (context->ident[0]) + fprintf(stderr, "'%s' ", context->ident); + if (context->options & LOG_PID) + fprintf(stderr, "[%ld] ", find_thread(NULL)); + + vfprintf(stderr, text, args); + fputc('\n', stderr); + } if (port < B_OK) { - // apparently, there is no syslog daemon running; if asked - // for, print out the (simplified) message on stderr - if (context->options & LOG_CONS) { - if (context->ident[0]) - fprintf(stderr, "'%s' ", context->ident); - if (context->options & LOG_PID) - fprintf(stderr, "[%ld] ", find_thread(NULL)); - vfprintf(stderr, text, args); - } + // apparently, there is no syslog daemon running; return; } @@ -121,7 +126,7 @@ send_syslog_message(syslog_context *context, int priority, const char *text, va_ message.from = find_thread(NULL); message.when = real_time_clock(); - message.options = context->options | priority; + message.options = options; strcpy(message.ident, context->ident); int length = vsnprintf(message.message, sizeof(buffer) - sizeof(syslog_message), text, args);