Index: src/log.cc |
diff --git a/src/log.cc b/src/log.cc |
index 88dae56b7b518d391b0e9dc54d4031b678dd002a..623e08d8fae6b776c0c8dad24d294f6b18132f1f 100644 |
--- a/src/log.cc |
+++ b/src/log.cc |
@@ -1936,58 +1936,48 @@ void Logger::LogAccessorCallbacks() { |
static void AddIsolateIdIfNeeded(Isolate* isolate, StringStream* stream) { |
- if (isolate->IsDefaultIsolate() || !FLAG_logfile_per_isolate) return; |
- stream->Add("isolate-%p-", isolate); |
+ if (FLAG_logfile_per_isolate) stream->Add("isolate-%p-", isolate); |
} |
static SmartArrayPointer<const char> PrepareLogFileName( |
Isolate* isolate, const char* file_name) { |
- if (strchr(file_name, '%') != NULL || !isolate->IsDefaultIsolate()) { |
- // If there's a '%' in the log file name we have to expand |
- // placeholders. |
- HeapStringAllocator allocator; |
- StringStream stream(&allocator); |
- AddIsolateIdIfNeeded(isolate, &stream); |
- for (const char* p = file_name; *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 'p': |
- stream.Add("%d", OS::GetCurrentProcessId()); |
- break; |
- case 't': { |
- // %t expands to the current time in milliseconds. |
- double time = OS::TimeCurrentMillis(); |
- stream.Add("%.0f", FmtElm(time)); |
- break; |
- } |
- case '%': |
- // %% expands (contracts really) to %. |
- stream.Put('%'); |
- break; |
- default: |
- // All other %'s expand to themselves. |
- stream.Put('%'); |
- stream.Put(*p); |
- break; |
+ HeapStringAllocator allocator; |
+ StringStream stream(&allocator); |
+ AddIsolateIdIfNeeded(isolate, &stream); |
+ for (const char* p = file_name; *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 'p': |
+ stream.Add("%d", OS::GetCurrentProcessId()); |
+ break; |
+ case 't': { |
+ // %t expands to the current time in milliseconds. |
+ double time = OS::TimeCurrentMillis(); |
+ stream.Add("%.0f", FmtElm(time)); |
+ break; |
} |
- } else { |
- stream.Put(*p); |
+ case '%': |
+ // %% expands (contracts really) to %. |
+ stream.Put('%'); |
+ break; |
+ default: |
+ // All other %'s expand to themselves. |
+ stream.Put('%'); |
+ stream.Put(*p); |
+ break; |
} |
+ } else { |
+ stream.Put(*p); |
} |
- return SmartArrayPointer<const char>(stream.ToCString()); |
} |
- int length = StrLength(file_name); |
- char* str = NewArray<char>(length + 1); |
- OS::MemCopy(str, file_name, length); |
- str[length] = '\0'; |
- return SmartArrayPointer<const char>(str); |
+ return SmartArrayPointer<const char>(stream.ToCString()); |
} |