3000
  +   ˆl–Ãa¾”ji?u@?pÜŠbÑ¿Ä„�>ï_†I|¥�+ÃÂ ?÷     /*
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, you can obtain one at https://mozilla.org/MPL/2.0/.
 *
 * See the COPYRIGHT file distributed with this work for additional
 * information regarding copyright ownership.
 */

#ifndef ISC_LOG_H
#define ISC_LOG_H 1

/*! \file isc/log.h */

#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <syslog.h> /* XXXDCL NT */

#include <isc/formatcheck.h>
#include <isc/lang.h>
#include <isc/platform.h>
#include <isc/types.h>

/*@{*/
/*!
 * \brief Severity levels, patterned after Unix's syslog levels.
 *
 */
#define ISC_LOG_DEBUG(level) (level)
/*!
 * #ISC_LOG_DYNAMIC can only be used for defining channels with
 * isc_log_createchannel(), not to specify a level in isc_log_write().
 */
#define ISC_LOG_DYNAMIC	 0
#define ISC_LOG_INFO	 (-1)
#define ISC_LOG_NOTICE	 (-2)
#define ISC_LOG_WARNING	 (-3)
#define ISC_LOG_ERROR	 (-4)
#define ISC_LOG_CRITICAL (-5)
/*@}*/

/*@{*/
/*!
 * \brief Destinations.
 */
#define ISC_LOG_TONULL	   1
#define ISC_LOG_TOSYSLOG   2
#define ISC_LOG_TOFILE	   3
#define ISC_LOG_TOFILEDESC 4
/*@}*/

/*@{*/
/*%
 * Channel flags.
 */
#define ISC_LOG_PRINTTIME     0x00001
#define ISC_LOG_PRINTLEVEL    0x00002
#define ISC_LOG_PRINTCATEGORY 0x00004
#define ISC_LOG_PRINTMODULE   0x00008
#define ISC_LOG_PRINTTAG      0x00010 /* tag and ":" */
#define ISC_LOG_PRINTPREFIX   0x00020 /* tag only, no colon */
#define ISC_LOG_PRINTALL      0x0003F
#define ISC_LOG_BUFFERED      0x00040
#define ISC_LOG_DEBUGONLY     0x01000
#define ISC_LOG_OPENERR	      0x08000 /* internal */
#define ISC_LOG_ISO8601	      0x10000 /* if PRINTTIME, use ISO8601 */
#define ISC_LOG_UTC	      0x20000 /* if PRINTTIME, use UTC */
/*@}*/

/*@{*/
/*!
 * \brief Other options.
 *
 * XXXDCL INFINITE doesn't yet work.  Arguably it isn't needed, but
 *   since I am intend to make large number of versions work efficiently,
 *   INFINITE is going to be trivial to add to that.
 */
#define ISC_LOG_ROLLINFINITE (-1)
#define ISC_LOG_ROLLNEVER    (-2)
#define ISC_LOG_MAX_VERSIONS 256
/*@}*/

/*@{*/
/*!
 * \brief Type of suffix used on rolled log files.
 */
typedef enum {
	isc_log_rollsuffix_increment,
	isc_log_rollsuffix_timestamp
} isc_log_rollsuffix_t;
/*@}*/

/*!
 * \brief Used to name the categories used by a library.
 *
 * An array of isc_logcategory
 * structures names each category, and the id value is initialized by calling
 * isc_log_registercategories.
 */
struct isc_logcategory {
	const char  *name;
	unsigned int id;
};

/*%
 * Similar to isc_logcategory, but for all the modules a library defines.
 */
struct isc_logmodule {
	const char  *name;
	unsigned int id;
};

/*%
 * The isc_logfile structure is initialized as part of an isc_logdestination
 * before calling isc_log_createchannel().
 *
 * When defining an #ISC_LOG_TOFILE
 * channel the name, versions and maximum_size should be set before calling
 * isc_log_createchannel().  To define an #ISC_LOG_TOFILEDESC channel set only
 * the stream before the call.
 *
 * Setting maximum_size to zero implies no maximum.
 */
typedef struct isc_logfile {
	FILE *stream;	      /*%< Initialized to NULL for
			       * #ISC_LOG_TOFILE. */
	const char *name;     /*%< NULL for #ISC_LOG_TOFILEDESC. */
	int	    versions; /* >= 0, #ISC_LOG_ROLLNEVER,
			       * #ISC_LOG_ROLLINFINITE. */
	isc_log_rollsuffix_t suffix;
	/*%
	 * stdio's ftell is standardized to return a long, which may well not
	 * be big enough for the largest file supportable by the operating
	 * system (though it is _probably_ big enough for the largest log
	 * anyone would want).  st_size returned by fstat should be typedef'd
	 * to a size large enough for the largest possible file on a system.
	 */
	isc_offset_t maximum_size;
	bool	     maximum_reached; /*%< Private. */
} isc_logfile_t;

/*%
 * Passed to isc_log_createchannel to define the attributes of either
 * a