| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/log.h" | 5 #include "vm/log.h" |
| 6 | 6 |
| 7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
| 8 #include "vm/thread.h" | 8 #include "vm/thread.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 134 } |
| 135 | 135 |
| 136 | 136 |
| 137 Log Log::noop_log_; | 137 Log Log::noop_log_; |
| 138 Log* Log::NoOpLog() { | 138 Log* Log::NoOpLog() { |
| 139 return &noop_log_; | 139 return &noop_log_; |
| 140 } | 140 } |
| 141 | 141 |
| 142 | 142 |
| 143 void Log::TerminateString() { | 143 void Log::TerminateString() { |
| 144 if (this == NoOpLog()) { |
| 145 return; |
| 146 } |
| 144 buffer_.Add('\0'); | 147 buffer_.Add('\0'); |
| 145 } | 148 } |
| 146 | 149 |
| 147 | 150 |
| 148 void Log::EnableManualFlush() { | 151 void Log::EnableManualFlush() { |
| 152 if (this == NoOpLog()) { |
| 153 return; |
| 154 } |
| 149 manual_flush_++; | 155 manual_flush_++; |
| 150 } | 156 } |
| 151 | 157 |
| 152 | 158 |
| 153 void Log::DisableManualFlush() { | 159 void Log::DisableManualFlush() { |
| 160 if (this == NoOpLog()) { |
| 161 return; |
| 162 } |
| 163 |
| 154 manual_flush_--; | 164 manual_flush_--; |
| 155 ASSERT(manual_flush_ >= 0); | 165 ASSERT(manual_flush_ >= 0); |
| 156 if (manual_flush_ == 0) { | 166 if (manual_flush_ == 0) { |
| 157 Flush(); | 167 Flush(); |
| 158 } | 168 } |
| 159 } | 169 } |
| 160 | 170 |
| 161 | 171 |
| 162 void LogBlock::Initialize() { | 172 void LogBlock::Initialize() { |
| 163 log_->EnableManualFlush(); | 173 log_->EnableManualFlush(); |
| 164 } | 174 } |
| 165 | 175 |
| 166 | 176 |
| 167 LogBlock::~LogBlock() { | 177 LogBlock::~LogBlock() { |
| 168 log_->Flush(cursor_); | 178 log_->Flush(cursor_); |
| 169 log_->DisableManualFlush(); | 179 log_->DisableManualFlush(); |
| 170 } | 180 } |
| 171 | 181 |
| 172 } // namespace dart | 182 } // namespace dart |
| OLD | NEW |