1255767Sdes/* $OpenBSD: log.h,v 1.20 2013/04/07 02:10:33 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);
54255767Sdesvoid     log_redirect_stderr_to(const char *);
5576259Sgreen
5692555SdesSyslogFacility	log_facility_number(char *);
57181111Sdesconst char * 	log_facility_name(SyslogFacility);
58181111SdesLogLevel	log_level_number(char *);
59181111Sdesconst char *	log_level_name(LogLevel);
6076259Sgreen
61181111Sdesvoid     fatal(const char *, ...) __attribute__((noreturn))
62181111Sdes    __attribute__((format(printf, 1, 2)));
63114972Sdesvoid     error(const char *, ...) __attribute__((format(printf, 1, 2)));
64181111Sdesvoid     sigdie(const char *, ...)  __attribute__((noreturn))
65181111Sdes    __attribute__((format(printf, 1, 2)));
66124211Sdesvoid     logit(const char *, ...) __attribute__((format(printf, 1, 2)));
67114972Sdesvoid     verbose(const char *, ...) __attribute__((format(printf, 1, 2)));
68114972Sdesvoid     debug(const char *, ...) __attribute__((format(printf, 1, 2)));
69114972Sdesvoid     debug2(const char *, ...) __attribute__((format(printf, 1, 2)));
70114972Sdesvoid     debug3(const char *, ...) __attribute__((format(printf, 1, 2)));
71114955Sdes
72226046Sdes
73226046Sdesvoid	 set_log_handler(log_handler_fn *, void *);
74226046Sdesvoid	 do_log2(LogLevel, const char *, ...)
75226046Sdes    __attribute__((format(printf, 2, 3)));
7692555Sdesvoid	 do_log(LogLevel, const char *, va_list);
77181111Sdesvoid	 cleanup_exit(int) __attribute__((noreturn));
7876259Sgreen#endif
79