[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r10291: Use svn revisions consistently throughout all log messages. (in tor/trunk: . src/common src/or)
- To: or-cvs@xxxxxxxxxxxxx
- Subject: [or-cvs] r10291: Use svn revisions consistently throughout all log messages. (in tor/trunk: . src/common src/or)
- From: nickm@xxxxxxxx
- Date: Tue, 22 May 2007 11:48:52 -0400 (EDT)
- Delivered-to: archiver@seul.org
- Delivered-to: or-cvs-outgoing@seul.org
- Delivered-to: or-cvs@seul.org
- Delivery-date: Tue, 22 May 2007 11:49:08 -0400
- Reply-to: or-dev@xxxxxxxxxxxxx
- Sender: owner-or-cvs@xxxxxxxxxxxxx
Author: nickm
Date: 2007-05-22 11:48:46 -0400 (Tue, 22 May 2007)
New Revision: 10291
Modified:
tor/trunk/
tor/trunk/src/common/log.c
tor/trunk/src/common/log.h
tor/trunk/src/or/config.c
tor/trunk/src/or/control.c
tor/trunk/src/or/main.c
tor/trunk/src/or/or.h
tor/trunk/src/or/router.c
Log:
r12852@catbus: nickm | 2007-05-22 11:00:27 -0400
Use svn revisions consistently throughout all log messages.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r12852] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/src/common/log.c
===================================================================
--- tor/trunk/src/common/log.c 2007-05-22 05:29:10 UTC (rev 10290)
+++ tor/trunk/src/common/log.c 2007-05-22 15:48:46 UTC (rev 10291)
@@ -88,6 +88,17 @@
static void delete_log(logfile_t *victim);
static void close_log(logfile_t *victim);
+/** DOCDOC */
+static char *appname = NULL;
+
+/** DOCDOC */
+void
+log_set_application_name(const char *name)
+{
+ tor_free(appname);
+ appname = name ? tor_strdup(name) : NULL;
+}
+
/** Helper: Write the standard prefix for log lines to a
* <b>buf_len</b> character buffer in <b>buf</b>.
*/
@@ -140,8 +151,13 @@
* need to log again. */
return 0;
n = _log_prefix(buf, sizeof(buf), LOG_NOTICE);
- tor_snprintf(buf+n, sizeof(buf)-n,
- "Tor %s opening %slog file.\n", VERSION, is_new?"new ":"");
+ if (appname) {
+ tor_snprintf(buf+n, sizeof(buf)-n,
+ "%s opening %slog file.\n", appname, is_new?"new ":"");
+ } else {
+ tor_snprintf(buf+n, sizeof(buf)-n,
+ "Tor %s opening %slog file.\n", VERSION, is_new?"new ":"");
+ }
if (fputs(buf, lf->file) == EOF ||
fflush(lf->file) == EOF) /* error */
return -1; /* failed */
Modified: tor/trunk/src/common/log.h
===================================================================
--- tor/trunk/src/common/log.h 2007-05-22 05:29:10 UTC (rev 10290)
+++ tor/trunk/src/common/log.h 2007-05-22 15:48:46 UTC (rev 10291)
@@ -113,6 +113,7 @@
void suppress_libevent_log_msg(const char *msg);
void change_callback_log_severity(int loglevelMin, int loglevelMax,
log_callback cb);
+void log_set_application_name(const char *name);
/* Outputs a message to stdout */
void _log(int severity, uint32_t domain, const char *format, ...)
Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c 2007-05-22 05:29:10 UTC (rev 10290)
+++ tor/trunk/src/or/config.c 2007-05-22 15:48:46 UTC (rev 10291)
@@ -697,6 +697,25 @@
return 0;
}
+extern const char tor_svn_revision[]; /* from main.c */
+
+/** Return the current Tor version, possibly */
+const char *
+get_version(void)
+{
+ static char *version = NULL;
+ if (version == NULL) {
+ if (strlen(tor_svn_revision)) {
+ size_t len = strlen(VERSION)+strlen(tor_svn_revision)+8;
+ version = tor_malloc(len);
+ tor_snprintf(version, len, "%s (r%s)", VERSION, tor_svn_revision);
+ } else {
+ version = tor_strdup(VERSION);
+ }
+ }
+ return version;
+}
+
/** Release all memory and resources held by global configuration structures.
*/
void
@@ -3080,8 +3099,6 @@
return r;
}
-extern const char tor_svn_revision[]; /* from main.c */
-
/** Read a configuration file into <b>options</b>, finding the configuration
* file location based on the command line. After loading the options,
* validate them for consistency, then take actions based on them.
@@ -3118,13 +3135,7 @@
}
if (argc > 1 && (!strcmp(argv[1],"--version"))) {
- char vbuf[128];
- if (strlen(tor_svn_revision)) {
- tor_snprintf(vbuf, sizeof(vbuf), " (r%s)", tor_svn_revision);
- } else {
- vbuf[0] = 0;
- }
- printf("Tor version %s%s.\n",VERSION,vbuf);
+ printf("Tor version %s.\n",get_version());
if (argc > 2 && (!strcmp(argv[2],"--version"))) {
print_svn_version();
}
@@ -4311,7 +4322,10 @@
global_state->LastWritten = time(NULL);
tor_free(global_state->TorVersion);
- global_state->TorVersion = tor_strdup("Tor " VERSION);
+ len = strlen(get_version())+8;
+ global_state->TorVersion = tor_malloc(len);
+ tor_snprintf(global_state->TorVersion, len, "Tor %s", get_version());
+
state = config_dump(&state_format, global_state, 1, 0);
len = strlen(state)+256;
contents = tor_malloc(len);
Modified: tor/trunk/src/or/control.c
===================================================================
--- tor/trunk/src/or/control.c 2007-05-22 05:29:10 UTC (rev 10290)
+++ tor/trunk/src/or/control.c 2007-05-22 15:48:46 UTC (rev 10291)
@@ -1184,7 +1184,7 @@
{
(void) conn;
if (!strcmp(question, "version")) {
- *answer = tor_strdup(VERSION);
+ *answer = tor_strdup(get_version());
} else if (!strcmp(question, "config-file")) {
*answer = tor_strdup(get_torrc_fname());
} else if (!strcmp(question, "info/names")) {
@@ -2301,8 +2301,9 @@
char buf[128];
set_uint16(buf+2, htons(0x0000)); /* type == error */
set_uint16(buf+4, htons(0x0001)); /* code == internal error */
- strlcpy(buf+6, "The v0 control protocol no longer supported in "VERSION"; "
- "use Tor 0.1.2.x or upgrade your controller", sizeof(buf)-6);
+ strlcpy(buf+6, "The v0 control protocol is not supported by Tor 0.2.0.x "
+ "and later; use Tor 0.1.2.x or upgrade your controller",
+ sizeof(buf)-6);
body_len = 2+strlen(buf+6)+2; /* code, msg, nul. */
set_uint16(buf+0, htons(body_len));
connection_write_to_buf(buf, 4+body_len, TO_CONN(conn));
Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c 2007-05-22 05:29:10 UTC (rev 10290)
+++ tor/trunk/src/or/main.c 2007-05-22 15:48:46 UTC (rev 10291)
@@ -1684,11 +1684,15 @@
static int
tor_init(int argc, char *argv[])
{
+ char buf[256];
time_of_process_start = time(NULL);
if (!closeable_connection_lst)
closeable_connection_lst = smartlist_create();
if (!active_linked_connection_lst)
active_linked_connection_lst = smartlist_create();
+ /* Have the log set up with our application name. */
+ tor_snprintf(buf, sizeof(buf), "Tor %s", get_version());
+ log_set_application_name(buf);
/* Initialize the history structures. */
rep_hist_init();
/* Initialize the service cache. */
@@ -1700,7 +1704,7 @@
add_temp_log();
log(LOG_NOTICE, LD_GENERAL, "Tor v%s. This is experimental software. "
- "Do not rely on it for strong anonymity. (Running on %s)",VERSION,
+ "Do not rely on it for strong anonymity. (Running on %s)",get_version(),
get_uname());
if (network_init()<0) {
Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h 2007-05-22 05:29:10 UTC (rev 10290)
+++ tor/trunk/src/or/or.h 2007-05-22 15:48:46 UTC (rev 10291)
@@ -2223,6 +2223,7 @@
void config_free_all(void);
const char *safe_str(const char *address);
const char *escaped_safe_str(const char *address);
+const char *get_version(void);
int config_get_lines(char *string, config_line_t **result);
void config_free_lines(config_line_t *front);
Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c 2007-05-22 05:29:10 UTC (rev 10290)
+++ tor/trunk/src/or/router.c 2007-05-22 15:48:46 UTC (rev 10291)
@@ -1249,17 +1249,7 @@
void
get_platform_str(char *platform, size_t len)
{
- char svn_version_buf[128];
- if (!strcmpend(VERSION, "-dev") && strlen(tor_svn_revision)) {
- tor_snprintf(svn_version_buf, sizeof(svn_version_buf), " (r%s)",
- tor_svn_revision);
- } else {
- svn_version_buf[0] = 0;
- }
-
- tor_snprintf(platform, len, "Tor %s%s on %s",
- VERSION, svn_version_buf, get_uname());
- return;
+ tor_snprintf(platform, len, "Tor %s on %s", get_version(), get_uname());
}
/* XXX need to audit this thing and count fenceposts. maybe