| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 namespace internal { | 34 namespace internal { |
| 35 | 35 |
| 36 | 36 |
| 37 const char* const Log::kLogToTemporaryFile = "&"; | 37 const char* const Log::kLogToTemporaryFile = "&"; |
| 38 const char* const Log::kLogToConsole = "-"; | 38 const char* const Log::kLogToConsole = "-"; |
| 39 | 39 |
| 40 | 40 |
| 41 Log::Log(Logger* logger) | 41 Log::Log(Logger* logger) |
| 42 : is_stopped_(false), | 42 : is_stopped_(false), |
| 43 output_handle_(NULL), | 43 output_handle_(NULL), |
| 44 mutex_(NULL), | |
| 45 message_buffer_(NULL), | 44 message_buffer_(NULL), |
| 46 logger_(logger) { | 45 logger_(logger) { |
| 47 } | 46 } |
| 48 | 47 |
| 49 | 48 |
| 50 void Log::Initialize(const char* log_file_name) { | 49 void Log::Initialize(const char* log_file_name) { |
| 51 mutex_ = OS::CreateMutex(); | |
| 52 message_buffer_ = NewArray<char>(kMessageBufferSize); | 50 message_buffer_ = NewArray<char>(kMessageBufferSize); |
| 53 | 51 |
| 54 // --log-all enables all the log flags. | 52 // --log-all enables all the log flags. |
| 55 if (FLAG_log_all) { | 53 if (FLAG_log_all) { |
| 56 FLAG_log_runtime = true; | 54 FLAG_log_runtime = true; |
| 57 FLAG_log_api = true; | 55 FLAG_log_api = true; |
| 58 FLAG_log_code = true; | 56 FLAG_log_code = true; |
| 59 FLAG_log_gc = true; | 57 FLAG_log_gc = true; |
| 60 FLAG_log_suspect = true; | 58 FLAG_log_suspect = true; |
| 61 FLAG_log_handles = true; | 59 FLAG_log_handles = true; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 fclose(output_handle_); | 107 fclose(output_handle_); |
| 110 } else { | 108 } else { |
| 111 result = output_handle_; | 109 result = output_handle_; |
| 112 } | 110 } |
| 113 } | 111 } |
| 114 output_handle_ = NULL; | 112 output_handle_ = NULL; |
| 115 | 113 |
| 116 DeleteArray(message_buffer_); | 114 DeleteArray(message_buffer_); |
| 117 message_buffer_ = NULL; | 115 message_buffer_ = NULL; |
| 118 | 116 |
| 119 delete mutex_; | |
| 120 mutex_ = NULL; | |
| 121 | |
| 122 is_stopped_ = false; | 117 is_stopped_ = false; |
| 123 return result; | 118 return result; |
| 124 } | 119 } |
| 125 | 120 |
| 126 | 121 |
| 127 Log::MessageBuilder::MessageBuilder(Log* log) | 122 Log::MessageBuilder::MessageBuilder(Log* log) |
| 128 : log_(log), | 123 : log_(log), |
| 129 sl(log_->mutex_), | 124 lock_guard_(&log_->mutex_), |
| 130 pos_(0) { | 125 pos_(0) { |
| 131 ASSERT(log_->message_buffer_ != NULL); | 126 ASSERT(log_->message_buffer_ != NULL); |
| 132 } | 127 } |
| 133 | 128 |
| 134 | 129 |
| 135 void Log::MessageBuilder::Append(const char* format, ...) { | 130 void Log::MessageBuilder::Append(const char* format, ...) { |
| 136 Vector<char> buf(log_->message_buffer_ + pos_, | 131 Vector<char> buf(log_->message_buffer_ + pos_, |
| 137 Log::kMessageBufferSize - pos_); | 132 Log::kMessageBufferSize - pos_); |
| 138 va_list args; | 133 va_list args; |
| 139 va_start(args, format); | 134 va_start(args, format); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 ASSERT(pos_ <= Log::kMessageBufferSize); | 250 ASSERT(pos_ <= Log::kMessageBufferSize); |
| 256 const int written = log_->WriteToFile(log_->message_buffer_, pos_); | 251 const int written = log_->WriteToFile(log_->message_buffer_, pos_); |
| 257 if (written != pos_) { | 252 if (written != pos_) { |
| 258 log_->stop(); | 253 log_->stop(); |
| 259 log_->logger_->LogFailure(); | 254 log_->logger_->LogFailure(); |
| 260 } | 255 } |
| 261 } | 256 } |
| 262 | 257 |
| 263 | 258 |
| 264 } } // namespace v8::internal | 259 } } // namespace v8::internal |
| OLD | NEW |