| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/log-utils.h" | 7 #include "src/log-utils.h" |
| 8 #include "src/string-stream.h" | 8 #include "src/string-stream.h" |
| 9 #include "src/version.h" |
| 9 | 10 |
| 10 namespace v8 { | 11 namespace v8 { |
| 11 namespace internal { | 12 namespace internal { |
| 12 | 13 |
| 13 | 14 |
| 14 const char* const Log::kLogToTemporaryFile = "&"; | 15 const char* const Log::kLogToTemporaryFile = "&"; |
| 15 const char* const Log::kLogToConsole = "-"; | 16 const char* const Log::kLogToConsole = "-"; |
| 16 | 17 |
| 17 | 18 |
| 18 Log::Log(Logger* logger) | 19 Log::Log(Logger* logger) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 42 | 43 |
| 43 // If we're logging anything, we need to open the log file. | 44 // If we're logging anything, we need to open the log file. |
| 44 if (Log::InitLogAtStart()) { | 45 if (Log::InitLogAtStart()) { |
| 45 if (strcmp(log_file_name, kLogToConsole) == 0) { | 46 if (strcmp(log_file_name, kLogToConsole) == 0) { |
| 46 OpenStdout(); | 47 OpenStdout(); |
| 47 } else if (strcmp(log_file_name, kLogToTemporaryFile) == 0) { | 48 } else if (strcmp(log_file_name, kLogToTemporaryFile) == 0) { |
| 48 OpenTemporaryFile(); | 49 OpenTemporaryFile(); |
| 49 } else { | 50 } else { |
| 50 OpenFile(log_file_name); | 51 OpenFile(log_file_name); |
| 51 } | 52 } |
| 53 |
| 54 if (output_handle_ != nullptr) { |
| 55 Log::MessageBuilder msg(this); |
| 56 msg.Append("v8-version,%d,%d,%d,%d,%d", |
| 57 Version::GetMajor(), |
| 58 Version::GetMinor(), |
| 59 Version::GetBuild(), |
| 60 Version::GetPatch(), |
| 61 Version::IsCandidate()); |
| 62 msg.WriteToLogFile(); |
| 63 } |
| 52 } | 64 } |
| 53 } | 65 } |
| 54 | 66 |
| 55 | 67 |
| 56 void Log::OpenStdout() { | 68 void Log::OpenStdout() { |
| 57 DCHECK(!IsEnabled()); | 69 DCHECK(!IsEnabled()); |
| 58 output_handle_ = stdout; | 70 output_handle_ = stdout; |
| 59 } | 71 } |
| 60 | 72 |
| 61 | 73 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 log_->message_buffer_[pos_++] = '\n'; | 237 log_->message_buffer_[pos_++] = '\n'; |
| 226 const int written = log_->WriteToFile(log_->message_buffer_, pos_); | 238 const int written = log_->WriteToFile(log_->message_buffer_, pos_); |
| 227 if (written != pos_) { | 239 if (written != pos_) { |
| 228 log_->stop(); | 240 log_->stop(); |
| 229 log_->logger_->LogFailure(); | 241 log_->logger_->LogFailure(); |
| 230 } | 242 } |
| 231 } | 243 } |
| 232 | 244 |
| 233 | 245 |
| 234 } } // namespace v8::internal | 246 } } // namespace v8::internal |
| OLD | NEW |