xref: /openssh-portable/log.h (revision 16ae3d0d)
1*16ae3d0dSBen Lindstrom /*	$OpenBSD: log.h,v 1.3 2001/06/26 06:32:55 itojun Exp $	*/
236579d3dSBen Lindstrom 
3226cfa03SBen Lindstrom /*
4226cfa03SBen Lindstrom  * Author: Tatu Ylonen <ylo@cs.hut.fi>
5226cfa03SBen Lindstrom  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
6226cfa03SBen Lindstrom  *                    All rights reserved
7226cfa03SBen Lindstrom  *
8226cfa03SBen Lindstrom  * As far as I am concerned, the code I have written for this software
9226cfa03SBen Lindstrom  * can be used freely for any purpose.  Any derived versions of this
10226cfa03SBen Lindstrom  * software must be clearly marked as such, and if the derived work is
11226cfa03SBen Lindstrom  * incompatible with the protocol description in the RFC file, it must be
12226cfa03SBen Lindstrom  * called by a name other than "ssh" or "Secure Shell".
13226cfa03SBen Lindstrom  */
14226cfa03SBen Lindstrom 
15226cfa03SBen Lindstrom #ifndef SSH_LOG_H
16226cfa03SBen Lindstrom #define SSH_LOG_H
17226cfa03SBen Lindstrom 
1830246a8fSDamien Miller #include <syslog.h> /* Needed for LOG_AUTHPRIV (if present) */
1930246a8fSDamien Miller 
20226cfa03SBen Lindstrom /* Supported syslog facilities and levels. */
21226cfa03SBen Lindstrom typedef enum {
22226cfa03SBen Lindstrom 	SYSLOG_FACILITY_DAEMON,
23226cfa03SBen Lindstrom 	SYSLOG_FACILITY_USER,
24226cfa03SBen Lindstrom 	SYSLOG_FACILITY_AUTH,
25226cfa03SBen Lindstrom #ifdef LOG_AUTHPRIV
26226cfa03SBen Lindstrom 	SYSLOG_FACILITY_AUTHPRIV,
27226cfa03SBen Lindstrom #endif
28226cfa03SBen Lindstrom 	SYSLOG_FACILITY_LOCAL0,
29226cfa03SBen Lindstrom 	SYSLOG_FACILITY_LOCAL1,
30226cfa03SBen Lindstrom 	SYSLOG_FACILITY_LOCAL2,
31226cfa03SBen Lindstrom 	SYSLOG_FACILITY_LOCAL3,
32226cfa03SBen Lindstrom 	SYSLOG_FACILITY_LOCAL4,
33226cfa03SBen Lindstrom 	SYSLOG_FACILITY_LOCAL5,
34226cfa03SBen Lindstrom 	SYSLOG_FACILITY_LOCAL6,
35226cfa03SBen Lindstrom 	SYSLOG_FACILITY_LOCAL7
36226cfa03SBen Lindstrom }       SyslogFacility;
37226cfa03SBen Lindstrom 
38226cfa03SBen Lindstrom typedef enum {
39226cfa03SBen Lindstrom 	SYSLOG_LEVEL_QUIET,
40226cfa03SBen Lindstrom 	SYSLOG_LEVEL_FATAL,
41226cfa03SBen Lindstrom 	SYSLOG_LEVEL_ERROR,
42226cfa03SBen Lindstrom 	SYSLOG_LEVEL_INFO,
43226cfa03SBen Lindstrom 	SYSLOG_LEVEL_VERBOSE,
44226cfa03SBen Lindstrom 	SYSLOG_LEVEL_DEBUG1,
45226cfa03SBen Lindstrom 	SYSLOG_LEVEL_DEBUG2,
46226cfa03SBen Lindstrom 	SYSLOG_LEVEL_DEBUG3
47226cfa03SBen Lindstrom }       LogLevel;
48226cfa03SBen Lindstrom /* Initializes logging. */
49*16ae3d0dSBen Lindstrom void    log_init(char *, LogLevel, SyslogFacility, int);
50226cfa03SBen Lindstrom 
51226cfa03SBen Lindstrom /* Logging implementation, depending on server or client */
52*16ae3d0dSBen Lindstrom void    do_log(LogLevel, const char *, va_list);
53226cfa03SBen Lindstrom 
54226cfa03SBen Lindstrom /* name to facility/level */
55*16ae3d0dSBen Lindstrom SyslogFacility log_facility_number(char *);
56*16ae3d0dSBen Lindstrom LogLevel log_level_number(char *);
57226cfa03SBen Lindstrom 
58226cfa03SBen Lindstrom /* Output a message to syslog or stderr */
59*16ae3d0dSBen Lindstrom void    fatal(const char *, ...) __attribute__((format(printf, 1, 2)));
60*16ae3d0dSBen Lindstrom void    error(const char *, ...) __attribute__((format(printf, 1, 2)));
61*16ae3d0dSBen Lindstrom void    log(const char *, ...) __attribute__((format(printf, 1, 2)));
62*16ae3d0dSBen Lindstrom void    verbose(const char *, ...) __attribute__((format(printf, 1, 2)));
63*16ae3d0dSBen Lindstrom void    debug(const char *, ...) __attribute__((format(printf, 1, 2)));
64*16ae3d0dSBen Lindstrom void    debug2(const char *, ...) __attribute__((format(printf, 1, 2)));
65*16ae3d0dSBen Lindstrom void    debug3(const char *, ...) __attribute__((format(printf, 1, 2)));
66226cfa03SBen Lindstrom 
67226cfa03SBen Lindstrom /* same as fatal() but w/o logging */
68226cfa03SBen Lindstrom void    fatal_cleanup(void);
69226cfa03SBen Lindstrom 
70226cfa03SBen Lindstrom /*
71226cfa03SBen Lindstrom  * Registers a cleanup function to be called by fatal()/fatal_cleanup()
72226cfa03SBen Lindstrom  * before exiting. It is permissible to call fatal_remove_cleanup for the
73226cfa03SBen Lindstrom  * function itself from the function.
74226cfa03SBen Lindstrom  */
75*16ae3d0dSBen Lindstrom void    fatal_add_cleanup(void (*) (void *), void *);
76226cfa03SBen Lindstrom 
77226cfa03SBen Lindstrom /* Removes a cleanup function to be called at fatal(). */
78*16ae3d0dSBen Lindstrom void    fatal_remove_cleanup(void (*) (void *), void *);
79226cfa03SBen Lindstrom 
80226cfa03SBen Lindstrom #endif
81