3 Copyright 2003 Red Hat Inc.
5 This file is part of Cygwin.
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
10 #ifdef __OUTSIDE_CYGWIN__
13 #define __BSD_VISIBLE 1
14 #include <sys/smallprint.h>
18 long log_level = 8; /* Illegal value. Don't change! */
19 tun_bool_t log_debug = TUN_UNDEF;
20 tun_bool_t log_syslog = TUN_UNDEF;
21 tun_bool_t log_stderr = TUN_UNDEF;
24 loginit (tun_bool_t opt_stderr, tun_bool_t opt_syslog)
26 if (log_debug == TUN_UNDEF)
27 TUNABLE_BOOL_FETCH ("kern.log.debug", &log_debug);
28 if (log_debug == TUN_UNDEF)
29 log_debug = TUN_FALSE;
31 if (opt_stderr != TUN_UNDEF)
32 log_stderr = opt_stderr;
34 TUNABLE_BOOL_FETCH ("kern.log.stderr", &log_stderr);
35 if (log_stderr == TUN_UNDEF)
36 log_stderr = TUN_FALSE;
38 if (opt_syslog != TUN_UNDEF)
39 log_syslog = opt_syslog;
41 TUNABLE_BOOL_FETCH ("kern.log.syslog", &log_syslog);
42 if (log_syslog == TUN_UNDEF)
43 log_syslog = TUN_FALSE;
46 TUNABLE_INT_FETCH ("kern.log.level", &log_level);
52 _vlog (const char *file, int line, int level,
53 const char *fmt, va_list ap)
57 if ((level == LOG_DEBUG && log_debug != TUN_TRUE)
58 || (level != LOG_DEBUG && level >= log_level))
60 strcpy (buf, "cygserver: ");
61 if (file && log_debug == TUN_TRUE)
62 __small_sprintf (strchr (buf, '\0'), "%s, line %d: ", file, line);
63 __small_vsprintf (strchr (buf, '\0'), fmt, ap);
64 if (log_syslog == TUN_TRUE && level != LOG_DEBUG)
66 if (log_stderr == TUN_TRUE || level == LOG_DEBUG)
74 _log (const char *file, int line, int level, const char *fmt, ...)
78 _vlog (file, line, level, fmt, ap);
82 _vpanic (const char *file, int line, const char *fmt, va_list ap)
84 _vlog (file, line, LOG_EMERG, fmt, ap);
89 _panic (const char *file, int line, const char *fmt, ...)
93 _vpanic (file, line, fmt, ap);
95 #endif /* __OUTSIDE_CYGWIN__ */