Flutter Engine
The Flutter Engine
log_interest_listener.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 "flutter/fml/platform/fuchsia/log_interest_listener.h"
6
7#include <fidl/fuchsia.diagnostics/cpp/fidl.h>
8#include <fidl/fuchsia.logger/cpp/fidl.h>
9#include <zircon/assert.h>
10
11#include "flutter/fml/log_level.h"
12#include "flutter/fml/log_settings.h"
13
14namespace fml {
15
17 log_sink_->WaitForInterestChange().Then(
18 [this](fidl::Result<fuchsia_logger::LogSink::WaitForInterestChange>&
19 interest_result) {
20 if (interest_result.is_error()) {
21 // Gracefully terminate on loop shutdown
22 auto error = interest_result.error_value();
23 ZX_ASSERT_MSG(error.is_framework_error() &&
24 error.framework_error().is_dispatcher_shutdown(),
25 "%s", error.FormatDescription().c_str());
26 return;
27 }
28 HandleInterestChange(interest_result->data());
30 });
31}
32
34 const fuchsia_diagnostics::Interest& interest) {
35 auto severity =
36 interest.min_severity().value_or(fuchsia_diagnostics::Severity::kInfo);
37 if (severity <= fuchsia_diagnostics::Severity::kDebug) {
38 fml::SetLogSettings({.min_log_level = -1}); // Verbose
39 } else if (severity <= fuchsia_diagnostics::Severity::kInfo) {
40 fml::SetLogSettings({.min_log_level = kLogInfo});
41 } else if (severity <= fuchsia_diagnostics::Severity::kWarn) {
42 fml::SetLogSettings({.min_log_level = kLogWarning});
43 } else if (severity <= fuchsia_diagnostics::Severity::kError) {
44 fml::SetLogSettings({.min_log_level = kLogError});
45 } else {
46 fml::SetLogSettings({.min_log_level = kLogFatal});
47 }
48}
49
50} // namespace fml
static void HandleInterestChange(const fuchsia_diagnostics::Interest &interest)
Definition: ascii_trie.cc:9
constexpr LogSeverity kLogFatal
Definition: log_level.h:19
void SetLogSettings(const LogSettings &settings)
Definition: log_settings.cc:26
constexpr LogSeverity kLogError
Definition: log_level.h:15
constexpr LogSeverity kLogInfo
Definition: log_level.h:13
constexpr LogSeverity kLogWarning
Definition: log_level.h:14