log.h revision 248619
1248619Sdes/* $OpenBSD: log.h,v 1.19 2012/09/06 04:37:39 dtucker Exp $ */
276259Sgreen
376259Sgreen/*
476259Sgreen * Author: Tatu Ylonen <ylo@cs.hut.fi>
576259Sgreen * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
676259Sgreen *                    All rights reserved
776259Sgreen *
876259Sgreen * As far as I am concerned, the code I have written for this software
976259Sgreen * can be used freely for any purpose.  Any derived versions of this
1076259Sgreen * software must be clearly marked as such, and if the derived work is
1176259Sgreen * incompatible with the protocol description in the RFC file, it must be
1276259Sgreen * called by a name other than "ssh" or "Secure Shell".
1376259Sgreen */
1476259Sgreen
1576259Sgreen#ifndef SSH_LOG_H
1676259Sgreen#define SSH_LOG_H
1776259Sgreen
1876259Sgreen/* Supported syslog facilities and levels. */
1976259Sgreentypedef enum {
2076259Sgreen	SYSLOG_FACILITY_DAEMON,
2176259Sgreen	SYSLOG_FACILITY_USER,
2276259Sgreen	SYSLOG_FACILITY_AUTH,
2398937Sdes#ifdef LOG_AUTHPRIV
2498937Sdes	SYSLOG_FACILITY_AUTHPRIV,
2598937Sdes#endif
2676259Sgreen	SYSLOG_FACILITY_LOCAL0,
2776259Sgreen	SYSLOG_FACILITY_LOCAL1,
2876259Sgreen	SYSLOG_FACILITY_LOCAL2,
2976259Sgreen	SYSLOG_FACILITY_LOCAL3,
3076259Sgreen	SYSLOG_FACILITY_LOCAL4,
3176259Sgreen	SYSLOG_FACILITY_LOCAL5,
3276259Sgreen	SYSLOG_FACILITY_LOCAL6,
3392555Sdes	SYSLOG_FACILITY_LOCAL7,
3498675Sdes	SYSLOG_FACILITY_NOT_SET = -1
3576259Sgreen}       SyslogFacility;
3676259Sgreen
3776259Sgreentypedef enum {
3876259Sgreen	SYSLOG_LEVEL_QUIET,
3976259Sgreen	SYSLOG_LEVEL_FATAL,
4076259Sgreen	SYSLOG_LEVEL_ERROR,
4176259Sgreen	SYSLOG_LEVEL_INFO,
4276259Sgreen	SYSLOG_LEVEL_VERBOSE,
4376259Sgreen	SYSLOG_LEVEL_DEBUG1,
4476259Sgreen	SYSLOG_LEVEL_DEBUG2,
4592555Sdes	SYSLOG_LEVEL_DEBUG3,
4698675Sdes	SYSLOG_LEVEL_NOT_SET = -1
4776259Sgreen}       LogLevel;
4876259Sgreen
49226046Sdestypedef void (log_handler_fn)(LogLevel, const char *, void *);
50226046Sdes
5192555Sdesvoid     log_init(char *, LogLevel, SyslogFacility, int);
52248619Sdesvoid     log_change_level(LogLevel);
53248619Sdesint      log_is_on_stderr(void);
5476259Sgreen
5592555SdesSyslogFacility	log_facility_number(char *);
56181111Sdesconst char * 	log_facility_name(SyslogFacility);
57181111SdesLogLevel	log_level_number(char *);
58181111Sdesconst char *	log_level_name(LogLevel);
5976259Sgreen
60181111Sdesvoid     fatal(const char *, ...) __attribute__((noreturn))
61181111Sdes    __attribute__((format(printf, 1, 2)));
62114972Sdesvoid     error(const char *, ...) __attribute__((format(printf, 1, 2)));
63181111Sdesvoid     sigdie(const char *, ...)  __attribute__((noreturn))
64181111Sdes    __attribute__((format(printf, 1, 2)));
65124211Sdesvoid     logit(const char *, ...) __attribute__((format(printf, 1, 2)));
66114972Sdesvoid     verbose(const char *, ...) __attribute__((format(printf, 1, 2)));
67114972Sdesvoid     debug(const char *, ...) __attribute__((format(printf, 1, 2)));
68114972Sdesvoid     debug2(const char *, ...) __attribute__((format(printf, 1, 2)));
69114972Sdesvoid     debug3(const char *, ...) __attribute__((format(printf, 1, 2)));
70114955Sdes
71226046Sdes
72226046Sdesvoid	 set_log_handler(log_handler_fn *, void *);
73226046Sdesvoid	 do_log2(LogLevel, const char *, ...)
74226046Sdes    __attribute__((format(printf, 2, 3)));
7592555Sdesvoid	 do_log(LogLevel, const char *, va_list);
76181111Sdesvoid	 cleanup_exit(int) __attribute__((noreturn));
7776259Sgreen#endif
78