Added BSD extension vsyslog() - is also found on Linux.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23835 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2008-02-03 15:31:16 +00:00
parent 6b1fc6fcb7
commit e5bc2a9e7a
2 changed files with 56 additions and 41 deletions

View File

@ -6,6 +6,9 @@
#define _SYSLOG_H_
#include <stdarg.h>
/* options for openlog() */
#define LOG_PID (1 << 12) /* log the process (thread/team) ID with each message */
@ -80,6 +83,9 @@ extern void openlog_thread(const char *ident, int logopt, int facility);
extern void log_thread(int priority, const char *message, ...);
extern int setlogmask_thread(int priorityMask);
/* BSD extensions */
extern void vsyslog(int priority, const char *message, va_list args);
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright 2003-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Copyright 2003-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
@ -162,18 +162,53 @@ send_syslog_message(syslog_context *context, int priority, const char *text,
}
// #pragma mark - public Be API
// #pragma mark - POSIX API
void
closelog(void)
{
closelog_thread();
}
void
openlog(const char *ident, int options, int facility)
{
openlog_thread(ident, options, facility);
}
int
setlogmask(int priorityMask)
{
return setlogmask_thread(priorityMask);
}
void
syslog(int priority, const char *message, ...)
{
va_list args;
va_start(args, message);
send_syslog_message(get_context(), priority, message, args);
va_end(args);
}
// #pragma mark - Be extensions
// ToDo: it would probably be better to export these symbols as weak symbols only
void
void
closelog_team(void)
{
// nothing to do here...
}
void
void
openlog_team(const char *ident, int options, int facility)
{
if (ident != NULL)
@ -184,7 +219,7 @@ openlog_team(const char *ident, int options, int facility)
}
int
int
setlogmask_team(int priorityMask)
{
int oldMask = sTeamContext.mask;
@ -196,18 +231,18 @@ setlogmask_team(int priorityMask)
}
void
void
log_team(int priority, const char *message, ...)
{
va_list args;
va_start(args, message);
send_syslog_message(&sTeamContext, priority, message, args);
va_end(args);
}
void
void
closelog_thread(void)
{
if (sThreadContextSlot < 0)
@ -218,7 +253,7 @@ closelog_thread(void)
}
void
void
openlog_thread(const char *ident, int options, int facility)
{
syslog_context *context = get_context();
@ -231,7 +266,7 @@ openlog_thread(const char *ident, int options, int facility)
}
int
int
setlogmask_thread(int priorityMask)
{
syslog_context *context = get_context();
@ -244,49 +279,23 @@ setlogmask_thread(int priorityMask)
}
void
void
log_thread(int priority, const char *message, ...)
{
va_list args;
va_start(args, message);
send_syslog_message(get_context(), priority, message, args);
va_end(args);
}
// #pragma mark - POSIX API
// #pragma mark - BSD extensions
void
closelog(void)
void
vsyslog(int priority, const char *message, va_list args)
{
closelog_thread();
}
void
openlog(const char *ident, int options, int facility)
{
openlog_thread(ident, options, facility);
}
int
setlogmask(int priorityMask)
{
return setlogmask_thread(priorityMask);
}
void
syslog(int priority, const char *message, ...)
{
va_list args;
va_start(args, message);
send_syslog_message(get_context(), priority, message, args);
va_end(args);
}