Flutter Engine
The Flutter Engine
third_party
dart-lang
sdk
runtime
vm
log.h
Go to the documentation of this 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
3
// BSD-style license that can be found in the LICENSE file.
4
5
#ifndef RUNTIME_VM_LOG_H_
6
#define RUNTIME_VM_LOG_H_
7
8
#include "
vm/allocation.h
"
9
#include "
vm/growable_array.h
"
10
#include "
vm/os.h
"
11
12
namespace
dart
{
13
14
class
IsolateGroup;
15
class
LogBlock;
16
17
#if defined(_MSC_VER)
18
#define THR_Print(format, ...) Log::Current()->Print(format, __VA_ARGS__)
19
#else
20
#define THR_Print(format, ...) Log::Current()->Print(format, ##__VA_ARGS__)
21
#endif
22
23
#define THR_VPrint(format, args) Log::Current()->VPrint(format, args)
24
25
typedef
void (*
LogPrinter
)(
const
char
*
data
);
26
27
class
Log
{
28
public
:
29
explicit
Log
(
LogPrinter
printer =
nullptr
);
30
~Log
();
31
32
static
Log
*
Current
();
33
34
// Append a formatted string to the log.
35
void
Print
(
const
char
*
format
, ...)
PRINTF_ATTRIBUTE
(2, 3);
36
37
void
VPrint
(
const
char
*
format
, va_list
args
);
38
39
// Flush and truncate the log. The log is flushed starting at cursor
40
// and truncated to cursor afterwards.
41
void
Flush
(
const
intptr_t
cursor
= 0);
42
43
// Clears the log.
44
void
Clear
();
45
46
// Current cursor.
47
intptr_t
cursor
()
const
;
48
49
// A logger that does nothing.
50
static
Log
*
NoOpLog
();
51
52
private
:
53
void
TerminateString();
54
void
EnableManualFlush();
55
void
DisableManualFlush(
const
intptr_t
cursor
);
56
57
// Returns true when flush is required.
58
bool
ShouldFlush()
const
;
59
60
// Returns false if we should drop log messages related to 'isolate'.
61
static
bool
ShouldLogForIsolateGroup(
const
IsolateGroup
* isolate);
62
63
static
Log
noop_log_;
64
LogPrinter
printer_;
65
intptr_t manual_flush_;
66
MallocGrowableArray<char>
buffer_;
67
68
friend
class
LogBlock
;
69
friend
class
LogTestHelper
;
70
DISALLOW_COPY_AND_ASSIGN
(
Log
);
71
};
72
73
// Causes all log messages to be buffered until destructor is called.
74
// Can be nested.
75
class
LogBlock
:
public
StackResource
{
76
public
:
77
LogBlock
(
ThreadState
*
thread
,
Log
*
log
)
78
:
StackResource
(
thread
), log_(
log
), cursor_(
log
->cursor()) {
79
Initialize();
80
}
81
82
LogBlock
()
83
:
StackResource
(
ThreadState
::Current()),
84
log_(
Log
::Current()),
85
cursor_(
Log
::Current()->cursor()) {
86
Initialize();
87
}
88
89
~LogBlock
();
90
91
private
:
92
void
Initialize();
93
94
Log
*
const
log_;
95
const
intptr_t cursor_;
96
};
97
98
}
// namespace dart
99
100
#endif
// RUNTIME_VM_LOG_H_
dart::IsolateGroup
Definition:
isolate.h:268
dart::LogBlock
Definition:
log.h:75
dart::LogBlock::~LogBlock
~LogBlock()
Definition:
log.cc:230
dart::LogBlock::LogBlock
LogBlock(ThreadState *thread, Log *log)
Definition:
log.h:77
dart::LogBlock::LogBlock
LogBlock()
Definition:
log.h:82
dart::LogTestHelper
Definition:
log_test.cc:33
dart::Log
Definition:
log.h:27
dart::Log::Clear
void Clear()
Definition:
log.cc:151
dart::Log::Print
void Print(const char *format,...) PRINTF_ATTRIBUTE(2
Definition:
log.cc:93
dart::Log::NoOpLog
static Log * NoOpLog()
Definition:
log.cc:183
dart::Log::cursor
intptr_t cursor() const
Definition:
log.cc:158
dart::Log::~Log
~Log()
Definition:
log.cc:70
dart::Log::Current
static Log * Current()
Definition:
log.cc:75
dart::Log::Log
Log(LogPrinter printer=nullptr)
Definition:
log.cc:60
dart::Log::Flush
void Flush(const intptr_t cursor=0)
Definition:
log.cc:134
dart::Log::VPrint
void void VPrint(const char *format, va_list args)
Definition:
log.cc:104
dart::MallocGrowableArray< char >
dart::StackResource
Definition:
allocation.h:23
dart::StackResource::thread
ThreadState * thread() const
Definition:
allocation.h:33
dart::ThreadState
Definition:
thread_state.h:24
args
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition:
fl_event_channel.h:89
format
uint32_t uint32_t * format
Definition:
fl_texture_registrar_test.cc:41
dart
Definition:
dart_vm.cc:33
dart::data
static int8_t data[kExtLength]
Definition:
dart_api_impl_test.cc:2256
dart::LogPrinter
void(* LogPrinter)(const char *data)
Definition:
log.h:25
dump_adb_log.log
log
Definition:
dump_adb_log.py:12
os.h
PRINTF_ATTRIBUTE
#define PRINTF_ATTRIBUTE(string_index, first_to_check)
Definition:
globals.h:697
DISALLOW_COPY_AND_ASSIGN
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Definition:
globals.h:581
allocation.h
growable_array.h
Generated on Sun Jun 23 2024 21:56:53 for Flutter Engine by
1.9.4