xref: /titanic_44/usr/src/lib/libresolv2/include/isc/logging.h (revision 355b4669e025ff377602b6fc7caaf30dbc218371)
1 /*
2  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*
7  * Copyright (c) 1996-1999 by Internet Software Consortium.
8  *
9  * Permission to use, copy, modify, and distribute this software for any
10  * purpose with or without fee is hereby granted, provided that the above
11  * copyright notice and this permission notice appear in all copies.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
14  * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
15  * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
16  * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
17  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
18  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20  * SOFTWARE.
21  */
22 #pragma ident	"%Z%%M%	%I%	%E% SMI"
23 
24 #ifndef LOGGING_H
25 #define LOGGING_H
26 
27 #include <sys/types.h>
28 #include <stdio.h>
29 #include <stdarg.h>
30 #include <unistd.h>
31 
32 #define log_critical		(-5)
33 #define log_error   		(-4)
34 #define log_warning 		(-3)
35 #define log_notice  		(-2)
36 #define log_info  		(-1)
37 #define log_debug(level)	(level)
38 
39 typedef enum { log_syslog, log_file, log_null } log_channel_type;
40 
41 #define LOG_MAX_VERSIONS 99
42 
43 #define LOG_CLOSE_STREAM		0x0001
44 #define LOG_TIMESTAMP			0x0002
45 #define LOG_TRUNCATE			0x0004
46 #define LOG_USE_CONTEXT_LEVEL		0x0008
47 #define LOG_PRINT_LEVEL			0x0010
48 #define LOG_REQUIRE_DEBUG		0x0020
49 #define LOG_CHANNEL_BROKEN		0x0040
50 #define LOG_PRINT_CATEGORY		0x0080
51 #define LOG_CHANNEL_OFF			0x0100
52 
53 typedef struct log_context *log_context;
54 typedef struct log_channel *log_channel;
55 
56 #define LOG_OPTION_DEBUG		0x01
57 #define LOG_OPTION_LEVEL		0x02
58 
59 #define log_open_stream		__log_open_stream
60 #define log_close_stream	__log_close_stream
61 #define log_get_stream		__log_get_stream
62 #define log_get_filename	__log_get_filename
63 #define log_check_channel	__log_check_channel
64 #define log_check		__log_check
65 #define log_vwrite		__log_vwrite
66 #define log_write		__log_write
67 #define log_new_context		__log_new_context
68 #define log_free_context	__log_free_context
69 #define log_add_channel		__log_add_channel
70 #define log_remove_channel	__log_remove_channel
71 #define log_option		__log_option
72 #define log_category_is_active	__log_category_is_active
73 #define log_new_syslog_channel	__log_new_syslog_channel
74 #define log_new_file_channel	__log_new_file_channel
75 #define log_set_file_owner	__log_set_file_owner
76 #define log_new_null_channel	__log_new_null_channel
77 #define log_inc_references	__log_inc_references
78 #define log_dec_references	__log_dec_references
79 #define log_get_channel_type	__log_get_channel_type
80 #define log_free_channel	__log_free_channel
81 #define log_close_debug_channels	__log_close_debug_channels
82 
83 FILE *			log_open_stream(log_channel);
84 int			log_close_stream(log_channel);
85 FILE *			log_get_stream(log_channel);
86 char *			log_get_filename(log_channel);
87 int			log_check_channel(log_context, int, log_channel);
88 int			log_check(log_context, int, int);
89 #ifdef __GNUC__
90 void			log_vwrite(log_context, int, int, const char *,
91 				   va_list args)
92 				__attribute__((__format__(__printf__, 4, 0)));
93 void			log_write(log_context, int, int, const char *, ...)
94 				__attribute__((__format__(__printf__, 4, 5)));
95 #else
96 void			log_vwrite(log_context, int, int, const char *,
97 				   va_list args);
98 void			log_write(log_context, int, int, const char *, ...);
99 #endif
100 int			log_new_context(int, char **, log_context *);
101 void			log_free_context(log_context);
102 int			log_add_channel(log_context, int, log_channel);
103 int			log_remove_channel(log_context, int, log_channel);
104 int			log_option(log_context, int, int);
105 int			log_category_is_active(log_context, int);
106 log_channel		log_new_syslog_channel(unsigned int, int, int);
107 log_channel		log_new_file_channel(unsigned int, int, const char *,
108 					     FILE *, unsigned int,
109 					     unsigned long);
110 int			log_set_file_owner(log_channel, uid_t, gid_t);
111 log_channel		log_new_null_channel(void);
112 int			log_inc_references(log_channel);
113 int			log_dec_references(log_channel);
114 log_channel_type	log_get_channel_type(log_channel);
115 int			log_free_channel(log_channel);
116 void			log_close_debug_channels(log_context);
117 
118 #endif /* !LOGGING_H */
119