cygserver: Seralize debug output to stdout to raise readability
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
8259db586a
commit
8d6a522877
@ -11,12 +11,16 @@ details. */
|
||||
#define __BSD_VISIBLE 1
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <libgen.h>
|
||||
|
||||
int32_t log_level = 8; /* Illegal value. Don't change! */
|
||||
tun_bool_t log_debug = TUN_UNDEF;
|
||||
tun_bool_t log_syslog = TUN_UNDEF;
|
||||
tun_bool_t log_stderr = TUN_UNDEF;
|
||||
|
||||
static CRITICAL_SECTION cs;
|
||||
static bool cs_inited;
|
||||
|
||||
void
|
||||
loginit (tun_bool_t opt_stderr, tun_bool_t opt_syslog)
|
||||
{
|
||||
@ -43,6 +47,8 @@ loginit (tun_bool_t opt_stderr, tun_bool_t opt_syslog)
|
||||
TUNABLE_INT_FETCH ("kern.log.level", &log_level);
|
||||
if (log_level == 8)
|
||||
log_level = 6;
|
||||
InitializeCriticalSection (&cs);
|
||||
cs_inited = true;
|
||||
}
|
||||
|
||||
void
|
||||
@ -63,8 +69,15 @@ _vlog (const char *file, int line, int level,
|
||||
syslog (level, buf);
|
||||
if (log_stderr == TUN_TRUE || level == LOG_DEBUG)
|
||||
{
|
||||
if (!cs_inited) /* Only occurs in --help scenario */
|
||||
{
|
||||
InitializeCriticalSection (&cs);
|
||||
cs_inited = true;
|
||||
}
|
||||
EnterCriticalSection (&cs);
|
||||
fputs (buf, stderr);
|
||||
fputc ('\n', stderr);
|
||||
LeaveCriticalSection (&cs);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user