From 752250caabda3dd24635503c4cd689b32a650794 Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Fri, 16 Oct 2020 13:24:45 +0000 Subject: upstream: revised log infrastructure for OpenSSH log functions receive function, filename and line number of caller. We can use this to selectively enable logging via pattern-lists. ok markus@ OpenBSD-Commit-ID: 51a472610cbe37834ce6ce4a3f0e0b1ccc95a349 --- log.h | 59 ++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 19 deletions(-) (limited to 'log.h') diff --git a/log.h b/log.h index 78cda287..b1ab7c7e 100644 --- a/log.h +++ b/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.24 2019/09/06 04:53:27 djm Exp $ */ +/* $OpenBSD: log.h,v 1.25 2020/10/16 13:24:45 djm Exp $ */ /* * Author: Tatu Ylonen @@ -48,36 +48,57 @@ typedef enum { SYSLOG_LEVEL_NOT_SET = -1 } LogLevel; -typedef void (log_handler_fn)(LogLevel, const char *, void *); +typedef void (log_handler_fn)(const char *, const char *, int, LogLevel, + const char *, void *); void log_init(char *, LogLevel, SyslogFacility, int); LogLevel log_level_get(void); int log_change_level(LogLevel); int log_is_on_stderr(void); void log_redirect_stderr_to(const char *); +void log_verbose_add(const char *); +void log_verbose_reset(void); SyslogFacility log_facility_number(char *); const char * log_facility_name(SyslogFacility); LogLevel log_level_number(char *); const char * log_level_name(LogLevel); -void fatal(const char *, ...) __attribute__((noreturn)) - __attribute__((format(printf, 1, 2))); -void error(const char *, ...) __attribute__((format(printf, 1, 2))); -void sigdie(const char *, ...) __attribute__((noreturn)) - __attribute__((format(printf, 1, 2))); -void logdie(const char *, ...) __attribute__((noreturn)) - __attribute__((format(printf, 1, 2))); -void logit(const char *, ...) __attribute__((format(printf, 1, 2))); -void verbose(const char *, ...) __attribute__((format(printf, 1, 2))); -void debug(const char *, ...) __attribute__((format(printf, 1, 2))); -void debug2(const char *, ...) __attribute__((format(printf, 1, 2))); -void debug3(const char *, ...) __attribute__((format(printf, 1, 2))); - - void set_log_handler(log_handler_fn *, void *); -void do_log2(LogLevel, const char *, ...) - __attribute__((format(printf, 2, 3))); -void do_log(LogLevel, const char *, va_list); void cleanup_exit(int) __attribute__((noreturn)); + +void sshlog(const char *, const char *, int, int, + LogLevel, const char *, ...) __attribute__((format(printf, 6, 7))); +void sshlogv(const char *, const char *, int, int, + LogLevel, const char *, va_list); +void sshsigdie(const char *, const char *, int, const char *, ...) + __attribute__((noreturn)) __attribute__((format(printf, 4, 5))); +void sshlogdie(const char *, const char *, int, const char *, ...) + __attribute__((noreturn)) __attribute__((format(printf, 4, 5))); +void sshfatal(const char *, const char *, int, const char *, ...) + __attribute__((noreturn)) __attribute__((format(printf, 4, 5))); + +#define ssh_nlog(level, ...) sshlog(__FILE__, __func__, __LINE__, 0, level, __VA_ARGS__) +#define ssh_debug3(...) sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG3, __VA_ARGS__) +#define ssh_debug2(...) sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG2, __VA_ARGS__) +#define ssh_debug(...) sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_DEBUG1, __VA_ARGS__) +#define ssh_verbose(...) sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_VERBOSE, __VA_ARGS__) +#define ssh_log(...) sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_INFO, __VA_ARGS__) +#define ssh_error(...) sshlog(__FILE__, __func__, __LINE__, 0, SYSLOG_LEVEL_ERROR, __VA_ARGS__) +#define ssh_fatal(...) sshfatal(__FILE__, __func__, __LINE__, __VA_ARGS__) +#define ssh_logdie(...) sshlogdie(__FILE__, __func__, __LINE__, __VA_ARGS__) +#define ssh_sigdie(...) sshsigdie(__FILE__, __func__, __LINE__, __VA_ARGS__) + +#define debug ssh_debug +#define debug1 ssh_debug1 +#define debug2 ssh_debug2 +#define debug3 ssh_debug3 +#define error ssh_error +#define logit ssh_log +#define verbose ssh_verbose +#define fatal ssh_fatal +#define logdie ssh_logdie +#define sigdie ssh_sigdie +#define do_log2 ssh_nlog + #endif -- cgit v1.2.3