]> andersk Git - openssh.git/blame - log-client.c
- (djm) Pick up LOGIN_PROGRAM from environment or PATH if not set by headers
[openssh.git] / log-client.c
CommitLineData
8efc0c15 1/*
6ae2364d 2 *
5260325f 3 * log-client.c
6ae2364d 4 *
5260325f 5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6ae2364d 6 *
5260325f 7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved
6ae2364d 9 *
5260325f 10 * Created: Mon Mar 20 21:13:40 1995 ylo
6ae2364d 11 *
5260325f 12 * Client-side versions of debug(), log(), etc. These print to stderr.
13 * This is a stripped down version of log-server.c.
6ae2364d 14 *
5260325f 15 */
8efc0c15 16
17#include "includes.h"
2e73a022 18RCSID("$OpenBSD: log-client.c,v 1.10 2000/08/19 02:57:33 deraadt Exp $");
8efc0c15 19
20#include "xmalloc.h"
21#include "ssh.h"
22
6a17f9c2 23static LogLevel log_level = SYSLOG_LEVEL_INFO;
8efc0c15 24
6a17f9c2 25/* Initialize the log.
5260325f 26 * av0 program name (should be argv[0])
27 * level logging level
28 */
8efc0c15 29
6a17f9c2 30void
31log_init(char *av0, LogLevel level, SyslogFacility ignored1, int ignored2)
8efc0c15 32{
5260325f 33 switch (level) {
34 case SYSLOG_LEVEL_QUIET:
35 case SYSLOG_LEVEL_ERROR:
36 case SYSLOG_LEVEL_FATAL:
37 case SYSLOG_LEVEL_INFO:
38 case SYSLOG_LEVEL_VERBOSE:
39 case SYSLOG_LEVEL_DEBUG:
40 log_level = level;
41 break;
42 default:
43 /* unchanged */
44 break;
45 }
8efc0c15 46}
47
c8d54615 48#define MSGBUFSIZ 1024
8efc0c15 49
6a17f9c2 50void
51do_log(LogLevel level, const char *fmt, va_list args)
8efc0c15 52{
c8d54615 53 char msgbuf[MSGBUFSIZ];
5260325f 54
55 if (level > log_level)
56 return;
57 if (level == SYSLOG_LEVEL_DEBUG)
58 fprintf(stderr, "debug: ");
59 vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
2e73a022 60 fprintf(stderr, "%s\r\n", msgbuf);
8efc0c15 61}
This page took 0.087764 seconds and 5 git commands to generate.