Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Abseil LOG output printed twice in Qt Creator
QtWS25 Last Chance

Abseil LOG output printed twice in Qt Creator

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
8 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SandSnip3r
    wrote on last edited by
    #1

    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. Using std::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
    )
    
    Christian EhrlicherC 1 Reply Last reply
    0
    • S SandSnip3r

      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. Using std::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
      )
      
      Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @SandSnip3r And it works correct when you run it from the command line? Please test.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      S 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @SandSnip3r And it works correct when you run it from the command line? Please test.

        S Offline
        S Offline
        SandSnip3r
        wrote on last edited by
        #3

        @Christian-Ehrlicher Yes. From the command line, the output is as expected. No duplicates. See screenshots of Qt Creator and command line:

        qtcreator_hhqQ1yVquY.png

        WindowsTerminal_WYVd18qnj5.png

        Christian EhrlicherC 1 Reply Last reply
        0
        • S SandSnip3r

          @Christian-Ehrlicher Yes. From the command line, the output is as expected. No duplicates. See screenshots of Qt Creator and command line:

          qtcreator_hhqQ1yVquY.png

          WindowsTerminal_WYVd18qnj5.png

          Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then try to not run it in the internal terminal - if it works there you should file a bug report.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          S 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            Then try to not run it in the internal terminal - if it works there you should file a bug report.

            S Offline
            S Offline
            SandSnip3r
            wrote on last edited by
            #5

            @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!

            S 1 Reply Last reply
            0
            • S SandSnip3r

              @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!

              S Offline
              S Offline
              SandSnip3r
              wrote on last edited by
              #6

              @SandSnip3r Done. https://bugreports.qt.io/browse/QTCREATORBUG-30163

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SandSnip3r
                wrote on last edited by SandSnip3r
                #7

                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?

                Christian EhrlicherC 1 Reply Last reply
                1
                • S SandSnip3r

                  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?

                  Christian EhrlicherC Online
                  Christian EhrlicherC Online
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @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.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  1
                  • S SandSnip3r has marked this topic as solved on

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved