Skip to content

Commit

Permalink
fix: Always log to stderr by default (shaka-project#1350)
Browse files Browse the repository at this point in the history
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 shaka-project#1325
  • Loading branch information
joeyparrish authored Feb 24, 2024
1 parent 89376d3 commit 35c2f46
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packager/app/mpd_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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[] =
Expand Down Expand Up @@ -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)) {
Expand Down
9 changes: 9 additions & 0 deletions packager/app/packager_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 35c2f46

Please sign in to comment.