xref: /titanic_52/usr/src/lib/libresolv2/include/isc/logging.h (revision 9525b14bcdeb5b5f6f95ab27c2f48f18bd2ec829)
17c478bd9Sstevel@tonic-gate /*
2*9525b14bSRao Shoaib  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
37c478bd9Sstevel@tonic-gate  * Copyright (c) 1996-1999 by Internet Software Consortium.
47c478bd9Sstevel@tonic-gate  *
57c478bd9Sstevel@tonic-gate  * Permission to use, copy, modify, and distribute this software for any
67c478bd9Sstevel@tonic-gate  * purpose with or without fee is hereby granted, provided that the above
77c478bd9Sstevel@tonic-gate  * copyright notice and this permission notice appear in all copies.
87c478bd9Sstevel@tonic-gate  *
9*9525b14bSRao Shoaib  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
10*9525b14bSRao Shoaib  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*9525b14bSRao Shoaib  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
12*9525b14bSRao Shoaib  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*9525b14bSRao Shoaib  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*9525b14bSRao Shoaib  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
15*9525b14bSRao Shoaib  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
167c478bd9Sstevel@tonic-gate  */
177c478bd9Sstevel@tonic-gate 
187c478bd9Sstevel@tonic-gate #ifndef LOGGING_H
197c478bd9Sstevel@tonic-gate #define LOGGING_H
207c478bd9Sstevel@tonic-gate 
217c478bd9Sstevel@tonic-gate #include <sys/types.h>
227c478bd9Sstevel@tonic-gate #include <stdio.h>
237c478bd9Sstevel@tonic-gate #include <stdarg.h>
247c478bd9Sstevel@tonic-gate #include <unistd.h>
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #define log_critical		(-5)
277c478bd9Sstevel@tonic-gate #define log_error   		(-4)
287c478bd9Sstevel@tonic-gate #define log_warning 		(-3)
297c478bd9Sstevel@tonic-gate #define log_notice  		(-2)
307c478bd9Sstevel@tonic-gate #define log_info  		(-1)
317c478bd9Sstevel@tonic-gate #define log_debug(level)	(level)
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate typedef enum { log_syslog, log_file, log_null } log_channel_type;
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #define LOG_MAX_VERSIONS 99
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #define LOG_CLOSE_STREAM		0x0001
387c478bd9Sstevel@tonic-gate #define LOG_TIMESTAMP			0x0002
397c478bd9Sstevel@tonic-gate #define LOG_TRUNCATE			0x0004
407c478bd9Sstevel@tonic-gate #define LOG_USE_CONTEXT_LEVEL		0x0008
417c478bd9Sstevel@tonic-gate #define LOG_PRINT_LEVEL			0x0010
427c478bd9Sstevel@tonic-gate #define LOG_REQUIRE_DEBUG		0x0020
437c478bd9Sstevel@tonic-gate #define LOG_CHANNEL_BROKEN		0x0040
447c478bd9Sstevel@tonic-gate #define LOG_PRINT_CATEGORY		0x0080
457c478bd9Sstevel@tonic-gate #define LOG_CHANNEL_OFF			0x0100
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate typedef struct log_context *log_context;
487c478bd9Sstevel@tonic-gate typedef struct log_channel *log_channel;
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate #define LOG_OPTION_DEBUG		0x01
517c478bd9Sstevel@tonic-gate #define LOG_OPTION_LEVEL		0x02
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate #define log_open_stream		__log_open_stream
547c478bd9Sstevel@tonic-gate #define log_close_stream	__log_close_stream
557c478bd9Sstevel@tonic-gate #define log_get_stream		__log_get_stream
567c478bd9Sstevel@tonic-gate #define log_get_filename	__log_get_filename
577c478bd9Sstevel@tonic-gate #define log_check_channel	__log_check_channel
587c478bd9Sstevel@tonic-gate #define log_check		__log_check
597c478bd9Sstevel@tonic-gate #define log_vwrite		__log_vwrite
607c478bd9Sstevel@tonic-gate #define log_write		__log_write
617c478bd9Sstevel@tonic-gate #define log_new_context		__log_new_context
627c478bd9Sstevel@tonic-gate #define log_free_context	__log_free_context
637c478bd9Sstevel@tonic-gate #define log_add_channel		__log_add_channel
647c478bd9Sstevel@tonic-gate #define log_remove_channel	__log_remove_channel
657c478bd9Sstevel@tonic-gate #define log_option		__log_option
667c478bd9Sstevel@tonic-gate #define log_category_is_active	__log_category_is_active
677c478bd9Sstevel@tonic-gate #define log_new_syslog_channel	__log_new_syslog_channel
687c478bd9Sstevel@tonic-gate #define log_new_file_channel	__log_new_file_channel
697c478bd9Sstevel@tonic-gate #define log_set_file_owner	__log_set_file_owner
707c478bd9Sstevel@tonic-gate #define log_new_null_channel	__log_new_null_channel
717c478bd9Sstevel@tonic-gate #define log_inc_references	__log_inc_references
727c478bd9Sstevel@tonic-gate #define log_dec_references	__log_dec_references
737c478bd9Sstevel@tonic-gate #define log_get_channel_type	__log_get_channel_type
747c478bd9Sstevel@tonic-gate #define log_free_channel	__log_free_channel
757c478bd9Sstevel@tonic-gate #define log_close_debug_channels	__log_close_debug_channels
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate FILE *			log_open_stream(log_channel);
787c478bd9Sstevel@tonic-gate int			log_close_stream(log_channel);
797c478bd9Sstevel@tonic-gate FILE *			log_get_stream(log_channel);
807c478bd9Sstevel@tonic-gate char *			log_get_filename(log_channel);
817c478bd9Sstevel@tonic-gate int			log_check_channel(log_context, int, log_channel);
827c478bd9Sstevel@tonic-gate int			log_check(log_context, int, int);
837c478bd9Sstevel@tonic-gate #ifdef __GNUC__
847c478bd9Sstevel@tonic-gate void			log_vwrite(log_context, int, int, const char *,
857c478bd9Sstevel@tonic-gate 				   va_list args)
867c478bd9Sstevel@tonic-gate 				__attribute__((__format__(__printf__, 4, 0)));
877c478bd9Sstevel@tonic-gate void			log_write(log_context, int, int, const char *, ...)
887c478bd9Sstevel@tonic-gate 				__attribute__((__format__(__printf__, 4, 5)));
897c478bd9Sstevel@tonic-gate #else
907c478bd9Sstevel@tonic-gate void			log_vwrite(log_context, int, int, const char *,
917c478bd9Sstevel@tonic-gate 				   va_list args);
927c478bd9Sstevel@tonic-gate void			log_write(log_context, int, int, const char *, ...);
937c478bd9Sstevel@tonic-gate #endif
947c478bd9Sstevel@tonic-gate int			log_new_context(int, char **, log_context *);
957c478bd9Sstevel@tonic-gate void			log_free_context(log_context);
967c478bd9Sstevel@tonic-gate int			log_add_channel(log_context, int, log_channel);
977c478bd9Sstevel@tonic-gate int			log_remove_channel(log_context, int, log_channel);
987c478bd9Sstevel@tonic-gate int			log_option(log_context, int, int);
997c478bd9Sstevel@tonic-gate int			log_category_is_active(log_context, int);
1007c478bd9Sstevel@tonic-gate log_channel		log_new_syslog_channel(unsigned int, int, int);
1017c478bd9Sstevel@tonic-gate log_channel		log_new_file_channel(unsigned int, int, const char *,
1027c478bd9Sstevel@tonic-gate 					     FILE *, unsigned int,
1037c478bd9Sstevel@tonic-gate 					     unsigned long);
1047c478bd9Sstevel@tonic-gate int			log_set_file_owner(log_channel, uid_t, gid_t);
1057c478bd9Sstevel@tonic-gate log_channel		log_new_null_channel(void);
1067c478bd9Sstevel@tonic-gate int			log_inc_references(log_channel);
1077c478bd9Sstevel@tonic-gate int			log_dec_references(log_channel);
1087c478bd9Sstevel@tonic-gate log_channel_type	log_get_channel_type(log_channel);
1097c478bd9Sstevel@tonic-gate int			log_free_channel(log_channel);
1107c478bd9Sstevel@tonic-gate void			log_close_debug_channels(log_context);
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate #endif /* !LOGGING_H */
113*9525b14bSRao Shoaib /*! \file */
114