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, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #include <stdio.h> 28 #include <stdlib.h> 29 #include <stdarg.h> 30 #include <unistd.h> 31 #include <time.h> 32 #include <syslog.h> 33 #include <errno.h> 34 #include <string.h> 35 #include <sys/types.h> 36 #include <sys/stat.h> 37 #include <sys/smedia.h> 38 #include "smserver.h" 39 40 #define DEBUGMSG "Level[%d]: %s" 41 42 void 43 fatal(const char *fmt, ...) 44 { 45 va_list ap; 46 47 va_start(ap, fmt); 48 (void) vsyslog(LOG_DAEMON|LOG_CRIT, fmt, ap); 49 va_end(ap); 50 51 exit(-1); 52 } 53 54 void 55 quit(const char *fmt, ...) 56 { 57 va_list ap; 58 59 va_start(ap, fmt); 60 (void) vsyslog(LOG_DAEMON|LOG_ERR, fmt, ap); 61 va_end(ap); 62 63 exit(0); 64 } 65 66 67 void 68 noise(const char *fmt, ...) 69 { 70 va_list ap; 71 72 va_start(ap, fmt); 73 (void) vsyslog(LOG_DAEMON|LOG_WARNING, fmt, ap); 74 va_end(ap); 75 } 76 77 void 78 warning(const char *fmt, ...) 79 { 80 va_list ap; 81 82 va_start(ap, fmt); 83 (void) vsyslog(LOG_DAEMON|LOG_WARNING, fmt, ap); 84 va_end(ap); 85 } 86 87 88 void 89 info(const char *fmt, ...) 90 { 91 extern int verbose; 92 va_list ap; 93 94 if (verbose == 0) { 95 return; 96 } 97 98 va_start(ap, fmt); 99 (void) vsyslog(LOG_DAEMON|LOG_INFO, fmt, ap); 100 va_end(ap); 101 } 102 103 /*PRINTFLIKE2*/ 104 void 105 debug(uint_t level, const char *fmt, ...) 106 { 107 extern int debug_level; 108 va_list ap; 109 char dbgmsg[BUFSIZ]; 110 111 if (level > debug_level) { 112 return; 113 } 114 115 (void) snprintf(dbgmsg, sizeof (dbgmsg), DEBUGMSG, level, fmt); 116 va_start(ap, fmt); 117 (void) vsyslog(LOG_DAEMON|LOG_DEBUG, dbgmsg, ap); 118 va_end(ap); 119 } 120