Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Log does not seem to write to stdout #1537

Closed
eugeneo opened this issue Sep 23, 2023 · 1 comment
Closed

[Bug]: Log does not seem to write to stdout #1537

eugeneo opened this issue Sep 23, 2023 · 1 comment

Comments

@eugeneo
Copy link

eugeneo commented Sep 23, 2023

Describe the issue

I can not see infos/warnings, no matter what I set --minloglevel to. Setting --stderrthreshold=0 works as expected.

Steps to reproduce the problem

Code:

int main(int argc, char** argv) {
  absl::SetProgramUsageMessage("Echo server");
  absl::ParseCommandLine(argc, argv);
  absl::InitializeLog();
  std::cout << "Hello, world!" << std::endl;
  LOG(INFO) << "Info";
  LOG(WARNING) << "Warning";
  LOG(ERROR) << "Error";
  return 0;
}

Bazel build:

cc_binary(
  name = "echo_server",
  srcs = [
    "echo_server.cc",
  ],
  deps = [
    "@com_google_absl//absl/flags:parse",
    "@com_google_absl//absl/log",
    "@com_google_absl//absl/log:flags",
    "@com_google_absl//absl/log:initialize",
  ],
)

Command line:
bazel run //src/tools:echo_server -- --minloglevel=0

What version of Abseil are you using?

abseil-cpp-20230802.0

What operating system and version are you using?

Ubuntu 22.04.3 LTS x86/64

What compiler and version are you using?

gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)

What build system are you using?

Bazel 6.3.2

Additional context

No response

@derekmauro
Copy link
Member

I'm not sure what you think the expected behavior is here. Logging writes to stderr (not stdout) when --stderrthreshold is set to the appropriate level, and you say that is working.

--minloglevel controls whether the logging infrastructure runs at all for a particular logging level.

If you want logs to go somewhere besides stderr, you need to use absl::AddLogSink().

@derekmauro derekmauro closed this as not planned Won't fix, can't repro, duplicate, stale Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants