Logger: simple, convinient and thread safe logger for Qt applications
-
-
Why do you think there is a difference, other than switching out FileAppender for ConsoleAppender and making sure it has a file name?
And what do you mean by
[quote author="01amit" date="1330493543"]If I want use the FileAppender in QPushButton what I need to do.[/quote]
Using FileAppender in QPushButton? Do you mean you want to trigger logging something if you click on some push button? -
Yes, whenever i click on push button it should write something to text file. How do I change the following code if I want to use FileAppender. I am very new to this. Where do I specify file name.
@
int main(int argc, char* argv[])
{
QCoreApplication app(argc, argv);ConsoleAppender* consoleAppender = new ConsoleAppender();
consoleAppender->setFormat("[%-7l] <%C> %m\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;
}
@Edit: please use @ tags around your code sections; Andre
-
Andre, thanks for your answers in this topic :)
CuteLogger have been updated about a day ago (thanks goes to Karl-Heinz Reichel). We finally got rid of symlinks in repository, added the Win32 builds support and a qmake file, so currently most of the Qt developers can build it without installing cmake.
-
Hi there,
I'm starting the logger in main(). When I'm including <Logger.h> in some class of my application the compiler states:
error: invalid use of incomplete type ‘struct QDebug’
error: forward declaration of ‘struct QDebug’and I still need to incude <QDebug> as well. Is that normal behaviour?
Thanks!
-
Please update to the current version of Logger. As of commit "c7d9a27":https://gitorious.org/cutelogger/cutelogger/commit/c7d9a27110b110298fdf42b417b6e0e246fa96af QDebug header is included into Logger.h.
-
How to I destroy this logger object and reinstantiate it without existing the application. Say I have three push buttons (1, 2, 3). I want to instantiate when button 1 is pressed. and use LOG_INFO macro when button 2 is pressed. Flush the data to the file when button 3 is pressed and destroy the object. Re-instantiate the class when button 1 is pressed again without closing the application.
In my application we never exit the application it contoneously runs. I am looking for a way to instantiate the class, use log_info, detroy the object and then reinstantiate. -
Well, I definitely need to ask a question here: why do you need to manually instantiate and destroy Logger?
This library is created as singleton without any visible initialization by design. Its main object is automatically created on the first Logger::* static function or macro call. As you can see in "Logger.cpp":https://gitorious.org/cutelogger/cutelogger/blobs/master/src/Logger.cpp the object is automatically destroyed after the application have been closed (using the qAddPostRoutine function).
So, once again: why do you want to do manually the thing that is done automatically? :)
-
How about logging size ? I searched in several Qt based logging libs ( QxtLogger, log4qt ..... ) didn't find any functions in it, related to the size of log functionality. So it will be very usefull to see this functionality !
-
Yes, for example : maximum log messages ( last 100 messages ) , or maximum log file size.