[or-cvs] Fix bug 230: add a rollback function to reverse all changes...

Nick Mathewson nickm at seul.org
Wed Jan 11 19:40:16 UTC 2006


Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv24293/src/common

Modified Files:
	log.c log.h 
Log Message:
Fix bug 230: add a rollback function to reverse all changes since the last mark_logs_temp(), and move log initialization into the two-phase part of option setting.

Index: log.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/log.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -p -d -r1.110 -r1.111
--- log.c	14 Dec 2005 20:40:39 -0000	1.110
+++ log.c	11 Jan 2006 19:40:14 -0000	1.111
@@ -438,6 +438,17 @@ close_temp_logs(void)
   }
 }
 
+/** Make all currently temporary logs (set to be closed by close_temp_logs)
+ * live again, and close all non-temporary logs. */
+void
+rollback_log_changes(void)
+{
+  logfile_t *lf;
+  for (lf = logfiles; lf; lf = lf->next)
+    lf->is_temporary = ! lf->is_temporary;
+  close_temp_logs();
+}
+
 /** Configure all log handles to be closed by close_temp_logs */
 void
 mark_logs_temp(void)
@@ -590,3 +601,38 @@ suppress_libevent_log_msg(const char *ms
 }
 #endif
 
+#if 0
+static void
+dump_log_info(logfile_t *lf)
+{
+  const char *tp;
+
+  if (lf->filename) {
+    printf("=== log into \"%s\" (%s-%s) (%stemporary)\n", lf->filename,
+           sev_to_string(lf->min_loglevel),
+           sev_to_string(lf->max_loglevel),
+           lf->is_temporary?"":"not ");
+  } else if (lf->is_syslog) {
+    printf("=== syslog (%s-%s) (%stemporary)\n",
+           sev_to_string(lf->min_loglevel),
+           sev_to_string(lf->max_loglevel),
+           lf->is_temporary?"":"not ");
+  } else {
+    printf("=== log (%s-%s) (%stemporary)\n",
+           sev_to_string(lf->min_loglevel),
+           sev_to_string(lf->max_loglevel),
+           lf->is_temporary?"":"not ");
+  }
+}
+
+void
+describe_logs(void)
+{
+  logfile_t *lf;
+  printf("==== BEGIN LOGS ====\n");
+  for (lf = logfiles; lf; lf = lf->next)
+    dump_log_info(lf);
+  printf("==== END LOGS ====\n");
+}
+#endif
+

Index: log.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/log.h,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -p -d -r1.62 -r1.63
--- log.h	14 Dec 2005 20:40:39 -0000	1.62
+++ log.h	11 Jan 2006 19:40:14 -0000	1.63
@@ -107,6 +107,7 @@ void switch_logs_debug(void);
 void close_logs(void);
 void add_temp_log(void);
 void close_temp_logs(void);
+void rollback_log_changes(void);
 void mark_logs_temp(void);
 void configure_libevent_logging(void);
 void suppress_libevent_log_msg(const char *msg);



More information about the tor-commits mailing list