xref: /illumos-gate/usr/src/cmd/nscd/nscd_log.h (revision dcb3fe6cf7f57637386afcd1e3d7077405adec74)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_NSCD_LOG_H
27 #define	_NSCD_LOG_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include "nscd_common.h"
34 
35 /*
36  * nscd logging options
37  */
38 /*
39  * components: select more than one by OR'ing
40  */
41 #define	NSCD_LOG_NONE		0x0000
42 #define	NSCD_LOG_CACHE		0x0001
43 #define	NSCD_LOG_SWITCH_ENGINE	0x0002
44 #define	NSCD_LOG_FRONT_END	0x0004
45 #define	NSCD_LOG_SELF_CRED	0x0008
46 #define	NSCD_LOG_ADMIN		0x0010	/*   16 */
47 #define	NSCD_LOG_CONFIG		0x0020  /*   32 */
48 #define	NSCD_LOG_SMF_MONITOR	0x0040  /*   64 */
49 #define	NSCD_LOG_NSW_STATE	0x0080  /*  128 */
50 #define	NSCD_LOG_GETENT_CTX	0x0100  /*  256 */
51 #define	NSCD_LOG_ACCESS_INFO	0x0200  /*  512 */
52 #define	NSCD_LOG_INT_ADDR	0x0400  /* 1024 */
53 #define	NSCD_LOG_ALL		0x07ff  /* 2047 */
54 
55 /*
56  * debug level: select more than one by OR'ing
57  */
58 #define	NSCD_LOG_LEVEL_NONE		0x0000
59 #define	NSCD_LOG_LEVEL_CANT_FIND	0x0001
60 #define	NSCD_LOG_LEVEL_DEBUG		0x0100  /*   256 */
61 #define	NSCD_LOG_LEVEL_ERROR		0x0200  /*   512 */
62 #define	NSCD_LOG_LEVEL_WARNING		0x0400  /*  1024 */
63 #define	NSCD_LOG_LEVEL_INFO		0x0800  /*  2048 */
64 #define	NSCD_LOG_LEVEL_NOTICE		0x1000	/*  4096 */
65 #define	NSCD_LOG_LEVEL_ALERT		0x2000  /*  8192 */
66 #define	NSCD_LOG_LEVEL_CRIT		0x4000  /* 16384 */
67 #define	NSCD_LOG_LEVEL_ALL		0x7fff  /* 32767 */
68 
69 /*
70  * debug level: for backward compatibility
71  */
72 #define	NSCD_LOG_LEVEL_DEBUG_6 (NSCD_LOG_LEVEL_CANT_FIND | NSCD_LOG_LEVEL_ERROR)
73 
74 /*
75  * _nscd_log_comp and _nscd_log_level defined in nscd_log.c
76  */
77 extern int _nscd_log_comp;
78 extern int _nscd_log_level;
79 
80 #define	_NSCD_LOG(comp, lvl)	if ((_nscd_log_comp & (comp)) && \
81 					(_nscd_log_level & (lvl))) \
82 				_nscd_logit
83 
84 #define	_NSCD_LOG_IF(comp, lvl)	if ((_nscd_log_comp & (comp)) && \
85 					(_nscd_log_level & (lvl)))
86 
87 
88 /*
89  * prototypes
90  */
91 void		_nscd_logit(char *funcname, char *format, ...);
92 nscd_rc_t	_nscd_set_debug_level(int level);
93 nscd_rc_t	_nscd_set_log_file(char *name);
94 void		_nscd_get_log_info(char *level, int llen, char *file, int flen);
95 
96 #ifdef	__cplusplus
97 }
98 #endif
99 
100 #endif	/* _NSCD_LOG_H */
101