1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-04 08:22:08 +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; 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)) { if (unlikely(DEBUGLEVEL_CLASS[ cls ] >= 10)) {
verbose = true; verbose = true;
} }
if (verbose || state.settings.debug_pid) { if (verbose || state.settings.debug_pid) {
snprintf(header_str, sizeof(header_str), ", pid=%u", size_t hs_len = strlen(header_str);
(unsigned int)getpid()); snprintf(header_str + hs_len, sizeof(header_str) - hs_len,
", pid=%u", (unsigned int)getpid());
} }
if (verbose || state.settings.debug_uid) { 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]); 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. */ /* Print it all out at once to prevent split syslog output. */
if( state.settings.debug_prefix_timestamp ) { if( state.settings.debug_prefix_timestamp ) {
(void)Debug1("[%s, %2d%s] ", (void)Debug1("%s] ", header_str);
tvbuf.buf,
level, header_str);
} else { } else {
(void)Debug1("[%s, %2d%s] %s(%s)\n", (void)Debug1("%s] %s(%s)\n",
tvbuf.buf, header_str, location, func );
level, header_str, location, func );
} }
errno = old_errno; errno = old_errno;