summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-03-04 20:11:46 +0000
committerNick Mathewson <nickm@torproject.org>2007-03-04 20:11:46 +0000
commit7fcceb2c25b3abdbe4c775607a0d157e9d578318 (patch)
tree3cd8ded357187a9fd9379c8174db99b4ea58cd94 /src/common
parent654924dfdfdf2c602d524f10be2628cfbfc5b877 (diff)
downloadtor-7fcceb2c25b3abdbe4c775607a0d157e9d578318.tar.gz
tor-7fcceb2c25b3abdbe4c775607a0d157e9d578318.zip
r12074@catbus: nickm | 2007-03-04 15:11:43 -0500
Make all LD_BUG log messsages get prefixed with "Bug: ". Remove manually-generated "Bug: "s from log-messages. (Apparently, we remembered to add them about 40% of the time.) svn:r9733
Diffstat (limited to 'src/common')
-rw-r--r--src/common/log.c13
-rw-r--r--src/common/util.c2
2 files changed, 10 insertions, 5 deletions
diff --git a/src/common/log.c b/src/common/log.c
index 67c7fb2a52..5d70256c42 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -96,7 +96,7 @@ static void close_log(logfile_t *victim);
* <b>buf_len</b> character buffer in <b>buf</b>.
*/
static INLINE size_t
-_log_prefix(char *buf, size_t buf_len, int severity)
+_log_prefix(char *buf, size_t buf_len, int severity, uint32_t domain)
{
time_t t;
struct timeval now;
@@ -110,7 +110,7 @@ _log_prefix(char *buf, size_t buf_len, int severity)
n = strftime(buf, buf_len, "%b %d %H:%M:%S", tor_localtime_r(&t, &tm));
r = tor_snprintf(buf+n, buf_len-n,
".%.3ld [%s] ",
- (long)now.tv_usec / 1000, sev_to_string(severity));
+ (long)now.tv_usec / 1000, sev_to_string(severity));
if (r<0)
return buf_len-1;
else
@@ -144,7 +144,7 @@ log_tor_version(logfile_t *lf, int reset)
/* We are resetting, but we aren't at the start of the file; no
* need to log again. */
return 0;
- n = _log_prefix(buf, sizeof(buf), LOG_NOTICE);
+ n = _log_prefix(buf, sizeof(buf), LOG_NOTICE, LD_GENERAL);
tor_snprintf(buf+n, sizeof(buf)-n,
"Tor %s opening %slog file.\n", VERSION, is_new?"new ":"");
if (fputs(buf, lf->file) == EOF ||
@@ -170,7 +170,7 @@ format_msg(char *buf, size_t buf_len,
tor_assert(buf_len >= 2); /* prevent integer underflow */
buf_len -= 2; /* subtract 2 characters so we have room for \n\0 */
- n = _log_prefix(buf, buf_len, severity);
+ n = _log_prefix(buf, buf_len, severity, domain);
end_of_prefix = buf+n;
if (funcname && should_log_function_name(domain, severity)) {
@@ -181,6 +181,11 @@ format_msg(char *buf, size_t buf_len,
n += r;
}
+ if (domain == LD_BUG && buf_len-n > 6) {
+ memcpy(buf+n, "Bug: ", 6);
+ n += 5;
+ }
+
r = tor_vsnprintf(buf+n,buf_len-n,format,ap);
if (r < 0) {
/* The message was too long; overwrite the end of the buffer with
diff --git a/src/common/util.c b/src/common/util.c
index c566bfe229..6c1ff3bc3b 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1242,7 +1242,7 @@ write_str_to_file(const char *fname, const char *str, int bin)
#ifdef MS_WINDOWS
if (!bin && strchr(str, '\r')) {
log_warn(LD_BUG,
- "Bug: we're writing a text string that already contains a CR.");
+ "We're writing a text string that already contains a CR.");
}
#endif
return write_bytes_to_file(fname, str, strlen(str), bin);