4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 /* lfmt_log() - log info */
38 #include <sys/types.h>
39 #include <sys/types32.h>
40 #include <sys/stropts.h>
41 #include <sys/strlog.h>
46 #include "pfmt_data.h"
54 #define LOGNAME "/dev/conslog"
55 #define LOG_CONSOLE "/dev/console"
58 __lfmt_log(const char *text
, const char *sev
, va_list args
, long flag
, int ret
)
71 len
= ret
+ sizeof (long) + 3;
73 if (len
> sizeof (msg
)) {
79 msg_offset
= (int)sizeof (long);
81 lrw_rdlock(&_rw_pfmt_label
);
83 msg_offset
+= strlcpy(msg
.buf
+ msg_offset
, __pfmt_label
,
84 sizeof (msg
.buf
) - msg_offset
);
85 lrw_unlock(&_rw_pfmt_label
);
88 msg_offset
+= sprintf(msg
.buf
+ msg_offset
, sev
, flag
& 0xff);
90 msg_offset
+= 1 + vsprintf(msg
.buf
+ msg_offset
, text
, args
);
91 msg
.buf
[msg_offset
++] = '\0';
94 ((fd
= open(LOGNAME
, O_WRONLY
)) == -1 ||
95 fcntl(fd
, F_SETFD
, 1) == -1))
99 dat
.len
= (int)msg_offset
;
102 if (putmsg(fd
, 0, &dat
, 0) == -1) {
108 * Display it to a console
110 if ((flag
& MM_CONSOLE
) != 0) {
115 fdd
= open(LOG_CONSOLE
, O_WRONLY
);
118 * Use C locale for time stamp.
121 (void) ctime_r(&t
, buf
);
122 p
= (char *)strrchr(buf
, '\n');
125 (void) write(fdd
, buf
, strlen(buf
));
126 (void) write(fdd
, msg
.buf
+ sizeof (long),
127 msg_offset
- sizeof (long));
128 (void) write(fdd
, "\n", 1);