xref: /titanic_52/usr/src/uts/common/sys/strlog.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
23*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
24*7c478bd9Sstevel@tonic-gate 
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate /*
27*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
28*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
29*7c478bd9Sstevel@tonic-gate  */
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate #ifndef _SYS_STRLOG_H
32*7c478bd9Sstevel@tonic-gate #define	_SYS_STRLOG_H
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
37*7c478bd9Sstevel@tonic-gate #include <sys/types32.h>
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
40*7c478bd9Sstevel@tonic-gate extern "C" {
41*7c478bd9Sstevel@tonic-gate #endif
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate /*
44*7c478bd9Sstevel@tonic-gate  * Streams Log Driver Interface Definitions
45*7c478bd9Sstevel@tonic-gate  */
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate /*
48*7c478bd9Sstevel@tonic-gate  * structure of control portion of log message
49*7c478bd9Sstevel@tonic-gate  */
50*7c478bd9Sstevel@tonic-gate typedef struct log_ctl {
51*7c478bd9Sstevel@tonic-gate 	short	mid;
52*7c478bd9Sstevel@tonic-gate 	short	sid;
53*7c478bd9Sstevel@tonic-gate 	char 	level;		/* level of message for tracing */
54*7c478bd9Sstevel@tonic-gate 	short	flags;		/* message disposition */
55*7c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_I32LPx)
56*7c478bd9Sstevel@tonic-gate 	clock32_t ltime;	/* time in machine ticks since boot */
57*7c478bd9Sstevel@tonic-gate 	time32_t ttime;		/* time in seconds since 1970 */
58*7c478bd9Sstevel@tonic-gate #else
59*7c478bd9Sstevel@tonic-gate 	clock_t	ltime;
60*7c478bd9Sstevel@tonic-gate 	time_t	ttime;
61*7c478bd9Sstevel@tonic-gate #endif
62*7c478bd9Sstevel@tonic-gate 	int	seq_no;		/* sequence number */
63*7c478bd9Sstevel@tonic-gate 	int	pri;		/* priority = (facility|level) */
64*7c478bd9Sstevel@tonic-gate } log_ctl_t;
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate /*
67*7c478bd9Sstevel@tonic-gate  * Public flags for log messages
68*7c478bd9Sstevel@tonic-gate  */
69*7c478bd9Sstevel@tonic-gate #define	SL_FATAL	0x01	/* indicates fatal error */
70*7c478bd9Sstevel@tonic-gate #define	SL_NOTIFY	0x02	/* logger must notify administrator */
71*7c478bd9Sstevel@tonic-gate #define	SL_ERROR	0x04	/* include on the error log */
72*7c478bd9Sstevel@tonic-gate #define	SL_TRACE	0x08	/* include on the trace log */
73*7c478bd9Sstevel@tonic-gate #define	SL_CONSOLE	0x10	/* include on the console log */
74*7c478bd9Sstevel@tonic-gate #define	SL_WARN		0x20	/* warning message */
75*7c478bd9Sstevel@tonic-gate #define	SL_NOTE		0x40	/* notice message */
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate /*
78*7c478bd9Sstevel@tonic-gate  * Private flags for log messages -- used by internal implementation only
79*7c478bd9Sstevel@tonic-gate  */
80*7c478bd9Sstevel@tonic-gate #define	SL_CONSONLY	0x1000	/* send message only to /dev/console */
81*7c478bd9Sstevel@tonic-gate #define	SL_LOGONLY	0x2000	/* send message only to /var/adm/messages */
82*7c478bd9Sstevel@tonic-gate #define	SL_USER		0x4000	/* send message to user's terminal */
83*7c478bd9Sstevel@tonic-gate #define	SL_PANICMSG	0x8000	/* message was created while panicking */
84*7c478bd9Sstevel@tonic-gate 
85*7c478bd9Sstevel@tonic-gate /*
86*7c478bd9Sstevel@tonic-gate  * Structure defining ids and levels desired by the tracer (I_TRCLOG).
87*7c478bd9Sstevel@tonic-gate  */
88*7c478bd9Sstevel@tonic-gate typedef struct trace_ids {
89*7c478bd9Sstevel@tonic-gate 	short	ti_mid;
90*7c478bd9Sstevel@tonic-gate 	short	ti_sid;
91*7c478bd9Sstevel@tonic-gate 	int8_t	ti_level;
92*7c478bd9Sstevel@tonic-gate } trace_ids_t;
93*7c478bd9Sstevel@tonic-gate 
94*7c478bd9Sstevel@tonic-gate /*
95*7c478bd9Sstevel@tonic-gate  * Log Driver I_STR ioctl commands
96*7c478bd9Sstevel@tonic-gate  */
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate #define	LOGCTL		(('L')<<8)
99*7c478bd9Sstevel@tonic-gate #define	I_TRCLOG	(LOGCTL|1)	/* process is tracer */
100*7c478bd9Sstevel@tonic-gate #define	I_ERRLOG	(LOGCTL|2)	/* process is error logger */
101*7c478bd9Sstevel@tonic-gate #define	I_CONSLOG	(LOGCTL|3)	/* process is console logger */
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate #define	STRLOG_MAKE_MSGID(fmt, msgid)					\
104*7c478bd9Sstevel@tonic-gate {									\
105*7c478bd9Sstevel@tonic-gate 	uchar_t *__cp = (uchar_t *)fmt;					\
106*7c478bd9Sstevel@tonic-gate 	uchar_t __c;							\
107*7c478bd9Sstevel@tonic-gate 	uint32_t __id = 0;						\
108*7c478bd9Sstevel@tonic-gate 	while ((__c = *__cp++) != '\0')					\
109*7c478bd9Sstevel@tonic-gate 		if (__c >= ' ')						\
110*7c478bd9Sstevel@tonic-gate 			__id = (__id >> 5) + (__id << 27) + __c;	\
111*7c478bd9Sstevel@tonic-gate 	msgid = (__id % 899981) + 100000;				\
112*7c478bd9Sstevel@tonic-gate }
113*7c478bd9Sstevel@tonic-gate 
114*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL
115*7c478bd9Sstevel@tonic-gate 
116*7c478bd9Sstevel@tonic-gate #ifndef _ASM
117*7c478bd9Sstevel@tonic-gate #include <sys/va_list.h>
118*7c478bd9Sstevel@tonic-gate #endif
119*7c478bd9Sstevel@tonic-gate 
120*7c478bd9Sstevel@tonic-gate /*PRINTFLIKE5*/
121*7c478bd9Sstevel@tonic-gate extern int strlog(short, short, char, unsigned short, char *, ...)
122*7c478bd9Sstevel@tonic-gate 	__KPRINTFLIKE(5);
123*7c478bd9Sstevel@tonic-gate extern int vstrlog(short, short, char, unsigned short, char *, __va_list)
124*7c478bd9Sstevel@tonic-gate 	__KVPRINTFLIKE(5);
125*7c478bd9Sstevel@tonic-gate 
126*7c478bd9Sstevel@tonic-gate /*
127*7c478bd9Sstevel@tonic-gate  * STRLOG(mid,sid,level,flags,fmt,args) should be used for those trace
128*7c478bd9Sstevel@tonic-gate  * calls that are only to be made during debugging.
129*7c478bd9Sstevel@tonic-gate  */
130*7c478bd9Sstevel@tonic-gate #if defined(DEBUG) || defined(__lint)
131*7c478bd9Sstevel@tonic-gate #define	STRLOG	strlog
132*7c478bd9Sstevel@tonic-gate #else
133*7c478bd9Sstevel@tonic-gate #define	STRLOG	0 && strlog
134*7c478bd9Sstevel@tonic-gate #endif	/* DEBUG || __lint */
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
137*7c478bd9Sstevel@tonic-gate 
138*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
139*7c478bd9Sstevel@tonic-gate }
140*7c478bd9Sstevel@tonic-gate #endif
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_STRLOG_H */
143