Abseil LOG output printed twice in Qt Creator
-
I have created a simple project which uses Abseil and is built and run inside of Qt Creator.
When I use any abseil logging, I see the output twice in the Qt Creator "Application Output" pane. Once in red and once again in white (I'm using dark theme). Using
std::cout
, I see the output once as white, as expected. Usingstd::cerr
, I see the output once as red, as expected. I cannot figure out how to stop Abseil logging from printing twice. If I run the same process from the command line, the Abseil logs are only printed to stderr, as expected.- OS: Windows 10
- Qt Creator versions tested: 11 & 12
- Qt version: 6.2.4 MSVC2019 64bit
Abseil is recently cloned locally as a subdirectory. The commit is
2a636651729cec997a433ce8e363c6344130944e
, though it happens with older versions too.Here is the directory structure:
. |-- CMakeLists.txt |-- CMakeLists.txt.user |-- abseil-cpp `-- main.cpp
Here is my main:
#include <absl/log/globals.h> #include <absl/log/initialize.h> #include <absl/log/log.h> #include <iostream> int main() { absl::InitializeLog(); absl::SetStderrThreshold(absl::LogSeverityAtLeast::kInfo); std::cout << "Cout test" << std::endl; std::cerr << "Cerr test" << std::endl; LOG(INFO) << "test"; return 0; }
This program will print something like:
Cout test Cerr test I0104 17:58:48.312991 20796 main.cpp:12] test I0104 17:58:48.312991 20796 main.cpp:12] test
("Cerr test" and one of the "main.cpp:12] test" lines are red)
Here is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.26.4) project(main LANGUAGES CXX) add_executable(${PROJECT_NAME} main.cpp ) set(ABSL_PROPAGATE_CXX_STD ON) add_subdirectory(abseil-cpp) target_link_libraries(${PROJECT_NAME} PUBLIC absl::log absl::log_initialize )
-
@SandSnip3r And it works correct when you run it from the command line? Please test.
-
@Christian-Ehrlicher Yes. From the command line, the output is as expected. No duplicates. See screenshots of Qt Creator and command line:
-
Then try to not run it in the internal terminal - if it works there you should file a bug report.
-
@Christian-Ehrlicher I also tried it in the internal Qt Creator terminal. The output is as expected there.
Ok, I will file a bug. Thanks!
-
-
It sounds like this is expected behavior. Abseil registers an additional "LogSink" for Windows' OutputDebugString, which is a different output stream than stdout or stderr.
Qt Creator displays this output type in the same place and style as stdout.
I think Qt Creator should not do this; or at least not do it so deceptively. I think one or both of these changes should be made:
- Qt Creator should show this OutputDebugString in the Application Output window in a different color or in a separate pane
- Qt Creator should allow you to disable this OutputDebugString
Thoughts?
-
@SandSnip3r said in Abseil LOG output printed twice in Qt Creator:
Thoughts?
Feel free to add a patch for it - I doubt anyone else will do it for you since it's a rare usecase. Logging has to go to a log file, not stdout.
-