From 35c2f4642830e1446701abe17ae6d3b96d6043ae Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Fri, 23 Feb 2024 16:16:29 -0800 Subject: [PATCH] fix: Always log to stderr by default (#1350) This tweaks the default config for stderrthreshold from absl/log so that we always get logs to stderr by default, as we did in v2. The --quiet and --v flags that existed in v2 can still be used to modify the log level, as well as the new --minloglevel from absl/log. Issue #1325 --- packager/app/mpd_generator.cc | 10 ++++++++++ packager/app/packager_main.cc | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/packager/app/mpd_generator.cc b/packager/app/mpd_generator.cc index ee9de0f810..e4cec7ed48 100644 --- a/packager/app/mpd_generator.cc +++ b/packager/app/mpd_generator.cc @@ -31,6 +31,9 @@ ABSL_FLAG(std::string, "", "Packager version for testing. Should be used for testing only."); +// From absl/log: +ABSL_DECLARE_FLAG(int, stderrthreshold); + namespace shaka { namespace { const char kUsage[] = @@ -109,6 +112,13 @@ int MpdMain(int argc, char** argv) { auto usage = absl::StrFormat(kUsage, argv[0]); absl::SetProgramUsageMessage(usage); + + // Before parsing the command line, change the default value of some flags + // provided by libraries. + + // Always log to stderr. Log levels are still controlled by --minloglevel. + absl::SetFlag(&FLAGS_stderrthreshold, 0); + absl::ParseCommandLine(argc, argv); if (absl::GetFlag(FLAGS_licenses)) { diff --git a/packager/app/packager_main.cc b/packager/app/packager_main.cc index 426a2352df..97a4fccd71 100644 --- a/packager/app/packager_main.cc +++ b/packager/app/packager_main.cc @@ -58,6 +58,9 @@ ABSL_FLAG(bool, false, "If enabled, only use one thread when generating content."); +// From absl/log: +ABSL_DECLARE_FLAG(int, stderrthreshold); + namespace shaka { namespace { @@ -560,6 +563,12 @@ int PackagerMain(int argc, char** argv) { auto usage = absl::StrFormat(kUsage, argv[0]); absl::SetProgramUsageMessage(usage); + // Before parsing the command line, change the default value of some flags + // provided by libraries. + + // Always log to stderr. Log levels are still controlled by --minloglevel. + absl::SetFlag(&FLAGS_stderrthreshold, 0); + auto remaining_args = absl::ParseCommandLine(argc, argv); if (absl::GetFlag(FLAGS_licenses)) { for (const char* line : kLicenseNotice)