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