17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23*b4203d75SMarcel Telka /* All Rights Reserved */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 277c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 287c478bd9Sstevel@tonic-gate * Use is subject to license terms. 297c478bd9Sstevel@tonic-gate */ 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifndef _SYS_STRLOG_H 327c478bd9Sstevel@tonic-gate #define _SYS_STRLOG_H 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <sys/types.h> 357c478bd9Sstevel@tonic-gate #include <sys/types32.h> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifdef __cplusplus 387c478bd9Sstevel@tonic-gate extern "C" { 397c478bd9Sstevel@tonic-gate #endif 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate /* 427c478bd9Sstevel@tonic-gate * Streams Log Driver Interface Definitions 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* 467c478bd9Sstevel@tonic-gate * structure of control portion of log message 477c478bd9Sstevel@tonic-gate */ 487c478bd9Sstevel@tonic-gate typedef struct log_ctl { 497c478bd9Sstevel@tonic-gate short mid; 507c478bd9Sstevel@tonic-gate short sid; 517c478bd9Sstevel@tonic-gate char level; /* level of message for tracing */ 527c478bd9Sstevel@tonic-gate short flags; /* message disposition */ 537c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_I32LPx) 547c478bd9Sstevel@tonic-gate clock32_t ltime; /* time in machine ticks since boot */ 557c478bd9Sstevel@tonic-gate time32_t ttime; /* time in seconds since 1970 */ 567c478bd9Sstevel@tonic-gate #else 577c478bd9Sstevel@tonic-gate clock_t ltime; 587c478bd9Sstevel@tonic-gate time_t ttime; 597c478bd9Sstevel@tonic-gate #endif 607c478bd9Sstevel@tonic-gate int seq_no; /* sequence number */ 617c478bd9Sstevel@tonic-gate int pri; /* priority = (facility|level) */ 627c478bd9Sstevel@tonic-gate } log_ctl_t; 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * Public flags for log messages 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate #define SL_FATAL 0x01 /* indicates fatal error */ 687c478bd9Sstevel@tonic-gate #define SL_NOTIFY 0x02 /* logger must notify administrator */ 697c478bd9Sstevel@tonic-gate #define SL_ERROR 0x04 /* include on the error log */ 707c478bd9Sstevel@tonic-gate #define SL_TRACE 0x08 /* include on the trace log */ 717c478bd9Sstevel@tonic-gate #define SL_CONSOLE 0x10 /* include on the console log */ 727c478bd9Sstevel@tonic-gate #define SL_WARN 0x20 /* warning message */ 737c478bd9Sstevel@tonic-gate #define SL_NOTE 0x40 /* notice message */ 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate /* 767c478bd9Sstevel@tonic-gate * Private flags for log messages -- used by internal implementation only 777c478bd9Sstevel@tonic-gate */ 787c478bd9Sstevel@tonic-gate #define SL_CONSONLY 0x1000 /* send message only to /dev/console */ 797c478bd9Sstevel@tonic-gate #define SL_LOGONLY 0x2000 /* send message only to /var/adm/messages */ 807c478bd9Sstevel@tonic-gate #define SL_USER 0x4000 /* send message to user's terminal */ 817c478bd9Sstevel@tonic-gate #define SL_PANICMSG 0x8000 /* message was created while panicking */ 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate /* 847c478bd9Sstevel@tonic-gate * Structure defining ids and levels desired by the tracer (I_TRCLOG). 857c478bd9Sstevel@tonic-gate */ 867c478bd9Sstevel@tonic-gate typedef struct trace_ids { 877c478bd9Sstevel@tonic-gate short ti_mid; 887c478bd9Sstevel@tonic-gate short ti_sid; 897c478bd9Sstevel@tonic-gate int8_t ti_level; 907c478bd9Sstevel@tonic-gate } trace_ids_t; 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* 937c478bd9Sstevel@tonic-gate * Log Driver I_STR ioctl commands 947c478bd9Sstevel@tonic-gate */ 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate #define LOGCTL (('L')<<8) 977c478bd9Sstevel@tonic-gate #define I_TRCLOG (LOGCTL|1) /* process is tracer */ 987c478bd9Sstevel@tonic-gate #define I_ERRLOG (LOGCTL|2) /* process is error logger */ 997c478bd9Sstevel@tonic-gate #define I_CONSLOG (LOGCTL|3) /* process is console logger */ 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate #define STRLOG_MAKE_MSGID(fmt, msgid) \ 1027c478bd9Sstevel@tonic-gate { \ 1037c478bd9Sstevel@tonic-gate uchar_t *__cp = (uchar_t *)fmt; \ 1047c478bd9Sstevel@tonic-gate uchar_t __c; \ 1057c478bd9Sstevel@tonic-gate uint32_t __id = 0; \ 1067c478bd9Sstevel@tonic-gate while ((__c = *__cp++) != '\0') \ 1077c478bd9Sstevel@tonic-gate if (__c >= ' ') \ 1087c478bd9Sstevel@tonic-gate __id = (__id >> 5) + (__id << 27) + __c; \ 1097c478bd9Sstevel@tonic-gate msgid = (__id % 899981) + 100000; \ 1107c478bd9Sstevel@tonic-gate } 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate #ifndef _ASM 1157c478bd9Sstevel@tonic-gate #include <sys/va_list.h> 1167c478bd9Sstevel@tonic-gate #endif 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate /*PRINTFLIKE5*/ 1197c478bd9Sstevel@tonic-gate extern int strlog(short, short, char, unsigned short, char *, ...) 1207c478bd9Sstevel@tonic-gate __KPRINTFLIKE(5); 1217c478bd9Sstevel@tonic-gate extern int vstrlog(short, short, char, unsigned short, char *, __va_list) 1227c478bd9Sstevel@tonic-gate __KVPRINTFLIKE(5); 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * STRLOG(mid,sid,level,flags,fmt,args) should be used for those trace 1267c478bd9Sstevel@tonic-gate * calls that are only to be made during debugging. 1277c478bd9Sstevel@tonic-gate */ 1287c478bd9Sstevel@tonic-gate #if defined(DEBUG) || defined(__lint) 1297c478bd9Sstevel@tonic-gate #define STRLOG strlog 1307c478bd9Sstevel@tonic-gate #else 1317c478bd9Sstevel@tonic-gate #define STRLOG 0 && strlog 1327c478bd9Sstevel@tonic-gate #endif /* DEBUG || __lint */ 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1377c478bd9Sstevel@tonic-gate } 1387c478bd9Sstevel@tonic-gate #endif 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate #endif /* _SYS_STRLOG_H */ 141