* syslog.cc (try_connect_syslogd): Add priority parameter. Use writev
to add the priority to the message in a syslog conformant way. (vsyslog): If facility isn't set in the priority, use default facility as given in call to openlog. Fix agressive use of spaces in syslog output. Call try_connect_syslogd with priority parameter.
This commit is contained in:
parent
143bf87846
commit
bf2d5da310
|
@ -1,3 +1,11 @@
|
|||
2005-10-11 Corinna Vinschen <corinna@vinschen.de>
|
||||
|
||||
* syslog.cc (try_connect_syslogd): Add priority parameter. Use writev
|
||||
to add the priority to the message in a syslog conformant way.
|
||||
(vsyslog): If facility isn't set in the priority, use default facility
|
||||
as given in call to openlog. Fix agressive use of spaces in syslog
|
||||
output. Call try_connect_syslogd with priority parameter.
|
||||
|
||||
2005-10-11 Christopher Faylor <cgf@timesys.com>
|
||||
|
||||
* (symlink_info::set_error): Change to return bool if input error
|
||||
|
|
|
@ -17,6 +17,7 @@ details. */
|
|||
#include <stdarg.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/uio.h>
|
||||
#include "cygerrno.h"
|
||||
#include "security.h"
|
||||
#include "path.h"
|
||||
|
@ -189,7 +190,7 @@ extern "C" int cygwin_socket (int, int, int);
|
|||
extern "C" int cygwin_connect (int, const struct sockaddr *, int);
|
||||
|
||||
static int
|
||||
try_connect_syslogd (const char *msg, int len)
|
||||
try_connect_syslogd (int priority, const char *msg, int len)
|
||||
{
|
||||
try_connect_guard.init ("try_connect_guard")->acquire ();
|
||||
if (!syslogd_inited)
|
||||
|
@ -225,10 +226,19 @@ try_connect_syslogd (const char *msg, int len)
|
|||
syslogd_inited = true;
|
||||
}
|
||||
out:
|
||||
int ret = -1;
|
||||
ssize_t ret = -1;
|
||||
if (syslogd_sock >= 0)
|
||||
{
|
||||
ret = write (syslogd_sock, msg, len);
|
||||
char pribuf[16];
|
||||
sprintf (pribuf, "<%d>", priority);
|
||||
struct iovec iv[2] =
|
||||
{
|
||||
{ pribuf, strlen (pribuf) },
|
||||
{ (char *) msg, len }
|
||||
};
|
||||
|
||||
|
||||
ret = writev (syslogd_sock, iv, 2);
|
||||
/* If write fails and LOG_CONS is set, return failure to vsyslog so
|
||||
it falls back to the usual logging method for this OS. */
|
||||
if (ret >= 0 || !(_my_tls.locals.process_logopt & LOG_CONS))
|
||||
|
@ -260,6 +270,10 @@ vsyslog (int priority, const char *message, va_list ap)
|
|||
return;
|
||||
}
|
||||
|
||||
/* Add default facility if not in the given priority. */
|
||||
if (!(priority & LOG_FACMASK))
|
||||
priority |= _my_tls.locals.process_facility;
|
||||
|
||||
/* Translate %m in the message to error text */
|
||||
char *errtext = strerror (get_errno ());
|
||||
int errlen = strlen (errtext);
|
||||
|
@ -396,7 +410,7 @@ vsyslog (int priority, const char *message, va_list ap)
|
|||
write (STDERR_FILENO, total_msg, len + 1);
|
||||
|
||||
int fd;
|
||||
if ((fd = try_connect_syslogd (total_msg, len + 1)) >= 0)
|
||||
if ((fd = try_connect_syslogd (priority, total_msg, len + 1)) >= 0)
|
||||
;
|
||||
else if (wincap.has_eventlog ())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue