Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
fml::LogMessage Class Reference

#include <logging.h>

Public Member Functions

 LogMessage (LogSeverity severity, const char *file, int line, const char *condition)
 
 ~LogMessage ()
 
std::ostream & stream ()
 

Static Public Member Functions

static void CaptureNextLog (std::ostringstream *stream)
 

Detailed Description

Definition at line 32 of file logging.h.

Constructor & Destructor Documentation

◆ LogMessage()

fml::LogMessage::LogMessage ( LogSeverity  severity,
const char *  file,
int  line,
const char *  condition 
)

Definition at line 69 of file logging.cc.

73 : severity_(severity), file_(StripDots(file)), line_(line) {
74#if !defined(OS_FUCHSIA)
75 stream_ << "[";
76 if (severity >= kLogInfo) {
77 stream_ << GetNameForLogSeverity(severity);
78 } else {
79 stream_ << "VERBOSE" << -severity;
80 }
81 stream_ << ":" << file_ << "(" << line_ << ")] ";
82#endif
83
84 if (condition) {
85 stream_ << "Check failed: " << condition << ". ";
86 }
87}
constexpr LogSeverity kLogInfo
Definition log_level.h:13

References fml::kLogInfo.

◆ ~LogMessage()

fml::LogMessage::~LogMessage ( )

Definition at line 113 of file logging.cc.

113 {
114#if !defined(OS_FUCHSIA)
115 stream_ << std::endl;
116#endif
117 if (capture_next_log_stream_) {
118 *capture_next_log_stream_ << stream_.str();
119 capture_next_log_stream_ = nullptr;
120 } else {
121#if defined(FML_OS_ANDROID)
122 android_LogPriority priority =
123 (severity_ < 0) ? ANDROID_LOG_VERBOSE : ANDROID_LOG_UNKNOWN;
124 switch (severity_) {
125 case kLogImportant:
126 case kLogInfo:
127 priority = ANDROID_LOG_INFO;
128 break;
129 case kLogWarning:
130 priority = ANDROID_LOG_WARN;
131 break;
132 case kLogError:
133 priority = ANDROID_LOG_ERROR;
134 break;
135 case kLogFatal:
136 priority = ANDROID_LOG_FATAL;
137 break;
138 }
139 __android_log_write(priority, "flutter", stream_.str().c_str());
140#elif defined(FML_OS_IOS)
141 syslog(LOG_ALERT, "%s", stream_.str().c_str());
142#elif defined(OS_FUCHSIA)
143 FuchsiaLogSeverity severity;
144 switch (severity_) {
145 case kLogImportant:
146 case kLogInfo:
147 severity = FUCHSIA_LOG_INFO;
148 break;
149 case kLogWarning:
150 severity = FUCHSIA_LOG_WARNING;
151 break;
152 case kLogError:
153 severity = FUCHSIA_LOG_ERROR;
154 break;
155 case kLogFatal:
156 severity = FUCHSIA_LOG_FATAL;
157 break;
158 default:
159 if (severity_ < 0) {
160 severity = FUCHSIA_LOG_DEBUG;
161 } else {
162 // Unknown severity. Use INFO.
163 severity = FUCHSIA_LOG_INFO;
164 }
165 break;
166 }
167 fuchsia_logging::LogBuffer buffer =
168 fuchsia_logging::LogBufferBuilder(severity)
169 .WithFile(file_, line_)
170 .WithMsg(stream_.str())
171 .Build();
172 const std::string* process_name = GetProcessName();
173 if (process_name) {
174 buffer.WriteKeyValue("tag", *process_name);
175 }
176 [[maybe_unused]] zx::result result =
177 fuchsia_logging::FlushToGlobalLogger(buffer);
178#else
179 // Don't use std::cerr here, because it may not be initialized properly yet.
180 fprintf(stderr, "%s", stream_.str().c_str());
181 fflush(stderr);
182#endif
183 }
184
185 if (severity_ >= kLogFatal) {
186 KillProcess();
187 }
188}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set profile Make the profiler discard new samples once the profiler sample buffer is full When this flag is not the profiler sample buffer is used as a ring buffer
Definition switch_defs.h:98
void KillProcess()
Definition logging.cc:198
constexpr LogSeverity kLogFatal
Definition log_level.h:19
constexpr LogSeverity kLogImportant
Definition log_level.h:18
constexpr LogSeverity kLogError
Definition log_level.h:15
constexpr LogSeverity kLogWarning
Definition log_level.h:14

References fml::KillProcess(), fml::kLogError, fml::kLogFatal, fml::kLogImportant, fml::kLogInfo, and fml::kLogWarning.

Member Function Documentation

◆ CaptureNextLog()

void fml::LogMessage::CaptureNextLog ( std::ostringstream *  stream)
static

Definition at line 109 of file logging.cc.

109 {
110 LogMessage::capture_next_log_stream_ = stream;
111}
std::ostream & stream()
Definition logging.h:40

References stream().

Referenced by fml::testing::LogCapture::LogCapture(), flutter::testing::TEST_F(), and fml::testing::LogCapture::~LogCapture().

◆ stream()

std::ostream & fml::LogMessage::stream ( )
inline

Definition at line 40 of file logging.h.

40{ return stream_; }

Referenced by CaptureNextLog(), impeller::ImpellerValidationBreak(), and fml::testing::TEST().


The documentation for this class was generated from the following files: