Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Showcase
  4. Logger: simple, convinient and thread safe logger for Qt applications
QtWS25 Last Chance

Logger: simple, convinient and thread safe logger for Qt applications

Scheduled Pinned Locked Moved Showcase
loggingqdebug
43 Posts 14 Posters 62.8k 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.
  • D Offline
    D Offline
    dvolosnykh
    wrote on last edited by
    #33

    Just wanted to notify the project's maintainers that cutelogger doesn't compile using Qt 5 Beta2 with deprecated API turned off by default: qInstallMsgHandler() has become deprecated.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cyberbobs
      wrote on last edited by
      #34

      Ok, thank you for notification. Currently there is only one project maintainer and I don't have much time for now to implement and support the Qt 5.0.0 compatibility of the project.

      Taking a quick look through the Qt 5 beta2 headers I've noticed there is a lot of work to be done refactoring the Logger to take advantage of the extended Qt 5 logging abilities. If anyone is willing to implement Qt 5 compatibility and post it as a merge request on Gitorious the contribution will be kindly accepted :)

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cyberbobs
        wrote on last edited by
        #35

        Pushed "e3c2745":https://gitorious.org/cutelogger/cutelogger/commit/e3c2745c6c5f38896f87472e01ea2caf2d9e211b. Now Logger successfully builds with Qt 5 and uses some of its advanced logging feature (e.g. file/line/function name gathered in renewed qDebug and the same macros).

        Still some work to be done to support "log categories":https://codereview.qt-project.org/#change,13226 and new Qt log formatting feature in a ConsoleAppender.

        1 Reply Last reply
        0
        • O Offline
          O Offline
          oraclei
          wrote on last edited by
          #36

          How do I enable/disable the CuteLogger?

          1 Reply Last reply
          0
          • C cyberbobs

            Hello in there.

            I want to proudly present the simple logging component for the Qt applications we're internally using for some of our projects. This component is designed concerning the K.I.S.S. principle and proved itself to be very stable and convinient to use. And yes, it's thread safe and ready for using in multi-threaded applications. I really hope it would be useful for you.

            Here's a simple code example using it:

            #include <QCoreApplication>
            
            #include <Logger.h>
            #include <ConsoleAppender.h>
            
            int main(int argc, char* argv[])
            {
              QCoreApplication app(argc, argv);
              ...
              ConsoleAppender* consoleAppender = new ConsoleAppender();
              consoleAppender->setFormat("[%{type}] <%{function}> %{message}\n");
              logger->registerAppender(consoleAppender);
              ...
              LOG_INFO("Starting the application");
              int result = app.exec();
              ...
              if (result)
                LOG_WARNING() << "Something went wrong." << "Result code is" << result;
            
              return result;
            }
            

            Library is Qt 4 and Qt 5 compatible, tested on Windows, Linux and Android (LogCat support included out-of-the-box). Also you may wish to know, that it's not meant to be a separate component, but it's prepared for including to your application sources, for example, using the git submodule approach. Build scripts to use the Logger in qmake-, CMake- or qbs-based projects are included. Logger also supports using many so-called appenders at once (targeting the log stream to different places), logging categories and many other features: just see the docs :)

            It's distributed free of charge according to the terms of LGPL 2.1 license and can be downloaded on the project GitHub page: https://github.com/dept2/CuteLogger

            Rather full documentation on it is embedded into a header files and may be generated using the doxygen (Doxyfile supplied).

            Waiting for your comments and suggestions :)

            AlexorleonA Offline
            AlexorleonA Offline
            Alexorleon
            wrote on last edited by
            #37

            @cyberbobs said:

            Hello

            Hello! How do I connect this component to my program, it is necessary to compile? I can not find a solution.
            I copied files but there were errors.
            android/log.h: No such file or directory
            #include <android/log.h>

            windows.h: No such file or directory
            #include <windows.h>

            My system Ubuntu 14.04

            C 1 Reply Last reply
            0
            • AlexorleonA Alexorleon

              @cyberbobs said:

              Hello

              Hello! How do I connect this component to my program, it is necessary to compile? I can not find a solution.
              I copied files but there were errors.
              android/log.h: No such file or directory
              #include <android/log.h>

              windows.h: No such file or directory
              #include <windows.h>

              My system Ubuntu 14.04

              C Offline
              C Offline
              cyberbobs
              wrote on last edited by
              #38

              @Alexorleon Replied to your question on Github. Basically, you don't need to include windows-specific or console appenders to Android project, it is already handled in pro file included in the library sources. Also, it is suggested that you will include CuteLogger sources to your project (if you store project in git repository, you can add it as submodule) and build it alongside your project instead of building it separately and adding the prebuild libraries.

              1 Reply Last reply
              1
              • Gregoire BorelG Offline
                Gregoire BorelG Offline
                Gregoire Borel
                wrote on last edited by
                #39

                Hey, thanks for this library, it's really cool.

                I'd like to know if it was possible and safe to write in several files? I'd like to create several FileAppender's and decide in which of these files I should write.

                Is there any way to indicate to LOG_INFO() the FileAppender I want to write in?

                C 1 Reply Last reply
                0
                • K Offline
                  K Offline
                  Konstantin Tokarev
                  wrote on last edited by
                  #40

                  Use syslog, it's simple, convenient and thread safe, and has powerful tools to work with (e.g., syslog-ng server). Don't reinvent the wheel!

                  1 Reply Last reply
                  0
                  • Gregoire BorelG Gregoire Borel

                    Hey, thanks for this library, it's really cool.

                    I'd like to know if it was possible and safe to write in several files? I'd like to create several FileAppender's and decide in which of these files I should write.

                    Is there any way to indicate to LOG_INFO() the FileAppender I want to write in?

                    C Offline
                    C Offline
                    cyberbobs
                    wrote on last edited by cyberbobs
                    #41

                    @Gregoire-Borel Actually, the categorized logging feature is made just for that case. Please, take a look at Logger::registerCategoryAppender(). After adding the appender for the category (which is basically just a string identifier) you may use LOG_C* macros to write records to the specific categories or make use of LOG_CATEGORY macro (I'm pretty fond of it myself :), allowing you to automatically redirect every log record made from inside some class to the category you picked.

                    1 Reply Last reply
                    0
                    • _ Offline
                      _ Offline
                      _JR_
                      wrote on last edited by
                      #42

                      Hey, thanks for this library, very usefull and easy to use

                      I'd like to know if someone used it on IOS and if there is any potential known issues on this platform ?

                      C 1 Reply Last reply
                      0
                      • _ _JR_

                        Hey, thanks for this library, very usefull and easy to use

                        I'd like to know if someone used it on IOS and if there is any potential known issues on this platform ?

                        C Offline
                        C Offline
                        cyberbobs
                        wrote on last edited by
                        #43

                        @_JR_ You're welcome :) Personally I neither had any experience in writing iOS apps nor have the necessary hardware/keys/certificates for that. So any input on the subject will be useful (but I doubt that it will be possible to make any enhancements based on that).

                        1 Reply Last reply
                        0

                        • Login

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