1999-10-27 03:42:43 +00:00
|
|
|
/*
|
|
|
|
|
|
|
|
log-client.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:13:40 1995 ylo
|
|
|
|
|
|
|
|
Client-side versions of debug(), log(), etc. These print to stderr.
|
1999-11-11 06:57:39 +00:00
|
|
|
This is a stripped down version of log-server.c.
|
1999-10-27 03:42:43 +00:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "includes.h"
|
1999-11-11 06:57:39 +00:00
|
|
|
RCSID("$Id: log-client.c,v 1.2 1999/11/11 06:57:39 damien Exp $");
|
1999-10-27 03:42:43 +00:00
|
|
|
|
|
|
|
#include "xmalloc.h"
|
|
|
|
#include "ssh.h"
|
|
|
|
|
1999-11-11 06:57:39 +00:00
|
|
|
static LogLevel log_level = SYSLOG_LEVEL_INFO;
|
1999-10-27 03:42:43 +00:00
|
|
|
|
1999-11-11 06:57:39 +00:00
|
|
|
/* Initialize the log.
|
|
|
|
av0 program name (should be argv[0])
|
|
|
|
level logging level
|
|
|
|
*/
|
1999-10-27 03:42:43 +00:00
|
|
|
|
1999-11-11 06:57:39 +00:00
|
|
|
void
|
|
|
|
log_init(char *av0, LogLevel level, SyslogFacility ignored1, int ignored2)
|
1999-10-27 03:42:43 +00:00
|
|
|
{
|
1999-11-11 06:57:39 +00:00
|
|
|
switch (level)
|
1999-10-27 03:42:43 +00:00
|
|
|
{
|
1999-11-11 06:57:39 +00:00
|
|
|
case SYSLOG_LEVEL_QUIET:
|
|
|
|
case SYSLOG_LEVEL_ERROR:
|
|
|
|
case SYSLOG_LEVEL_FATAL:
|
|
|
|
case SYSLOG_LEVEL_INFO:
|
|
|
|
case SYSLOG_LEVEL_CHAT:
|
|
|
|
case SYSLOG_LEVEL_DEBUG:
|
|
|
|
log_level = level;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* unchanged */
|
|
|
|
break;
|
1999-10-27 03:42:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-11-11 06:57:39 +00:00
|
|
|
#define MSGBUFSIZE 1024
|
1999-10-27 03:42:43 +00:00
|
|
|
|
1999-11-11 06:57:39 +00:00
|
|
|
void
|
|
|
|
do_log(LogLevel level, const char *fmt, va_list args)
|
1999-10-27 03:42:43 +00:00
|
|
|
{
|
1999-11-11 06:57:39 +00:00
|
|
|
char msgbuf[MSGBUFSIZE];
|
1999-10-27 03:42:43 +00:00
|
|
|
|
1999-11-11 06:57:39 +00:00
|
|
|
if (level > log_level)
|
|
|
|
return;
|
|
|
|
if (level == SYSLOG_LEVEL_DEBUG)
|
|
|
|
fprintf(stderr, "debug: ");
|
|
|
|
vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
|
|
|
|
fprintf(stderr, "%s", msgbuf);
|
1999-10-27 03:42:43 +00:00
|
|
|
fprintf(stderr, "\r\n");
|
|
|
|
}
|