diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-09-29 18:13:29 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-09-29 18:13:29 +0000 |
commit | 05604c60d42afc8dd006c67fad592275b24929a7 (patch) | |
tree | 7ff9a08c19a496b8ce6cc01e38ef664e5d83227f | |
parent | 0335bd51d384ed6d075413580eefa1248c730d0f (diff) | |
download | tor-05604c60d42afc8dd006c67fad592275b24929a7.tar tor-05604c60d42afc8dd006c67fad592275b24929a7.tar.gz |
r9006@Kushana: nickm | 2006-09-29 10:48:23 -0400
Omit function names from NOTICE, WARN and ERR messages unless they are in LD_BUG.
svn:r8534
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/common/log.c | 26 |
2 files changed, 26 insertions, 3 deletions
@@ -42,6 +42,9 @@ Changes in version 0.1.2.2-alpha - 2006-??-?? any router is the canonical Unnamed. - New controller event to alert the controller when our server descriptor has changed. + - Only include function names in log messages for debugging messages; + in other cases, the content of the message should be clear on its own, + and including the function name only seems to confuse users. o Security Fixes, minor: - If a client asked for a server by name, and we didn't have a diff --git a/src/common/log.c b/src/common/log.c index 1d9c10d56..d6c5699f2 100644 --- a/src/common/log.c +++ b/src/common/log.c @@ -60,6 +60,26 @@ sev_to_string(int severity) } } +/** Helper: decide whether to include the function name in the log message. + * */ +static INLINE int +should_log_function_name(uint32_t domain, int severity) +{ + switch (severity) { + case LOG_DEBUG: + case LOG_INFO: + /* All debugging messages occur in interesting places. */ + return 1; + case LOG_NOTICE: + case LOG_WARN: + case LOG_ERR: + /* We care about places where bugs occur. */ + return (domain == LD_BUG); + default: + assert(0); return 0; + } +} + /** Linked list of logfile_t. */ static logfile_t *logfiles = NULL; #ifdef HAVE_SYSLOG_H @@ -137,7 +157,7 @@ log_tor_version(logfile_t *lf, int reset) */ static INLINE char * format_msg(char *buf, size_t buf_len, - int severity, const char *funcname, + uint32_t domain, int severity, const char *funcname, const char *format, va_list ap) { size_t n; @@ -150,7 +170,7 @@ format_msg(char *buf, size_t buf_len, n = _log_prefix(buf, buf_len, severity); end_of_prefix = buf+n; - if (funcname) { + if (funcname && should_log_function_name(domain, severity)) { r = tor_snprintf(buf+n, buf_len-n, "%s(): ", funcname); if (r<0) n = strlen(buf); @@ -206,7 +226,7 @@ logv(int severity, uint32_t domain, const char *funcname, const char *format, if (!formatted) { end_of_prefix = - format_msg(buf, sizeof(buf), severity, funcname, format, ap); + format_msg(buf, sizeof(buf), domain, severity, funcname, format, ap); formatted = 1; } if (lf->is_syslog) { |