aboutsummaryrefslogtreecommitdiff
path: root/src/common/log.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-02-21 05:57:12 +0000
committerNick Mathewson <nickm@torproject.org>2007-02-21 05:57:12 +0000
commit0fb179aa2ecbfa2e8c6a2ef287453b123471f8e9 (patch)
tree5946982409d1de433239aa06ea6a324a480eeaba /src/common/log.c
parent809a4daa5289ac0751c31690d111f2efef7d26c1 (diff)
downloadtor-0fb179aa2ecbfa2e8c6a2ef287453b123471f8e9.tar.gz
tor-0fb179aa2ecbfa2e8c6a2ef287453b123471f8e9.zip
r11860@catbus: nickm | 2007-02-21 00:56:15 -0500
Another optimization suggested by Shark output: shave off >90% of uses of logv by cutting down on calls to log_debug when log actually debugging. This is showing up in some profiles bug not others, and might be as much as 2.5%. svn:r9612
Diffstat (limited to 'src/common/log.c')
-rw-r--r--src/common/log.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/common/log.c b/src/common/log.c
index ff3be350fb..67c7fb2a52 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -86,6 +86,9 @@ static logfile_t *logfiles = NULL;
static int syslog_count = 0;
#endif
+/* What's the lowest log level anybody cares about? */
+int _log_global_min_severity = LOG_NOTICE;
+
static void delete_log(logfile_t *victim);
static void close_log(logfile_t *victim);
@@ -405,6 +408,8 @@ add_stream_log(int loglevelMin, int loglevelMax,
lf->file = stream;
lf->next = logfiles;
logfiles = lf;
+
+ _log_global_min_severity = get_min_log_level();
}
/** Add a log handler to receive messages during startup (before the real
@@ -415,6 +420,8 @@ add_temp_log(void)
{
add_stream_log(LOG_NOTICE, LOG_ERR, "<temp>", stdout);
logfiles->is_temporary = 1;
+
+ _log_global_min_severity = get_min_log_level();
}
/**
@@ -433,6 +440,8 @@ add_callback_log(int loglevelMin, int loglevelMax, log_callback cb)
lf->callback = cb;
lf->next = logfiles;
logfiles = lf;
+
+ _log_global_min_severity = get_min_log_level();
return 0;
}
@@ -449,6 +458,8 @@ change_callback_log_severity(int loglevelMin, int loglevelMax,
lf->max_loglevel = loglevelMax;
}
}
+
+ _log_global_min_severity = get_min_log_level();
}
/** Close any log handlers added by add_temp_log or marked by mark_logs_temp */
@@ -468,6 +479,8 @@ close_temp_logs(void)
p = &((*p)->next);
}
}
+
+ _log_global_min_severity = get_min_log_level();
}
/** Make all currently temporary logs (set to be closed by close_temp_logs)
@@ -506,6 +519,7 @@ add_file_log(int loglevelMin, int loglevelMax, const char *filename)
if (log_tor_version(logfiles, 0) < 0) {
delete_log(logfiles);
}
+ _log_global_min_severity = get_min_log_level();
return 0;
}
@@ -528,6 +542,8 @@ add_syslog_log(int loglevelMin, int loglevelMax)
lf->is_syslog = 1;
lf->next = logfiles;
logfiles = lf;
+
+ _log_global_min_severity = get_min_log_level();
return 0;
}
#endif