Flutter Engine
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 ()
 

Detailed Description

Definition at line 20 of file logging.h.

Constructor & Destructor Documentation

◆ LogMessage()

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

Definition at line 53 of file logging.cc.

References fml::LOG_INFO.

57  : severity_(severity), file_(file), line_(line) {
58 #if !defined(OS_FUCHSIA)
59  stream_ << "[";
60  if (severity >= LOG_INFO) {
61  stream_ << GetNameForLogSeverity(severity);
62  } else {
63  stream_ << "VERBOSE" << -severity;
64  }
65  stream_ << ":" << (severity > LOG_INFO ? StripDots(file_) : StripPath(file_))
66  << "(" << line_ << ")] ";
67 #endif
68 
69  if (condition) {
70  stream_ << "Check failed: " << condition << ". ";
71  }
72 }
constexpr LogSeverity LOG_INFO
Definition: log_level.h:13

◆ ~LogMessage()

fml::LogMessage::~LogMessage ( )

Definition at line 74 of file logging.cc.

References fml::KillProcess(), fml::LOG_ERROR, fml::LOG_FATAL, fml::LOG_INFO, and fml::LOG_WARNING.

74  {
75 #if !defined(OS_FUCHSIA)
76  stream_ << std::endl;
77 #endif
78 
79 #if defined(OS_ANDROID)
80  android_LogPriority priority =
81  (severity_ < 0) ? ANDROID_LOG_VERBOSE : ANDROID_LOG_UNKNOWN;
82  switch (severity_) {
83  case LOG_INFO:
84  priority = ANDROID_LOG_INFO;
85  break;
86  case LOG_WARNING:
87  priority = ANDROID_LOG_WARN;
88  break;
89  case LOG_ERROR:
90  priority = ANDROID_LOG_ERROR;
91  break;
92  case LOG_FATAL:
93  priority = ANDROID_LOG_FATAL;
94  break;
95  }
96  __android_log_write(priority, "flutter", stream_.str().c_str());
97 #elif defined(OS_IOS)
98  syslog(LOG_ALERT, "%s", stream_.str().c_str());
99 #elif defined(OS_FUCHSIA)
100  fx_log_severity_t fx_severity;
101  switch (severity_) {
102  case LOG_INFO:
103  fx_severity = FX_LOG_INFO;
104  break;
105  case LOG_WARNING:
106  fx_severity = FX_LOG_WARNING;
107  break;
108  case LOG_ERROR:
109  fx_severity = FX_LOG_ERROR;
110  break;
111  case LOG_FATAL:
112  fx_severity = FX_LOG_FATAL;
113  break;
114  default:
115  if (severity_ < 0) {
116  fx_severity = fx_log_severity_from_verbosity(-severity_);
117  } else {
118  // Unknown severity. Use INFO.
119  fx_severity = FX_LOG_INFO;
120  }
121  }
122  fx_logger_log_with_source(fx_log_get_logger(), fx_severity, nullptr, file_,
123  line_, stream_.str().c_str());
124 #else
125  std::cerr << stream_.str();
126  std::cerr.flush();
127 #endif
128 
129  if (severity_ >= LOG_FATAL) {
130  KillProcess();
131  }
132 }
constexpr LogSeverity LOG_WARNING
Definition: log_level.h:14
constexpr LogSeverity LOG_ERROR
Definition: log_level.h:15
void KillProcess()
Definition: logging.cc:142
constexpr LogSeverity LOG_INFO
Definition: log_level.h:13
constexpr LogSeverity LOG_FATAL
Definition: log_level.h:16

Member Function Documentation

◆ stream()

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

Definition at line 28 of file logging.h.

References FML_DISALLOW_COPY_AND_ASSIGN, fml::GetVlogVerbosity(), fml::KillProcess(), and fml::ShouldCreateLogMessage().

28 { return stream_; }

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