14DEFINE_FLAG(
bool, force_log_flush,
false,
"Always flush log messages.");
21 force_log_flush_at_size,
23 "Flush log messages when buffer exceeds given size (disabled when 0).");
28 "Log isolates whose name include the filter. "
29 "Default: service isolate log messages are suppressed "
30 "(specify 'vm-service' to log them).");
33 redirect_isolate_log_to,
35 "Log isolate messages into the given file.");
41 static LogFile log_file;
45 static void Print(
const char*
data) {
51 :
handle_(Dart::file_open_callback()(FLAG_redirect_isolate_log_to,
61 if (printer_ ==
nullptr) {
62 if (FLAG_redirect_isolate_log_to ==
nullptr) {
65 printer_ = &LogFile::Print;
77 if (thread ==
nullptr) {
79 ASSERT(os_thread !=
nullptr);
80 return os_thread->
log();
83 if ((isolate_group !=
nullptr) &&
84 Log::ShouldLogForIsolateGroup(isolate_group)) {
86 ASSERT(os_thread !=
nullptr);
87 return os_thread->
log();
110 va_list measure_args;
111 va_copy(measure_args,
args);
113 va_end(measure_args);
116 char*
buffer =
reinterpret_cast<char*
>(
malloc(len + 1));
118 va_copy(print_args,
args);
124 for (intptr_t i = 0; i < len; i++) {
145 const char* str = &buffer_[
cursor];
162bool Log::ShouldLogForIsolateGroup(
const IsolateGroup* isolate_group) {
163 if (FLAG_isolate_log_filter ==
nullptr) {
175 if (strstr(
name, FLAG_isolate_log_filter) ==
nullptr) {
187void Log::TerminateString() {
194void Log::EnableManualFlush() {
201void Log::DisableManualFlush(
const intptr_t cursor) {
207 ASSERT(manual_flush_ >= 0);
208 if (manual_flush_ == 0) {
213bool Log::ShouldFlush()
const {
214#ifdef DART_TARGET_OS_ANDROID
217 if (*(buffer_.
end() - 1) ==
'\n') {
221 return ((manual_flush_ == 0) || FLAG_force_log_flush ||
222 ((FLAG_force_log_flush_at_size > 0) &&
223 (
cursor() > FLAG_force_log_flush_at_size)));
226void LogBlock::Initialize() {
227 log_->EnableManualFlush();
231 log_->DisableManualFlush(cursor_);
void TruncateTo(intptr_t length)
static Dart_FileWriteCallback file_write_callback()
static IsolateGroup * vm_isolate_group()
static Dart_FileCloseCallback file_close_callback()
static bool IsSystemIsolateGroup(const IsolateGroup *group)
IsolateGroupSource * source() const
void Print(const char *format,...) PRINTF_ATTRIBUTE(2
Log(LogPrinter printer=nullptr)
void Flush(const intptr_t cursor=0)
void void VPrint(const char *format, va_list args)
static OSThread * Current()
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
OSThread * os_thread() const
static Thread * Current()
IsolateGroup * isolate_group() const
static int static int VSNPrint(char *str, size_t size, const char *format, va_list args)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
static const uint8_t buffer[]
uint32_t uint32_t * format
#define DEFINE_FLAG(type, name, default_value, comment)
void Log(const char *format,...) SK_PRINTF_LIKE(1
void * malloc(size_t size)
static int8_t data[kExtLength]
void(* LogPrinter)(const char *data)