2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
22 #include <smbsrv/smbinfo.h>
23 #include <smbsrv/smb_ioctl.h>
26 #define CBUFSIZ 26 /* ctime(3c) */
28 static const char *pri_name
[LOG_DEBUG
+1] = {
29 "emerg", "alert", "crit", "err", "warning", "notice", "info", "debug"
33 smb_svc_log(int pri
, const char *fmt
, va_list ap
)
35 static time_t prev_ts
;
36 char fbuf
[SMBD_LOG_MSGSIZE
];
40 int save_errno
= errno
;
43 if (smbd
.s_debug
== 0 && pri
== LOG_DEBUG
)
50 (void) fprintf(stdout
, "@ %s",
51 ctime_r(&ts
, cbuf
, sizeof (cbuf
)));
54 newfmt
= smb_syslog_fmt_m(fbuf
, sizeof (fbuf
), fmt
, save_errno
);
57 (void) fprintf(stdout
, "smbd.%s: ", pri_name
[pri
]);
58 /* LINTED E_SEC_PRINTF_VAR_FMT */
59 (void) vfprintf(stdout
, newfmt
, ap
);
60 (void) fprintf(stdout
, "\n");
63 (void) fflush(stdout
);
67 * Provide a replacement for libsmb:smb_vsyslog() that prints messages
68 * both to the normal sysloc(3c), and to stdout, which ends up in:
69 * /var/svc/log/network-smb-server:default.log
70 * It's much easier to follow debug messages in the service log.
73 smb_vsyslog(int pri
, const char *fmt
, va_list ap
)
78 smb_svc_log(pri
, fmt
, tap
);
81 vsyslog(pri
, fmt
, ap
);
85 * An override for libsmb:smb_trace(). As the comment there says:
87 * This function is designed to be used with dtrace, i.e. see:
88 * usr/src/cmd/smbsrv/dtrace/smbd-all.d
90 * Outside of dtrace, the messages passed to this function usually
91 * lack sufficient context to be useful, so don't log them.
92 * However, if you insist, set debug >= 3 and this will log them.
95 smb_trace(const char *s
)
97 if (smbd
.s_debug
>= 3)
98 (void) fprintf(stdout
, "smbd.trace: %s\n", s
);