aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-06-30 16:35:11 +0000
committerNick Mathewson <nickm@torproject.org>2004-06-30 16:35:11 +0000
commit653aaeef08764b80820f87b916f5833f64f9ebbe (patch)
tree7627226bcfb7631073d87f78b7e7647eed744fb4
parent899bd4f47111173d66327fa228aca18bb3cb6d16 (diff)
downloadtor-653aaeef08764b80820f87b916f5833f64f9ebbe.tar
tor-653aaeef08764b80820f87b916f5833f64f9ebbe.tar.gz
Always log version when starting tor.
svn:r1990
-rw-r--r--src/common/log.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/common/log.c b/src/common/log.c
index 05f656c17..b05b63271 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -70,10 +70,11 @@ static INLINE size_t _log_prefix(char *buf, size_t buf_len, int severity)
/** If lf refers to an actual file that we have just opened, and the file
* contains no data, log an "opening new logfile" message at the top. **/
-static void log_tor_version(logfile_t *lf)
+static void log_tor_version(logfile_t *lf, int reset)
{
char buf[256];
size_t n;
+ int is_new;
if (!lf->needs_close)
/* If it doesn't get closed, it isn't really a file. */
@@ -81,11 +82,14 @@ static void log_tor_version(logfile_t *lf)
if (lf->is_temporary)
/* If it's temporary, it isn't really a file. */
return;
- if (ftell(lf->file) != 0)
- /* We aren't at the start of the file; no need to log. */
+ is_new = (ftell(lf->file) == 0);
+ if (reset && !is_new)
+ /* We are resetting, but we aren't at the start of the file; no
+ * need to log again. */
return;
n = _log_prefix(buf, 250, LOG_NOTICE);
- n += snprintf(buf+n, 250-n, "Tor %s creating new log file\n", VERSION);
+ n += snprintf(buf+n, 250-n, "Tor %s opening %slog file\n", VERSION,
+ is_new?"new ":"");
if (n>250)
n = 250;
buf[n+1]='\0';
@@ -190,7 +194,7 @@ void reset_logs()
if (lf->needs_close) {
fclose(lf->file);
lf->file = fopen(lf->filename, "a");
- log_tor_version(lf);
+ log_tor_version(lf, 1);
}
}
}
@@ -256,7 +260,7 @@ int add_file_log(int loglevelMin, int loglevelMax, const char *filename)
if (!f) return -1;
add_stream_log(loglevelMin, loglevelMax, filename, f);
logfiles->needs_close = 1;
- log_tor_version(logfiles);
+ log_tor_version(logfiles, 0);
return 0;
}