r21825: add debug prefix timestamp to allow "short timestamps" to be
authorHerb Lewis <herb@samba.org>
Tue, 13 Mar 2007 17:39:06 +0000 (17:39 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:18:37 +0000 (12:18 -0500)
added to debug messages

source/lib/debug.c
source/param/loadparm.c

index 5f14166..62fda57 100644 (file)
@@ -962,7 +962,7 @@ BOOL dbghdr( int level, const char *file, const char *func, int line )
        /* Print the header if timestamps are turned on.  If parameters are
         * not yet loaded, then default to timestamps on.
         */
-       if( lp_timestamp_logs() || !(lp_loaded()) ) {
+       if( lp_timestamp_logs() || lp_debug_prefix_timestamp() || !(lp_loaded()) ) {
                char header_str[200];
 
                header_str[0] = '\0';
@@ -980,9 +980,15 @@ BOOL dbghdr( int level, const char *file, const char *func, int line )
                }
   
                /* Print it all out at once to prevent split syslog output. */
-               (void)Debug1( "[%s, %d%s] %s:%s(%d)\n",
+               if( lp_debug_prefix_timestamp() ) {
+                   (void)Debug1( "[%s, %d%s] ",
+                       current_timestring(lp_debug_hires_timestamp()), level,
+                       header_str);
+               } else {
+                   (void)Debug1( "[%s, %d%s] %s:%s(%d)\n",
                        current_timestring(lp_debug_hires_timestamp()), level,
                        header_str, file, func, line );
+               }
        }
 
        errno = old_errno;
index b90b53c..b9e9505 100644 (file)
@@ -290,6 +290,7 @@ typedef struct {
        BOOL bClientNTLMv2Auth;
        BOOL bClientPlaintextAuth;
        BOOL bClientUseSpnego;
+       BOOL bDebugPrefixTimestamp;
        BOOL bDebugHiresTimestamp;
        BOOL bDebugPid;
        BOOL bDebugUid;
@@ -952,6 +953,7 @@ static struct parm_struct parm_table[] = {
        {"max log size", P_INTEGER, P_GLOBAL, &Globals.max_log_size, NULL, NULL, FLAG_ADVANCED}, 
        {"debug timestamp", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, FLAG_ADVANCED}, 
        {"timestamp logs", P_BOOL, P_GLOBAL, &Globals.bTimestampLogs, NULL, NULL, FLAG_ADVANCED}, 
+       {"debug prefix timestamp", P_BOOL, P_GLOBAL, &Globals.bDebugPrefixTimestamp, NULL, NULL, FLAG_ADVANCED}, 
        {"debug hires timestamp", P_BOOL, P_GLOBAL, &Globals.bDebugHiresTimestamp, NULL, NULL, FLAG_ADVANCED}, 
        {"debug pid", P_BOOL, P_GLOBAL, &Globals.bDebugPid, NULL, NULL, FLAG_ADVANCED}, 
        {"debug uid", P_BOOL, P_GLOBAL, &Globals.bDebugUid, NULL, NULL, FLAG_ADVANCED}, 
@@ -1516,6 +1518,7 @@ static void init_globals(BOOL first_time_only)
        Globals.bSyslogOnly = False;
        Globals.bTimestampLogs = True;
        string_set(&Globals.szLogLevel, "0");
+       Globals.bDebugPrefixTimestamp = False;
        Globals.bDebugHiresTimestamp = False;
        Globals.bDebugPid = False;
        Globals.bDebugUid = False;
@@ -1947,6 +1950,7 @@ FN_GLOBAL_INTEGER(lp_client_schannel, &Globals.clientSchannel)
 FN_GLOBAL_INTEGER(lp_server_schannel, &Globals.serverSchannel)
 FN_GLOBAL_BOOL(lp_syslog_only, &Globals.bSyslogOnly)
 FN_GLOBAL_BOOL(lp_timestamp_logs, &Globals.bTimestampLogs)
+FN_GLOBAL_BOOL(lp_debug_prefix_timestamp, &Globals.bDebugPrefixTimestamp)
 FN_GLOBAL_BOOL(lp_debug_hires_timestamp, &Globals.bDebugHiresTimestamp)
 FN_GLOBAL_BOOL(lp_debug_pid, &Globals.bDebugPid)
 FN_GLOBAL_BOOL(lp_debug_uid, &Globals.bDebugUid)