/*
- *
+ *
* log-server.c
- *
+ *
* Author: Tatu Ylonen <ylo@cs.hut.fi>
- *
+ *
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
* All rights reserved
- *
+ *
* Created: Mon Mar 20 21:19:30 1995 ylo
- *
+ *
* Server-side versions of debug(), log(), etc. These normally send the output
* to the system log.
- *
+ *
*/
#include "includes.h"
#ifdef HAVE___PROGNAME
extern char *__progname;
#else /* HAVE___PROGNAME */
-const char *__progname = "sshd";
+static const char *__progname = "sshd";
#endif /* HAVE___PROGNAME */
static LogLevel log_level = SYSLOG_LEVEL_INFO;
* level logging level
*/
-void
+void
log_init(char *av0, LogLevel level, SyslogFacility facility, int on_stderr)
{
switch (level) {
log_on_stderr = on_stderr;
}
-#define SSH_MSGBUFSIZE 1024
+#define MSGBUFSIZ 1024
void
do_log(LogLevel level, const char *fmt, va_list args)
{
- char msgbuf[SSH_MSGBUFSIZE];
- char fmtbuf[SSH_MSGBUFSIZE];
+ char msgbuf[MSGBUFSIZ];
+ char fmtbuf[MSGBUFSIZ];
char *txt = NULL;
int pri = LOG_INFO;
} else {
vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
}
- if (log_on_stderr)
+ if (log_on_stderr) {
fprintf(stderr, "%s\n", msgbuf);
- openlog(__progname, LOG_PID, log_facility);
- syslog(pri, "%.500s", msgbuf);
- closelog();
+ } else {
+ openlog(__progname, LOG_PID, log_facility);
+ syslog(pri, "%.500s", msgbuf);
+ closelog();
+ }
}