Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 4b45a53

Browse files
authored
Only make ERROR and FATAL log levels visible by default. (#5022)
Adds the --verbose-logging flag to enable logging at all other severities.
1 parent 98f6c2d commit 4b45a53

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed

assets/asset_manager.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ bool AssetManager::GetAsBuffer(const std::string& asset_name,
4747
return true;
4848
}
4949
}
50-
FXL_DLOG(ERROR) << "Could not find asset: " << asset_name;
50+
FXL_DLOG(WARNING) << "Could not find asset: " << asset_name;
5151
return false;
5252
}
5353

common/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ struct Settings {
7171
bool enable_software_rendering = false;
7272
bool using_blink = false;
7373
bool skia_deterministic_rendering_on_cpu = false;
74+
bool verbose_logging = false;
7475
std::string log_tag = "flutter";
7576
std::string icu_data_path;
7677

shell/common/shell.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "lib/fxl/files/path.h"
2424
#include "lib/fxl/files/unique_fd.h"
2525
#include "lib/fxl/functional/make_copyable.h"
26+
#include "lib/fxl/log_settings.h"
2627
#include "lib/fxl/logging.h"
2728
#include "third_party/dart/runtime/include/dart_tools_api.h"
2829
#include "third_party/skia/include/core/SkGraphics.h"
@@ -149,6 +150,11 @@ std::unique_ptr<Shell> Shell::Create(
149150
blink::Settings settings,
150151
Shell::CreateCallback<PlatformView> on_create_platform_view,
151152
Shell::CreateCallback<Rasterizer> on_create_rasterizer) {
153+
fxl::LogSettings log_settings;
154+
log_settings.min_log_level =
155+
settings.verbose_logging ? fxl::LOG_INFO : fxl::LOG_ERROR;
156+
fxl::SetLogSettings(log_settings);
157+
152158
if (!task_runners.IsValid() || !on_create_platform_view ||
153159
!on_create_rasterizer) {
154160
return nullptr;

shell/common/switches.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ blink::Settings SettingsFromCommandLine(const fxl::CommandLine& command_line) {
155155
settings.skia_deterministic_rendering_on_cpu =
156156
command_line.HasOption(FlagForSwitch(Switch::SkiaDeterministicRendering));
157157

158+
settings.verbose_logging =
159+
command_line.HasOption(FlagForSwitch(Switch::VerboseLogging));
160+
158161
command_line.GetOptionValue(FlagForSwitch(Switch::FLX), &settings.flx_path);
159162

160163
command_line.GetOptionValue(FlagForSwitch(Switch::FlutterAssetsDir),

shell/common/switches.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ DEF_SWITCH(UseTestFonts,
113113
"will make font resolution default to the Ahem test font on all "
114114
"platforms (See https://www.w3.org/Style/CSS/Test/Fonts/Ahem/). "
115115
"This option is only available on the desktop test shells.")
116+
DEF_SWITCH(VerboseLogging,
117+
"verbose-logging",
118+
"By default, only errors are logged. This flag enabled logging at "
119+
"all severity levels. This is NOT a per shell flag and affect log "
120+
"levels for all shells in the process.")
116121
DEF_SWITCH(RunForever,
117122
"run-forever",
118123
"In non-interactive mode, keep the shell running after the Dart "

0 commit comments

Comments
 (0)