summaryrefslogtreecommitdiffstats
path: root/lib/util/debug.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2014-07-29 15:26:22 +0000
committerMichael Adam <obnox@samba.org>2014-07-31 18:49:47 +0200
commit44c77e80326c17a80c70140ee1b64a8847a4f779 (patch)
tree55a303e559bd044f73e94071265e9b8eb124f20c /lib/util/debug.c
parentcff585b6e2dff316c9478d470e11aa69faf0f4d5 (diff)
downloadsamba-44c77e80326c17a80c70140ee1b64a8847a4f779.tar.gz
samba-44c77e80326c17a80c70140ee1b64a8847a4f779.tar.xz
samba-44c77e80326c17a80c70140ee1b64a8847a4f779.zip
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>
Diffstat (limited to 'lib/util/debug.c')
-rw-r--r--lib/util/debug.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/util/debug.c b/lib/util/debug.c
index 0e8c1d3904..f94f44310f 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -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;