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.

svn:r5803
This commit is contained in:
Nick Mathewson
2006-01-11 19:40:14 +00:00
parent 856546925a
commit 099b9ce2f9
3 changed files with 83 additions and 17 deletions
+46
View File
@@ -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 *msg)
}
#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
+1
View File
@@ -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);