[BACK]Return to log-client.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Annotation of src/usr.bin/ssh/log-client.c, Revision 1.7

1.1       deraadt     1: /*
1.6       deraadt     2:  *
                      3:  * log-client.c
                      4:  *
                      5:  * Author: Tatu Ylonen <ylo@cs.hut.fi>
                      6:  *
                      7:  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
                      8:  *                    All rights reserved
                      9:  *
                     10:  * Created: Mon Mar 20 21:13:40 1995 ylo
                     11:  *
                     12:  * Client-side versions of debug(), log(), etc.  These print to stderr.
                     13:  * This is a stripped down version of log-server.c.
                     14:  *
                     15:  */
1.1       deraadt    16:
                     17: #include "includes.h"
1.7     ! deraadt    18: RCSID("$Id: log-client.c,v 1.6 1999/11/24 00:26:02 deraadt Exp $");
1.1       deraadt    19:
                     20: #include "xmalloc.h"
                     21: #include "ssh.h"
                     22:
1.3       markus     23: static LogLevel log_level = SYSLOG_LEVEL_INFO;
1.1       deraadt    24:
1.3       markus     25: /* Initialize the log.
1.5       markus     26:  *   av0       program name (should be argv[0])
                     27:  *   level     logging level
                     28:  */
1.1       deraadt    29:
1.3       markus     30: void
                     31: log_init(char *av0, LogLevel level, SyslogFacility ignored1, int ignored2)
1.1       deraadt    32: {
1.5       markus     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:        }
1.1       deraadt    46: }
                     47:
1.7     ! deraadt    48: #define MSGBUFSIZ 1024
1.1       deraadt    49:
1.3       markus     50: void
                     51: do_log(LogLevel level, const char *fmt, va_list args)
1.1       deraadt    52: {
1.7     ! deraadt    53:        char msgbuf[MSGBUFSIZ];
1.1       deraadt    54:
1.5       markus     55:        if (level > log_level)
                     56:                return;
                     57:        if (level == SYSLOG_LEVEL_DEBUG)
                     58:                fprintf(stderr, "debug: ");
                     59:        vsnprintf(msgbuf, sizeof(msgbuf), fmt, args);
                     60:        fprintf(stderr, "%s", msgbuf);
                     61:        fprintf(stderr, "\r\n");
1.1       deraadt    62: }