mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[vm] buffer size based log flushing
Useful when debugging on Android, since adb logcat truncates messages that are "too long" (and always flushing would result in too many short messages). Change-Id: I51978b4e352d65c9074ab1d830b042f68e06710d Reviewed-on: https://dart-review.googlesource.com/70740 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Aart Bik <ajcbik@google.com>
This commit is contained in:
parent
dec1da2437
commit
7f88b64e0a
|
@ -12,6 +12,15 @@ namespace dart {
|
|||
|
||||
DEFINE_FLAG(bool, force_log_flush, false, "Always flush log messages.");
|
||||
|
||||
// The following flag is useful when debugging on Android, since
|
||||
// adb logcat truncates messages that are "too long" (and always
|
||||
// flushing would result in too many short messages).
|
||||
DEFINE_FLAG(
|
||||
int,
|
||||
force_log_flush_at_size,
|
||||
0,
|
||||
"Flush log messages when buffer exceeds given size (disabled when 0).");
|
||||
|
||||
DEFINE_FLAG(charp,
|
||||
isolate_log_filter,
|
||||
NULL,
|
||||
|
@ -80,7 +89,7 @@ void Log::VPrint(const char* format, va_list args) {
|
|||
}
|
||||
free(buffer);
|
||||
|
||||
if ((manual_flush_ == 0) || FLAG_force_log_flush) {
|
||||
if (ShouldFlush()) {
|
||||
Flush();
|
||||
}
|
||||
}
|
||||
|
@ -161,6 +170,12 @@ void Log::DisableManualFlush(const intptr_t cursor) {
|
|||
}
|
||||
}
|
||||
|
||||
bool Log::ShouldFlush() const {
|
||||
return ((manual_flush_ == 0) || FLAG_force_log_flush ||
|
||||
((FLAG_force_log_flush_at_size > 0) &&
|
||||
(cursor() > FLAG_force_log_flush_at_size)));
|
||||
}
|
||||
|
||||
void LogBlock::Initialize() {
|
||||
log_->EnableManualFlush();
|
||||
}
|
||||
|
|
|
@ -54,6 +54,9 @@ class Log {
|
|||
void EnableManualFlush();
|
||||
void DisableManualFlush(const intptr_t cursor);
|
||||
|
||||
// Returns true when flush is required.
|
||||
bool ShouldFlush() const;
|
||||
|
||||
// Returns false if we should drop log messages related to 'isolate'.
|
||||
static bool ShouldLogForIsolate(const Isolate* isolate);
|
||||
|
||||
|
|
Loading…
Reference in a new issue