Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(740)

Unified Diff: runtime/vm/log.h

Issue 1314673008: Migrate logging infrastructure Isolate->Thread (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add TODO regarding filtering. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/log.h
diff --git a/runtime/vm/log.h b/runtime/vm/log.h
index f4c58e964cffb4b30c51dbf1a0186b8ab32d4d82..fab7c96c886d0f4d867ed60b8f6c939d4acf7a5a 100644
--- a/runtime/vm/log.h
+++ b/runtime/vm/log.h
@@ -11,26 +11,26 @@
namespace dart {
-class Isolate;
class LogBlock;
class Thread;
#if defined(_MSC_VER)
-#define ISL_Print(format, ...) \
- Isolate::Current()->Log()->Print(format, __VA_ARGS__)
+#define THR_Print(format, ...) \
+ Thread::Current()->Log()->Print(format, __VA_ARGS__)
#else
-#define ISL_Print(format, ...) \
- Isolate::Current()->Log()->Print(format, ##__VA_ARGS__)
+#define THR_Print(format, ...) \
+ Thread::Current()->Log()->Print(format, ##__VA_ARGS__)
#endif
-#define ISL_VPrint(format, args) \
- Isolate::Current()->Log()->VPrint(format, args)
+#define THR_VPrint(format, args) \
+ Thread::Current()->Log()->VPrint(format, args)
typedef void (*LogPrinter)(const char* str, ...);
class Log {
public:
explicit Log(LogPrinter printer = OS::Print);
+ ~Log();
// Append a formatted string to the log.
void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
@@ -47,6 +47,9 @@ class Log {
// Current cursor.
intptr_t cursor() const;
+ // Returns false if we should drop log messages related to 'isolate'.
+ static bool ShouldLogForIsolate(const Isolate* isolate);
+
// A logger that does nothing.
static Log* NoOpLog();
@@ -70,32 +73,21 @@ class Log {
// Can be nested.
class LogBlock : public StackResource {
public:
- LogBlock(Isolate* isolate, Log* log)
- : StackResource(isolate),
- log_(log), cursor_(log->cursor()) {
- CommonConstructor();
+ LogBlock(Thread* thread, Log* log) : StackResource(thread) {
+ Initialize(log);
}
- explicit LogBlock(Isolate* isolate);
- explicit LogBlock(Thread* thread);
-
- LogBlock(Thread* thread, Log* log);
-
- ~LogBlock() {
- CommonDestructor();
+ explicit LogBlock(Thread* thread) : StackResource(thread) {
+ Initialize(thread->Log());
}
+ ~LogBlock();
+
private:
- void CommonConstructor() {
- log_->EnableManualFlush();
- }
+ void Initialize(Log* log);
- void CommonDestructor() {
- log_->Flush(cursor_);
- log_->DisableManualFlush();
- }
Log* log_;
- const intptr_t cursor_;
+ intptr_t cursor_;
};
} // namespace dart
« no previous file with comments | « runtime/vm/locations.cc ('k') | runtime/vm/log.cc » ('j') | runtime/vm/thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698