[or-cvs] r14222: Add --hush switch. New --hush command-line option similar to (in tor/trunk: . src/common src/or)

weasel at seul.org weasel at seul.org
Thu Mar 27 17:25:49 UTC 2008


Author: weasel
Date: 2008-03-27 13:25:49 -0400 (Thu, 27 Mar 2008)
New Revision: 14222

Modified:
   tor/trunk/ChangeLog
   tor/trunk/src/common/log.c
   tor/trunk/src/common/log.h
   tor/trunk/src/or/config.c
   tor/trunk/src/or/main.c
Log:
Add --hush switch.

New --hush command-line option similar to --quiet.  While --quiet disables all
logging to the console on startup, --hush limits the output to messages of
warning and error severity.


Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-03-27 17:20:13 UTC (rev 14221)
+++ tor/trunk/ChangeLog	2008-03-27 17:25:49 UTC (rev 14222)
@@ -47,6 +47,9 @@
       this accounted for over 40% of allocations from within Tor's code
       on a typical directory cache.
     - Lots of new unit tests.
+    - New --hush command-line option similar to --quiet.  While --quiet
+      disables all logging to the console on startup, --hush limits the
+      output to messages of warning and error severity.
 
   o Code simplifications and refactoring:
     - Refactor code using connection_ap_handshake_attach_circuit() to

Modified: tor/trunk/src/common/log.c
===================================================================
--- tor/trunk/src/common/log.c	2008-03-27 17:20:13 UTC (rev 14221)
+++ tor/trunk/src/common/log.c	2008-03-27 17:25:49 UTC (rev 14222)
@@ -535,10 +535,10 @@
  * logs are initialized).
  */
 void
-add_temp_log(void)
+add_temp_log(int min_severity)
 {
   log_severity_list_t *s = tor_malloc_zero(sizeof(log_severity_list_t));
-  set_log_severity_config(LOG_NOTICE, LOG_ERR, s);
+  set_log_severity_config(min_severity, LOG_ERR, s);
   LOCK_LOGS();
   add_stream_log_impl(s, "<temp>", stdout);
   tor_free(s);

Modified: tor/trunk/src/common/log.h
===================================================================
--- tor/trunk/src/common/log.h	2008-03-27 17:20:13 UTC (rev 14221)
+++ tor/trunk/src/common/log.h	2008-03-27 17:25:49 UTC (rev 14222)
@@ -130,7 +130,7 @@
 int get_min_log_level(void);
 void switch_logs_debug(void);
 void logs_free_all(void);
-void add_temp_log(void);
+void add_temp_log(int min_severity);
 void close_temp_logs(void);
 void rollback_log_changes(void);
 void mark_logs_temp(void);

Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2008-03-27 17:20:13 UTC (rev 14221)
+++ tor/trunk/src/or/config.c	2008-03-27 17:25:49 UTC (rev 14222)
@@ -1343,7 +1343,8 @@
     } else if (!strcmp(argv[i],"--list-fingerprint") ||
                !strcmp(argv[i],"--verify-config") ||
                !strcmp(argv[i],"--ignore-missing-torrc") ||
-               !strcmp(argv[i],"--quiet")) {
+               !strcmp(argv[i],"--quiet") ||
+               !strcmp(argv[i],"--hush")) {
       i += 1; /* command-line option. ignore it. */
       continue;
     } else if (!strcmp(argv[i],"--nt-service") ||

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2008-03-27 17:20:13 UTC (rev 14221)
+++ tor/trunk/src/or/main.c	2008-03-27 17:25:49 UTC (rev 14222)
@@ -1780,12 +1780,21 @@
   /* We search for the "quiet" option first, since it decides whether we
    * will log anything at all to the command line. */
   for (i=1;i<argc;++i) {
+    if (!strcmp(argv[i], "--hush"))
+      quiet = 1;
     if (!strcmp(argv[i], "--quiet"))
-      quiet = 1;
+      quiet = 2;
   }
-  if (!quiet) {
-    /* give it somewhere to log to initially */
-    add_temp_log();
+ /* give it somewhere to log to initially */
+  switch (quiet) {
+    case 2:
+      /* no initial logging */
+      break;
+    case 1:
+      add_temp_log(LOG_WARN);
+      break;
+    default:
+      add_temp_log(LOG_NOTICE);
   }
 
   log(LOG_NOTICE, LD_GENERAL, "Tor v%s. This is experimental software. "



More information about the tor-commits mailing list