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 48 of file logging.cc.

References fml::LOG_INFO.

52  : severity_(severity), file_(file), line_(line) {
53  stream_ << "[";
54  if (severity >= LOG_INFO) {
55  stream_ << GetNameForLogSeverity(severity);
56  } else {
57  stream_ << "VERBOSE" << -severity;
58  }
59  stream_ << ":" << (severity > LOG_INFO ? StripDots(file_) : StripPath(file_))
60  << "(" << line_ << ")] ";
61 
62  if (condition) {
63  stream_ << "Check failed: " << condition << ". ";
64  }
65 }
constexpr LogSeverity LOG_INFO
Definition: log_level.h:13

◆ ~LogMessage()

fml::LogMessage::~LogMessage ( )

Definition at line 67 of file logging.cc.

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

67  {
68  stream_ << std::endl;
69 
70 #if defined(OS_ANDROID)
71  android_LogPriority priority =
72  (severity_ < 0) ? ANDROID_LOG_VERBOSE : ANDROID_LOG_UNKNOWN;
73  switch (severity_) {
74  case LOG_INFO:
75  priority = ANDROID_LOG_INFO;
76  break;
77  case LOG_WARNING:
78  priority = ANDROID_LOG_WARN;
79  break;
80  case LOG_ERROR:
81  priority = ANDROID_LOG_ERROR;
82  break;
83  case LOG_FATAL:
84  priority = ANDROID_LOG_FATAL;
85  break;
86  }
87  __android_log_write(priority, "flutter", stream_.str().c_str());
88 #elif defined(OS_IOS)
89  syslog(LOG_ALERT, "%s", stream_.str().c_str());
90 #else
91  std::cerr << stream_.str();
92  std::cerr.flush();
93 #endif
94 
95  if (severity_ >= LOG_FATAL) {
96  KillProcess();
97  }
98 }
constexpr LogSeverity LOG_WARNING
Definition: log_level.h:14
constexpr LogSeverity LOG_ERROR
Definition: log_level.h:15
void KillProcess()
Definition: logging.cc:108
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: