Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Unified Diff: src/log.cc

Issue 7403: Timestamps in log file names (Closed)
Patch Set: Created 12 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index 72eb455b2ac3532bdc357aa8a2347ce8f65e71ee..4505449d5206e4637d93535b7781df59d1e22b69 100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -31,6 +31,7 @@
#include "log.h"
#include "platform.h"
+#include "string-stream.h"
namespace v8 { namespace internal {
@@ -686,6 +687,37 @@ bool Logger::Setup() {
if (open_log_file) {
if (strcmp(FLAG_logfile, "-") == 0) {
logfile_ = stdout;
+ } else if (strchr(FLAG_logfile, '%') != NULL) {
+ // If there's a '%' in the log file name we have to expand
+ // placeholders.
+ HeapStringAllocator allocator;
+ StringStream stream(&allocator);
+ for (const char* p = FLAG_logfile; *p; p++) {
+ if (*p == '%') {
+ p++;
+ switch (*p) {
+ case '\0':
+ // If there's a % at the end of the string we back up
+ // one character so we can escape the loop properly.
+ p--;
+ break;
+ case 't': {
+ // %t expands to the current time in milliseconds.
+ uint32_t time = static_cast<uint32_t>(OS::TimeCurrentMillis());
+ stream.Add("%u", time);
+ break;
+ }
+ default:
+ // All other %'s expand to themselves.
Erik Corry 2008/10/15 08:36:01 IMHO they should expand to % followed by themselve
Christian Plesner Hansen 2008/10/15 08:46:32 Sure, I'll change it -- I don't really care. I di
+ stream.Put(*p);
+ break;
+ }
+ } else {
+ stream.Put(*p);
+ }
+ }
+ SmartPointer<char> expanded = stream.ToCString();
+ logfile_ = OS::FOpen(*expanded, "w");
} else {
logfile_ = OS::FOpen(FLAG_logfile, "w");
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698