[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Replace add_temp_log() with add_default_log().



commit 3a73f6612aad051e0d9a9228a136e06720748c16
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu Oct 17 12:30:52 2019 -0400

    Replace add_temp_log() with add_default_log().
    
    We used to have this function so that we could mark our initial
    log-to-stdout as specifically temporary so that we would delete it
    once regular logs were configured.  But it's no longer necessary to
    mark these logs as temporary, since we now use a mark-and-sweep
    process to ensure that _all_ not-configured logs are closed when we
    change our configuration.
    
    Instead, this function will be the basis of a refactoring in how we
    handle default logs.
---
 src/app/main/main.c |  4 ++--
 src/lib/log/log.c   | 11 ++++-------
 src/lib/log/log.h   |  2 +-
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/src/app/main/main.c b/src/app/main/main.c
index 2d7579336..e6bd4f30b 100644
--- a/src/app/main/main.c
+++ b/src/app/main/main.c
@@ -564,11 +564,11 @@ tor_init(int argc, char *argv[])
       break;
     case QUIET_HUSH:
       /* --hush: log at warning or higher. */
-      add_temp_log(LOG_WARN);
+      add_default_log(LOG_WARN);
       break;
     case QUIET_NONE: /* fall through */
     default:
-      add_temp_log(LOG_NOTICE);
+      add_default_log(LOG_NOTICE);
   }
   quiet_level = quiet;
 
diff --git a/src/lib/log/log.c b/src/lib/log/log.c
index 83f04a346..ddd0eac6e 100644
--- a/src/lib/log/log.c
+++ b/src/lib/log/log.c
@@ -995,18 +995,16 @@ logs_set_domain_logging(int enabled)
   UNLOCK_LOGS();
 }
 
-/** Add a log handler to receive messages during startup (before the real
- * logs are initialized).
+/** Add a log handler to accept messages when no other log is configured.
  */
 void
-add_temp_log(int min_severity)
+add_default_log(int min_severity)
 {
   log_severity_list_t *s = tor_malloc_zero(sizeof(log_severity_list_t));
   set_log_severity_config(min_severity, LOG_ERR, s);
   LOCK_LOGS();
-  add_stream_log_impl(s, "<temp>", fileno(stdout));
+  add_stream_log_impl(s, "<default>", fileno(stdout));
   tor_free(s);
-  logfiles->is_temporary = 1;
   UNLOCK_LOGS();
 }
 
@@ -1149,8 +1147,7 @@ flush_log_messages_from_startup(void)
   UNLOCK_LOGS();
 }
 
-/** Close any log handlers added by add_temp_log() or marked by
- * mark_logs_temp(). */
+/** Close any log handlers marked by mark_logs_temp(). */
 void
 close_temp_logs(void)
 {
diff --git a/src/lib/log/log.h b/src/lib/log/log.h
index 8e3601261..4dead0fd2 100644
--- a/src/lib/log/log.h
+++ b/src/lib/log/log.h
@@ -185,7 +185,7 @@ int get_min_log_level(void);
 void switch_logs_debug(void);
 void logs_free_all(void);
 void logs_close_sigsafe(void);
-void add_temp_log(int min_severity);
+void add_default_log(int min_severity);
 void close_temp_logs(void);
 void rollback_log_changes(void);
 void mark_logs_temp(void);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits