xref: /titanic_51/usr/src/cmd/smserverd/smediad_err.c (revision 1e49577a7fcde812700ded04431b49d67cc57d6d)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 
30 #include	<stdio.h>
31 #include	<stdlib.h>
32 #include	<stdarg.h>
33 #include	<unistd.h>
34 #include	<time.h>
35 #include	<syslog.h>
36 #include	<errno.h>
37 #include	<string.h>
38 #include	<sys/types.h>
39 #include	<sys/stat.h>
40 #include	<sys/smedia.h>
41 #include	"smserver.h"
42 
43 #define	DEBUGMSG	"Level[%d]: %s"
44 
45 void
46 fatal(const char *fmt, ...)
47 {
48 	va_list		ap;
49 
50 	va_start(ap, fmt);
51 	(void) vsyslog(LOG_DAEMON|LOG_CRIT, fmt, ap);
52 	va_end(ap);
53 
54 	exit(-1);
55 }
56 
57 void
58 quit(const char *fmt, ...)
59 {
60 	va_list		ap;
61 
62 	va_start(ap, fmt);
63 	(void) vsyslog(LOG_DAEMON|LOG_ERR, fmt, ap);
64 	va_end(ap);
65 
66 	exit(0);
67 }
68 
69 
70 void
71 noise(const char *fmt, ...)
72 {
73 	va_list		ap;
74 
75 	va_start(ap, fmt);
76 	(void) vsyslog(LOG_DAEMON|LOG_WARNING, fmt, ap);
77 	va_end(ap);
78 }
79 
80 void
81 warning(const char *fmt, ...)
82 {
83 	va_list		ap;
84 
85 	va_start(ap, fmt);
86 	(void) vsyslog(LOG_DAEMON|LOG_WARNING, fmt, ap);
87 	va_end(ap);
88 }
89 
90 
91 void
92 info(const char *fmt, ...)
93 {
94 	extern int	verbose;
95 	va_list		ap;
96 
97 	if (verbose == 0) {
98 		return;
99 	}
100 
101 	va_start(ap, fmt);
102 	(void) vsyslog(LOG_DAEMON|LOG_INFO, fmt, ap);
103 	va_end(ap);
104 }
105 
106 /*PRINTFLIKE2*/
107 void
108 debug(uint_t level, const char *fmt, ...)
109 {
110 	extern int	debug_level;
111 	va_list		ap;
112 	char		dbgmsg[BUFSIZ];
113 
114 	if (level > debug_level) {
115 		return;
116 	}
117 
118 	(void) snprintf(dbgmsg, sizeof (dbgmsg), DEBUGMSG, level, fmt);
119 	va_start(ap, fmt);
120 	(void) vsyslog(LOG_DAEMON|LOG_DEBUG, dbgmsg, ap);
121 	va_end(ap);
122 }
123