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 #ifndef RUNTIME_VM_LOG_H_ | 5 #ifndef RUNTIME_VM_LOG_H_ |
6 #define RUNTIME_VM_LOG_H_ | 6 #define RUNTIME_VM_LOG_H_ |
7 | 7 |
8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
10 #include "vm/os.h" | 10 #include "vm/os.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 static Log noop_log_; | 60 static Log noop_log_; |
61 LogPrinter printer_; | 61 LogPrinter printer_; |
62 intptr_t manual_flush_; | 62 intptr_t manual_flush_; |
63 MallocGrowableArray<char> buffer_; | 63 MallocGrowableArray<char> buffer_; |
64 | 64 |
65 friend class LogBlock; | 65 friend class LogBlock; |
66 friend class LogTestHelper; | 66 friend class LogTestHelper; |
67 DISALLOW_COPY_AND_ASSIGN(Log); | 67 DISALLOW_COPY_AND_ASSIGN(Log); |
68 }; | 68 }; |
69 | 69 |
70 | |
71 // Causes all log messages to be buffered until destructor is called. | 70 // Causes all log messages to be buffered until destructor is called. |
72 // Can be nested. | 71 // Can be nested. |
73 class LogBlock : public StackResource { | 72 class LogBlock : public StackResource { |
74 public: | 73 public: |
75 LogBlock(Thread* thread, Log* log) | 74 LogBlock(Thread* thread, Log* log) |
76 : StackResource(thread), log_(log), cursor_(log->cursor()) { | 75 : StackResource(thread), log_(log), cursor_(log->cursor()) { |
77 Initialize(); | 76 Initialize(); |
78 } | 77 } |
79 | 78 |
80 LogBlock() | 79 LogBlock() |
81 : StackResource(Thread::Current()), | 80 : StackResource(Thread::Current()), |
82 log_(Log::Current()), | 81 log_(Log::Current()), |
83 cursor_(Log::Current()->cursor()) { | 82 cursor_(Log::Current()->cursor()) { |
84 Initialize(); | 83 Initialize(); |
85 } | 84 } |
86 | 85 |
87 ~LogBlock(); | 86 ~LogBlock(); |
88 | 87 |
89 private: | 88 private: |
90 void Initialize(); | 89 void Initialize(); |
91 | 90 |
92 Log* const log_; | 91 Log* const log_; |
93 const intptr_t cursor_; | 92 const intptr_t cursor_; |
94 }; | 93 }; |
95 | 94 |
96 } // namespace dart | 95 } // namespace dart |
97 | 96 |
98 #endif // RUNTIME_VM_LOG_H_ | 97 #endif // RUNTIME_VM_LOG_H_ |
OLD | NEW |