| 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 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 va_start(args, format); | 105 va_start(args, format); |
| 106 AppendVA(format, args); | 106 AppendVA(format, args); |
| 107 va_end(args); | 107 va_end(args); |
| 108 ASSERT(pos_ <= Log::kMessageBufferSize); | 108 ASSERT(pos_ <= Log::kMessageBufferSize); |
| 109 } | 109 } |
| 110 | 110 |
| 111 | 111 |
| 112 void Log::MessageBuilder::AppendVA(const char* format, va_list args) { | 112 void Log::MessageBuilder::AppendVA(const char* format, va_list args) { |
| 113 Vector<char> buf(log_->message_buffer_ + pos_, | 113 Vector<char> buf(log_->message_buffer_ + pos_, |
| 114 Log::kMessageBufferSize - pos_); | 114 Log::kMessageBufferSize - pos_); |
| 115 int result = v8::internal::OS::VSNPrintF(buf, format, args); | 115 int result = v8::internal::VSNPrintF(buf, format, args); |
| 116 | 116 |
| 117 // Result is -1 if output was truncated. | 117 // Result is -1 if output was truncated. |
| 118 if (result >= 0) { | 118 if (result >= 0) { |
| 119 pos_ += result; | 119 pos_ += result; |
| 120 } else { | 120 } else { |
| 121 pos_ = Log::kMessageBufferSize; | 121 pos_ = Log::kMessageBufferSize; |
| 122 } | 122 } |
| 123 ASSERT(pos_ <= Log::kMessageBufferSize); | 123 ASSERT(pos_ <= Log::kMessageBufferSize); |
| 124 } | 124 } |
| 125 | 125 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 | 205 |
| 206 void Log::MessageBuilder::AppendStringPart(const char* str, int len) { | 206 void Log::MessageBuilder::AppendStringPart(const char* str, int len) { |
| 207 if (pos_ + len > Log::kMessageBufferSize) { | 207 if (pos_ + len > Log::kMessageBufferSize) { |
| 208 len = Log::kMessageBufferSize - pos_; | 208 len = Log::kMessageBufferSize - pos_; |
| 209 ASSERT(len >= 0); | 209 ASSERT(len >= 0); |
| 210 if (len == 0) return; | 210 if (len == 0) return; |
| 211 } | 211 } |
| 212 Vector<char> buf(log_->message_buffer_ + pos_, | 212 Vector<char> buf(log_->message_buffer_ + pos_, |
| 213 Log::kMessageBufferSize - pos_); | 213 Log::kMessageBufferSize - pos_); |
| 214 OS::StrNCpy(buf, str, len); | 214 StrNCpy(buf, str, len); |
| 215 pos_ += len; | 215 pos_ += len; |
| 216 ASSERT(pos_ <= Log::kMessageBufferSize); | 216 ASSERT(pos_ <= Log::kMessageBufferSize); |
| 217 } | 217 } |
| 218 | 218 |
| 219 | 219 |
| 220 void Log::MessageBuilder::WriteToLogFile() { | 220 void Log::MessageBuilder::WriteToLogFile() { |
| 221 ASSERT(pos_ <= Log::kMessageBufferSize); | 221 ASSERT(pos_ <= Log::kMessageBufferSize); |
| 222 const int written = log_->WriteToFile(log_->message_buffer_, pos_); | 222 const int written = log_->WriteToFile(log_->message_buffer_, pos_); |
| 223 if (written != pos_) { | 223 if (written != pos_) { |
| 224 log_->stop(); | 224 log_->stop(); |
| 225 log_->logger_->LogFailure(); | 225 log_->logger_->LogFailure(); |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 | 228 |
| 229 | 229 |
| 230 } } // namespace v8::internal | 230 } } // namespace v8::internal |
| OLD | NEW |