logging.h revision 2
2N/A/*
2N/A * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
2N/A * Copyright (c) 1996-1999 by Internet Software Consortium.
2N/A *
2N/A * Permission to use, copy, modify, and distribute this software for any
2N/A * purpose with or without fee is hereby granted, provided that the above
2N/A * copyright notice and this permission notice appear in all copies.
2N/A *
2N/A * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
2N/A * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
2N/A * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
2N/A * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
2N/A * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
2N/A * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
2N/A * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2N/A */
2N/A
2N/A#ifndef LOGGING_H
2N/A#define LOGGING_H
2N/A
2N/A#include <sys/types.h>
2N/A#include <stdio.h>
2N/A#include <stdarg.h>
2N/A#include <unistd.h>
2N/A
2N/A#define log_critical (-5)
2N/A#define log_error (-4)
2N/A#define log_warning (-3)
2N/A#define log_notice (-2)
2N/A#define log_info (-1)
2N/A#define log_debug(level) (level)
2N/A
2N/Atypedef enum { log_syslog, log_file, log_null } log_channel_type;
2N/A
2N/A#define LOG_MAX_VERSIONS 99
2N/A
2N/A#define LOG_CLOSE_STREAM 0x0001
2N/A#define LOG_TIMESTAMP 0x0002
2N/A#define LOG_TRUNCATE 0x0004
2N/A#define LOG_USE_CONTEXT_LEVEL 0x0008
2N/A#define LOG_PRINT_LEVEL 0x0010
2N/A#define LOG_REQUIRE_DEBUG 0x0020
2N/A#define LOG_CHANNEL_BROKEN 0x0040
2N/A#define LOG_PRINT_CATEGORY 0x0080
2N/A#define LOG_CHANNEL_OFF 0x0100
2N/A
2N/Atypedef struct log_context *log_context;
2N/Atypedef struct log_channel *log_channel;
2N/A
2N/A#define LOG_OPTION_DEBUG 0x01
2N/A#define LOG_OPTION_LEVEL 0x02
2N/A
2N/A#define log_open_stream __log_open_stream
2N/A#define log_close_stream __log_close_stream
2N/A#define log_get_stream __log_get_stream
2N/A#define log_get_filename __log_get_filename
2N/A#define log_check_channel __log_check_channel
2N/A#define log_check __log_check
2N/A#define log_vwrite __log_vwrite
2N/A#define log_write __log_write
2N/A#define log_new_context __log_new_context
2N/A#define log_free_context __log_free_context
2N/A#define log_add_channel __log_add_channel
2N/A#define log_remove_channel __log_remove_channel
2N/A#define log_option __log_option
2N/A#define log_category_is_active __log_category_is_active
2N/A#define log_new_syslog_channel __log_new_syslog_channel
2N/A#define log_new_file_channel __log_new_file_channel
2N/A#define log_set_file_owner __log_set_file_owner
2N/A#define log_new_null_channel __log_new_null_channel
2N/A#define log_inc_references __log_inc_references
2N/A#define log_dec_references __log_dec_references
2N/A#define log_get_channel_type __log_get_channel_type
2N/A#define log_free_channel __log_free_channel
2N/A#define log_close_debug_channels __log_close_debug_channels
2N/A
2N/AFILE * log_open_stream(log_channel);
2N/Aint log_close_stream(log_channel);
2N/AFILE * log_get_stream(log_channel);
2N/Achar * log_get_filename(log_channel);
2N/Aint log_check_channel(log_context, int, log_channel);
2N/Aint log_check(log_context, int, int);
2N/A#ifdef __GNUC__
2N/Avoid log_vwrite(log_context, int, int, const char *,
2N/A va_list args)
2N/A __attribute__((__format__(__printf__, 4, 0)));
2N/Avoid log_write(log_context, int, int, const char *, ...)
2N/A __attribute__((__format__(__printf__, 4, 5)));
2N/A#else
2N/Avoid log_vwrite(log_context, int, int, const char *,
2N/A va_list args);
2N/Avoid log_write(log_context, int, int, const char *, ...);
2N/A#endif
2N/Aint log_new_context(int, char **, log_context *);
2N/Avoid log_free_context(log_context);
2N/Aint log_add_channel(log_context, int, log_channel);
2N/Aint log_remove_channel(log_context, int, log_channel);
2N/Aint log_option(log_context, int, int);
2N/Aint log_category_is_active(log_context, int);
2N/Alog_channel log_new_syslog_channel(unsigned int, int, int);
2N/Alog_channel log_new_file_channel(unsigned int, int, const char *,
2N/A FILE *, unsigned int,
2N/A unsigned long);
2N/Aint log_set_file_owner(log_channel, uid_t, gid_t);
2N/Alog_channel log_new_null_channel(void);
2N/Aint log_inc_references(log_channel);
2N/Aint log_dec_references(log_channel);
2N/Alog_channel_type log_get_channel_type(log_channel);
2N/Aint log_free_channel(log_channel);
2N/Avoid log_close_debug_channels(log_context);
2N/A
2N/A#endif /* !LOGGING_H */
2N/A/*! \file */