log.h revision 6a8832f784bd53aa6afbda22f6187cea6490e1e1
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User * Copyright (C) 1999-2001 Internet Software Consortium.
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User * Permission to use, copy, modify, and distribute this software for any
5347c0fcb04eaea19d9f39795646239f487c6207Tinderbox User * purpose with or without fee is hereby granted, provided that the above
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User * copyright notice and this permission notice appear in all copies.
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
164ade1482251e1da962b42e5bf0d3aa02a11e03Tinderbox User/* $Id: log.h,v 1.41 2002/02/20 01:44:09 gson Exp $ */
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt * Severity levels, patterned after Unix's syslog levels.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt * ISC_LOG_DYNAMIC can only be used for defining channels with
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * isc_log_createchannel(), not to specify a level in isc_log_write().
33c9436ef1a43d3c0fc3d9be9b4b0509daa83223Tinderbox User * Destinations.
33c9436ef1a43d3c0fc3d9be9b4b0509daa83223Tinderbox User * Channel flags.
33c9436ef1a43d3c0fc3d9be9b4b0509daa83223Tinderbox User * Other options.
33c9436ef1a43d3c0fc3d9be9b4b0509daa83223Tinderbox User * XXXDCL INFINITE doesn't yet work. Arguably it isn't needed, but
33c9436ef1a43d3c0fc3d9be9b4b0509daa83223Tinderbox User * since I am intend to make large number of versions work efficiently,
33c9436ef1a43d3c0fc3d9be9b4b0509daa83223Tinderbox User * INFINITE is going to be trivial to add to that.
a1ff871f78b7d907d6fc3a382beea2a640fe8423Tinderbox User * Used to name the categories used by a library. An array of isc_logcategory
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * structures names each category, and the id value is initialized by calling
0da02c26a6631c25f075a8e4ac6de9e58f49a0c2Tinderbox User * isc_log_registercategories.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User unsigned int id;
8a48b6b9b6fa8486f24b22d1972b2b6ebb36a4a4Tinderbox User * Similar to isc_logcategory above, but for all the modules a library defines.
8a48b6b9b6fa8486f24b22d1972b2b6ebb36a4a4Tinderbox User unsigned int id;
8a48b6b9b6fa8486f24b22d1972b2b6ebb36a4a4Tinderbox User * The isc_logfile structure is initialized as part of an isc_logdestination
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * before calling isc_log_createchannel(). When defining an ISC_LOG_TOFILE
8a48b6b9b6fa8486f24b22d1972b2b6ebb36a4a4Tinderbox User * channel the name, versions and maximum_size should be set before calling
8a48b6b9b6fa8486f24b22d1972b2b6ebb36a4a4Tinderbox User * isc_log_createchannel(). To define an ISC_LOG_TOFILEDESC channel set only
8a48b6b9b6fa8486f24b22d1972b2b6ebb36a4a4Tinderbox User * the stream before the call.
8a48b6b9b6fa8486f24b22d1972b2b6ebb36a4a4Tinderbox Usertypedef struct isc_logfile {
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User FILE *stream; /* Initialized to NULL for ISC_LOG_TOFILE. */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User const char *name; /* NULL for ISC_LOG_TOFILEDESC. */
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User int versions; /* >= 0, ISC_LOG_ROLLNEVER, ISC_LOG_ROLLINFINITE. */
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt * stdio's ftell is standardized to return a long, which may well not
164ade1482251e1da962b42e5bf0d3aa02a11e03Tinderbox User * be big enough for the largest file supportable by the operating
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * system (though it is _probably_ big enough for the largest log
164ade1482251e1da962b42e5bf0d3aa02a11e03Tinderbox User * anyone would want). st_size returned by fstat should be typedef'd
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * to a size large enough for the largest possible file on a system.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User isc_boolean_t maximum_reached; /* Private. */
abe69df9a7de5cda07a2b8e19e8b7c981bcd7a9dTinderbox User * Passed to isc_log_createchannel to define the attributes of either
abe69df9a7de5cda07a2b8e19e8b7c981bcd7a9dTinderbox User * a stdio or a syslog log.
abe69df9a7de5cda07a2b8e19e8b7c981bcd7a9dTinderbox User * The built-in categories of libisc.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Each library registering categories should provide library_LOGCATEGORY_name
164ade1482251e1da962b42e5bf0d3aa02a11e03Tinderbox User * definitions with indexes into its isc_logcategory structure corresponding to
164ade1482251e1da962b42e5bf0d3aa02a11e03Tinderbox User * the order of the names.
164ade1482251e1da962b42e5bf0d3aa02a11e03Tinderbox UserLIBISC_EXTERNAL_DATA extern isc_logcategory_t isc_categories[];
164ade1482251e1da962b42e5bf0d3aa02a11e03Tinderbox UserLIBISC_EXTERNAL_DATA extern isc_log_t *isc_lctx;
164ade1482251e1da962b42e5bf0d3aa02a11e03Tinderbox UserLIBISC_EXTERNAL_DATA extern isc_logmodule_t isc_modules[];
abe69df9a7de5cda07a2b8e19e8b7c981bcd7a9dTinderbox User * Do not log directly to DEFAULT. Use another category. When in doubt,
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * use GENERAL.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User#define ISC_LOGCATEGORY_DEFAULT (&isc_categories[0])
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt#define ISC_LOGCATEGORY_GENERAL (&isc_categories[1])
99b30e26a6beb9092557cc9e5370b517309bff6eTinderbox User#define ISC_LOGMODULE_SOCKET (&isc_modules[0])
3b15473cedf41d48904f5b07bdc5e87afff6b58cTinderbox Userisc_log_create(isc_mem_t *mctx, isc_log_t **lctxp, isc_logconfig_t **lcfgp);
3b15473cedf41d48904f5b07bdc5e87afff6b58cTinderbox User * Establish a new logging context, with default channels.
99b30e26a6beb9092557cc9e5370b517309bff6eTinderbox User * isc_log_create calls isc_logconfig_create, so see its comment
99b30e26a6beb9092557cc9e5370b517309bff6eTinderbox User * below for more information.
99b30e26a6beb9092557cc9e5370b517309bff6eTinderbox User * mctx is a valid memory context.
99b30e26a6beb9092557cc9e5370b517309bff6eTinderbox User * lctxp is not null and *lctxp is null.
99b30e26a6beb9092557cc9e5370b517309bff6eTinderbox User * lcfgp is null or lcfgp is not null and *lcfgp is null.
ffe29868b4bbc64953fc5d0de51f988c20158967Tinderbox User * *lctxp will point to a valid logging context if all of the necessary
ffe29868b4bbc64953fc5d0de51f988c20158967Tinderbox User * memory was allocated, or NULL otherwise.
ffe29868b4bbc64953fc5d0de51f988c20158967Tinderbox User * *lcfgp will point to a valid logging configuration if all of the
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt * necessary memory was allocated, or NULL otherwise.
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * On failure, no additional memory is allocated.
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * ISC_R_SUCCESS Success
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt * ISC_R_NOMEMORY Resource limit: Out of memory
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Huntisc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp);
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * Create the data structure that holds all of the configurable information
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt * about where messages are actually supposed to be sent -- the information
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt * that could changed based on some configuration file, as opposed to the
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt * the category/module specification of isc_log_[v]write[1] that is compiled
fd2597f75693a2279fdf588bd40dfe2407c42028Tinderbox User * into a program, or the debug_level which is dynamic state information.
14a656f94b1fd0ababd84a772228dfa52276ba15Evan Hunt * It is necessary to specify the logging context the configuration
7911e6f9de303bca5a3d8b34f4330c8f7cecffaeTinderbox User * will be used with because the number of categories and modules
1c57c3f79db0bf0358bbe6d7b5ad650c0c852f4bTinderbox User * needs to be known in order to set the configuration. However,
unsigned int flags);
const char *format, ...)
const char *format, ...)
const char *format, ...)