Fix ndrdump to use a common setup_logging() API
authorAndrew Bartlett <abartlet@samba.org>
Mon, 29 Jun 2009 10:12:23 +0000 (20:12 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 29 Jun 2009 10:12:23 +0000 (20:12 +1000)
By adding a new common setup_logging_stdout() API, we no longer need to abuse the ABI compatability between the different setup_logging() calls in Samba3 and Samba4's DEBUG() subsystems.

The revert of 49a6d757b4d944cd22c91b2838beb83f04fbe1e9 works with this
to fix bug 6211.

Andrew Bartlett

lib/util/debug.c
lib/util/debug.h
librpc/tools/ndrdump.c
source3/include/proto.h
source3/lib/debug.c

index 76178e207460a7842eaacdda1b3aacad93207a6d..996efdff7e84b9d59e910a08002e4fc541c87625 100644 (file)
@@ -197,6 +197,14 @@ _PUBLIC_ void setup_logging(const char *prog_name, enum debug_logtype new_logtyp
        reopen_logs();
 }
 
+/**
+   Just run logging to stdout for this program 
+*/
+_PUBLIC_ void setup_logging_stdout(void)
+{
+       setup_logging(NULL, DEBUG_STDOUT);
+}
+
 /**
   return a string constant containing n tabs
   no more than 10 tabs are returned
index 7518a64e19613ae8fa809781dbcea20fa788f508..f0d16952a987b7d9ad94746730748cd04c9a98b1 100644 (file)
@@ -74,7 +74,11 @@ extern int DEBUGLEVEL;
  */
 #define DEBUGTAB(n) do_debug_tab(n)
 
-/** Possible destinations for the debug log */
+/** Possible destinations for the debug log (in order of precedence -
+ * once set to DEBUG_FILE, it is not possible to reset to DEBUG_STDOUT
+ * for example.  This makes it easy to override for debug to stderr on
+ * the command line, as the smb.conf cannot reset it back to
+ * file-based logging */
 enum debug_logtype {DEBUG_STDOUT = 0, DEBUG_FILE = 1, DEBUG_STDERR = 2};
 
 /**
@@ -101,6 +105,11 @@ _PUBLIC_ void debug_schedule_reopen_logs(void);
 */
 _PUBLIC_ void setup_logging(const char *prog_name, enum debug_logtype new_logtype);
 
+/**
+   Just run logging to stdout for this program 
+*/
+_PUBLIC_ void setup_logging_stdout(void);
+
 /**
   return a string constant containing n tabs
   no more than 10 tabs are returned
index 69b304dc9c078f081d6629065f2a1e677574273e..7126d26c5997bc6d93b58202a7b4722d1068e9e6 100644 (file)
@@ -179,7 +179,7 @@ static void ndrdump_data(uint8_t *d, uint32_t l, bool force)
 
        dbf = x_stderr;
 
-       setup_logging(argv[0], true);
+       setup_logging_stdout();
 
        pc = poptGetContext("ndrdump", argc, argv, long_options, 0);
        
index 1a8a9a9538239e9610d3e08954a081be34c003b8..49afd8c46681f43ebc0a112d7d363c4c44562911 100644 (file)
@@ -466,6 +466,7 @@ void debug_message(struct messaging_context *msg_ctx, void *private_data, uint32
 void debug_init(void);
 void debug_register_msgs(struct messaging_context *msg_ctx);
 void setup_logging(const char *pname, bool interactive);
+void setup_logging_stdout( void );
 void debug_set_logfile(const char *name);
 bool reopen_logs( void );
 void force_check_log_size( void );
index 419af61ef3674d27ac75bc66cb399449e7ae6515..e7dcfb4fdf3f6b2e887224a7055f00612f5016b1 100644 (file)
@@ -605,6 +605,15 @@ void setup_logging(const char *pname, bool interactive)
 #endif
 }
 
+/**
+   Just run logging to stdout for this program 
+*/
+_PUBLIC_ void setup_logging_stdout(void)
+{
+       setup_logging(NULL, True);
+}
+
+
 /***************************************************************************
  Set the logfile name.
 **************************************************************************/