1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

debug: Move adding timeval and loglevel

The whole routine incrementally creates the hdr_string, do it for the
time string and the debuglevel as well

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
This commit is contained in:
Volker Lendecke
2014-07-29 15:26:22 +00:00
committed by Michael Adam
parent cff585b6e2
commit 44c77e8032

View File

@ -1003,15 +1003,20 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func)
return true;
}
header_str[0] = '\0';
GetTimeOfDay(&tv);
timeval_str_buf(&tv, state.settings.debug_hires_timestamp, &tvbuf);
snprintf(header_str, sizeof(header_str), "[%s, %2d",
tvbuf.buf, level);
if (unlikely(DEBUGLEVEL_CLASS[ cls ] >= 10)) {
verbose = true;
}
if (verbose || state.settings.debug_pid) {
snprintf(header_str, sizeof(header_str), ", pid=%u",
(unsigned int)getpid());
size_t hs_len = strlen(header_str);
snprintf(header_str + hs_len, sizeof(header_str) - hs_len,
", pid=%u", (unsigned int)getpid());
}
if (verbose || state.settings.debug_uid) {
@ -1031,18 +1036,12 @@ bool dbghdrclass(int level, int cls, const char *location, const char *func)
classname_table[cls]);
}
GetTimeOfDay(&tv);
timeval_str_buf(&tv, state.settings.debug_hires_timestamp, &tvbuf);
/* Print it all out at once to prevent split syslog output. */
if( state.settings.debug_prefix_timestamp ) {
(void)Debug1("[%s, %2d%s] ",
tvbuf.buf,
level, header_str);
(void)Debug1("%s] ", header_str);
} else {
(void)Debug1("[%s, %2d%s] %s(%s)\n",
tvbuf.buf,
level, header_str, location, func );
(void)Debug1("%s] %s(%s)\n",
header_str, location, func );
}
errno = old_errno;