10Sstevel@tonic-gate /* 2*11038SRao.Shoaib@Sun.COM * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") 30Sstevel@tonic-gate * Copyright (c) 1996-1999 by Internet Software Consortium. 40Sstevel@tonic-gate * 50Sstevel@tonic-gate * Permission to use, copy, modify, and distribute this software for any 60Sstevel@tonic-gate * purpose with or without fee is hereby granted, provided that the above 70Sstevel@tonic-gate * copyright notice and this permission notice appear in all copies. 80Sstevel@tonic-gate * 9*11038SRao.Shoaib@Sun.COM * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES 10*11038SRao.Shoaib@Sun.COM * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11*11038SRao.Shoaib@Sun.COM * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR 12*11038SRao.Shoaib@Sun.COM * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13*11038SRao.Shoaib@Sun.COM * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14*11038SRao.Shoaib@Sun.COM * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 15*11038SRao.Shoaib@Sun.COM * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 160Sstevel@tonic-gate */ 170Sstevel@tonic-gate 180Sstevel@tonic-gate #ifndef LOGGING_H 190Sstevel@tonic-gate #define LOGGING_H 200Sstevel@tonic-gate 210Sstevel@tonic-gate #include <sys/types.h> 220Sstevel@tonic-gate #include <stdio.h> 230Sstevel@tonic-gate #include <stdarg.h> 240Sstevel@tonic-gate #include <unistd.h> 250Sstevel@tonic-gate 260Sstevel@tonic-gate #define log_critical (-5) 270Sstevel@tonic-gate #define log_error (-4) 280Sstevel@tonic-gate #define log_warning (-3) 290Sstevel@tonic-gate #define log_notice (-2) 300Sstevel@tonic-gate #define log_info (-1) 310Sstevel@tonic-gate #define log_debug(level) (level) 320Sstevel@tonic-gate 330Sstevel@tonic-gate typedef enum { log_syslog, log_file, log_null } log_channel_type; 340Sstevel@tonic-gate 350Sstevel@tonic-gate #define LOG_MAX_VERSIONS 99 360Sstevel@tonic-gate 370Sstevel@tonic-gate #define LOG_CLOSE_STREAM 0x0001 380Sstevel@tonic-gate #define LOG_TIMESTAMP 0x0002 390Sstevel@tonic-gate #define LOG_TRUNCATE 0x0004 400Sstevel@tonic-gate #define LOG_USE_CONTEXT_LEVEL 0x0008 410Sstevel@tonic-gate #define LOG_PRINT_LEVEL 0x0010 420Sstevel@tonic-gate #define LOG_REQUIRE_DEBUG 0x0020 430Sstevel@tonic-gate #define LOG_CHANNEL_BROKEN 0x0040 440Sstevel@tonic-gate #define LOG_PRINT_CATEGORY 0x0080 450Sstevel@tonic-gate #define LOG_CHANNEL_OFF 0x0100 460Sstevel@tonic-gate 470Sstevel@tonic-gate typedef struct log_context *log_context; 480Sstevel@tonic-gate typedef struct log_channel *log_channel; 490Sstevel@tonic-gate 500Sstevel@tonic-gate #define LOG_OPTION_DEBUG 0x01 510Sstevel@tonic-gate #define LOG_OPTION_LEVEL 0x02 520Sstevel@tonic-gate 530Sstevel@tonic-gate #define log_open_stream __log_open_stream 540Sstevel@tonic-gate #define log_close_stream __log_close_stream 550Sstevel@tonic-gate #define log_get_stream __log_get_stream 560Sstevel@tonic-gate #define log_get_filename __log_get_filename 570Sstevel@tonic-gate #define log_check_channel __log_check_channel 580Sstevel@tonic-gate #define log_check __log_check 590Sstevel@tonic-gate #define log_vwrite __log_vwrite 600Sstevel@tonic-gate #define log_write __log_write 610Sstevel@tonic-gate #define log_new_context __log_new_context 620Sstevel@tonic-gate #define log_free_context __log_free_context 630Sstevel@tonic-gate #define log_add_channel __log_add_channel 640Sstevel@tonic-gate #define log_remove_channel __log_remove_channel 650Sstevel@tonic-gate #define log_option __log_option 660Sstevel@tonic-gate #define log_category_is_active __log_category_is_active 670Sstevel@tonic-gate #define log_new_syslog_channel __log_new_syslog_channel 680Sstevel@tonic-gate #define log_new_file_channel __log_new_file_channel 690Sstevel@tonic-gate #define log_set_file_owner __log_set_file_owner 700Sstevel@tonic-gate #define log_new_null_channel __log_new_null_channel 710Sstevel@tonic-gate #define log_inc_references __log_inc_references 720Sstevel@tonic-gate #define log_dec_references __log_dec_references 730Sstevel@tonic-gate #define log_get_channel_type __log_get_channel_type 740Sstevel@tonic-gate #define log_free_channel __log_free_channel 750Sstevel@tonic-gate #define log_close_debug_channels __log_close_debug_channels 760Sstevel@tonic-gate 770Sstevel@tonic-gate FILE * log_open_stream(log_channel); 780Sstevel@tonic-gate int log_close_stream(log_channel); 790Sstevel@tonic-gate FILE * log_get_stream(log_channel); 800Sstevel@tonic-gate char * log_get_filename(log_channel); 810Sstevel@tonic-gate int log_check_channel(log_context, int, log_channel); 820Sstevel@tonic-gate int log_check(log_context, int, int); 830Sstevel@tonic-gate #ifdef __GNUC__ 840Sstevel@tonic-gate void log_vwrite(log_context, int, int, const char *, 850Sstevel@tonic-gate va_list args) 860Sstevel@tonic-gate __attribute__((__format__(__printf__, 4, 0))); 870Sstevel@tonic-gate void log_write(log_context, int, int, const char *, ...) 880Sstevel@tonic-gate __attribute__((__format__(__printf__, 4, 5))); 890Sstevel@tonic-gate #else 900Sstevel@tonic-gate void log_vwrite(log_context, int, int, const char *, 910Sstevel@tonic-gate va_list args); 920Sstevel@tonic-gate void log_write(log_context, int, int, const char *, ...); 930Sstevel@tonic-gate #endif 940Sstevel@tonic-gate int log_new_context(int, char **, log_context *); 950Sstevel@tonic-gate void log_free_context(log_context); 960Sstevel@tonic-gate int log_add_channel(log_context, int, log_channel); 970Sstevel@tonic-gate int log_remove_channel(log_context, int, log_channel); 980Sstevel@tonic-gate int log_option(log_context, int, int); 990Sstevel@tonic-gate int log_category_is_active(log_context, int); 1000Sstevel@tonic-gate log_channel log_new_syslog_channel(unsigned int, int, int); 1010Sstevel@tonic-gate log_channel log_new_file_channel(unsigned int, int, const char *, 1020Sstevel@tonic-gate FILE *, unsigned int, 1030Sstevel@tonic-gate unsigned long); 1040Sstevel@tonic-gate int log_set_file_owner(log_channel, uid_t, gid_t); 1050Sstevel@tonic-gate log_channel log_new_null_channel(void); 1060Sstevel@tonic-gate int log_inc_references(log_channel); 1070Sstevel@tonic-gate int log_dec_references(log_channel); 1080Sstevel@tonic-gate log_channel_type log_get_channel_type(log_channel); 1090Sstevel@tonic-gate int log_free_channel(log_channel); 1100Sstevel@tonic-gate void log_close_debug_channels(log_context); 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate #endif /* !LOGGING_H */ 113*11038SRao.Shoaib@Sun.COM /*! \file */ 114