Annotation of src/usr.bin/ssh/log.h, Revision 1.25
1.25 ! djm 1: /* $OpenBSD: log.h,v 1.24 2019/09/06 04:53:27 djm Exp $ */
1.2 niklas 2:
1.1 markus 3: /*
4: * Author: Tatu Ylonen <ylo@cs.hut.fi>
5: * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
6: * All rights reserved
7: *
8: * As far as I am concerned, the code I have written for this software
9: * can be used freely for any purpose. Any derived versions of this
10: * software must be clearly marked as such, and if the derived work is
11: * incompatible with the protocol description in the RFC file, it must be
12: * called by a name other than "ssh" or "Secure Shell".
13: */
14:
15: #ifndef SSH_LOG_H
16: #define SSH_LOG_H
1.24 djm 17:
18: #include <stdarg.h> /* va_list */
1.1 markus 19:
20: /* Supported syslog facilities and levels. */
21: typedef enum {
22: SYSLOG_FACILITY_DAEMON,
23: SYSLOG_FACILITY_USER,
24: SYSLOG_FACILITY_AUTH,
25: SYSLOG_FACILITY_LOCAL0,
26: SYSLOG_FACILITY_LOCAL1,
27: SYSLOG_FACILITY_LOCAL2,
28: SYSLOG_FACILITY_LOCAL3,
29: SYSLOG_FACILITY_LOCAL4,
30: SYSLOG_FACILITY_LOCAL5,
31: SYSLOG_FACILITY_LOCAL6,
1.5 markus 32: SYSLOG_FACILITY_LOCAL7,
1.7 deraadt 33: SYSLOG_FACILITY_NOT_SET = -1
1.1 markus 34: } SyslogFacility;
35:
36: typedef enum {
37: SYSLOG_LEVEL_QUIET,
38: SYSLOG_LEVEL_FATAL,
39: SYSLOG_LEVEL_ERROR,
40: SYSLOG_LEVEL_INFO,
41: SYSLOG_LEVEL_VERBOSE,
42: SYSLOG_LEVEL_DEBUG1,
43: SYSLOG_LEVEL_DEBUG2,
1.5 markus 44: SYSLOG_LEVEL_DEBUG3,
1.7 deraadt 45: SYSLOG_LEVEL_NOT_SET = -1
1.1 markus 46: } LogLevel;
47:
1.25 ! djm 48: typedef void (log_handler_fn)(const char *, const char *, int, LogLevel,
! 49: const char *, void *);
1.18 djm 50:
1.4 markus 51: void log_init(char *, LogLevel, SyslogFacility, int);
1.23 markus 52: LogLevel log_level_get(void);
1.22 djm 53: int log_change_level(LogLevel);
1.19 dtucker 54: int log_is_on_stderr(void);
1.20 dtucker 55: void log_redirect_stderr_to(const char *);
1.25 ! djm 56: void log_verbose_add(const char *);
! 57: void log_verbose_reset(void);
1.1 markus 58:
1.4 markus 59: SyslogFacility log_facility_number(char *);
1.16 dtucker 60: const char * log_facility_name(SyslogFacility);
61: LogLevel log_level_number(char *);
62: const char * log_level_name(LogLevel);
1.1 markus 63:
1.25 ! djm 64: void set_log_handler(log_handler_fn *, void *);
! 65: void cleanup_exit(int) __attribute__((noreturn));
1.4 markus 66:
1.25 ! djm 67: void sshlog(const char *, const char *, int, int,
! 68: LogLevel, const char *, ...) __attribute__((format(printf, 6, 7)));
! 69: void sshlogv(const char *, const char *, int, int,
! 70: LogLevel, const char *, va_list);
! 71: void sshsigdie(const char *, const char *, int, const char *, ...)
! 72: __attribute__((noreturn)) __attribute__((format(printf, 4, 5)));
! 73: void sshlogdie(const char *, const char *, int, const char *, ...)
! 74: __attribute__((noreturn)) __attribute__((format(printf, 4, 5)));
! 75: void sshfatal(const char *, const char *, int, const char *, ...)
! 76: __attribute__((noreturn)) __attribute__((format(printf, 4, 5)));
! 77:
! 78: #define ssh_nlog(level, ...) sshlog(__FILE__, __func__, __LINE__, 0, level, __VA_ARGS__)
! 79: #define ssh_debug3(...) sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG3, __VA_ARGS__)
! 80: #define ssh_debug2(...) sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG2, __VA_ARGS__)
! 81: #define ssh_debug(...) sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, __VA_ARGS__)
! 82: #define ssh_verbose(...) sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_VERBOSE, __VA_ARGS__)
! 83: #define ssh_log(...) sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, __VA_ARGS__)
! 84: #define ssh_error(...) sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_ERROR, __VA_ARGS__)
! 85: #define ssh_fatal(...) sshfatal(__FILE__, __func__, __LINE__, __VA_ARGS__)
! 86: #define ssh_logdie(...) sshlogdie(__FILE__, __func__, __LINE__, __VA_ARGS__)
! 87: #define ssh_sigdie(...) sshsigdie(__FILE__, __func__, __LINE__, __VA_ARGS__)
! 88:
! 89: #define debug ssh_debug
! 90: #define debug1 ssh_debug1
! 91: #define debug2 ssh_debug2
! 92: #define debug3 ssh_debug3
! 93: #define error ssh_error
! 94: #define logit ssh_log
! 95: #define verbose ssh_verbose
! 96: #define fatal ssh_fatal
! 97: #define logdie ssh_logdie
! 98: #define sigdie ssh_sigdie
! 99: #define do_log2 ssh_nlog
1.18 djm 100:
1.1 markus 101: #endif