Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
logging.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "logging.h"
6
7#include <algorithm>
8#include <iostream>
9
11// #include "log_settings.h"
12
13#if defined(OS_ANDROID)
14#include <android/log.h>
15#elif defined(OS_IOS)
16#include <syslog.h>
17#endif
18
19namespace base {
20
21namespace {
22
23const char* StripPath(const char* path) {
24 auto* p = strrchr(path, '/');
25 if (p) {
26 return p + 1;
27 }
28 return path;
29}
30
31} // namespace
32
33LogMessage::LogMessage(const char* file,
34 int line,
35 const char* condition,
36 bool killProcess)
37 : file_(file), line_(line), killProcess_(killProcess) {
38 stream_ << "[ERROR:" << StripPath(file_) << "(" << line_ << ")] ";
39
40 if (condition) {
41 stream_ << "Check failed: " << condition << ". ";
42 }
43}
44
46 stream_ << std::endl;
47
48#if defined(OS_ANDROID)
49 android_LogPriority priority = ANDROID_LOG_ERROR __android_log_write(
50 priority, "flutter", stream_.str().c_str());
51#elif defined(OS_IOS)
52 syslog(LOG_ALERT, "%s", stream_.str().c_str());
53#else
54 std::cerr << stream_.str();
55 std::cerr.flush();
56#endif
57 if (killProcess_)
59}
60
62 abort();
63}
64
65} // namespace base
LogMessage(const char *file, int line, const char *condition, bool killProcess)
Definition logging.cc:33
void KillProcess()
Definition logging.cc:61
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
Definition switches.h:57