Logger: simple, convinient and thread safe logger for Qt applications
-
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 :)
-
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.
-
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 :)
@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
-
@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
@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.
-
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?
-
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!
-
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?
@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.
-
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 ?
@_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).