Logger: simple, convinient and thread safe logger for Qt applications
-
wrote on 29 Feb 2012, 14:19 last edited by
Take a look at the header file of FileAppender, especially the constructor. It takes one additional argument...
-
wrote on 4 Mar 2012, 21:53 last edited by
Thanks. now I understood how to use file appender and log data into txt file. I want use SQL database instead of txt file how can i do that.
-
wrote on 5 Mar 2012, 06:28 last edited by
Write a new appender that does just that. You can start by subclassing AbstractStringAppender. Instead of outputting to file, you can use Qt's SQL classes to output to a database.
-
wrote on 15 Mar 2012, 11:25 last edited by
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.
-
wrote on 30 Mar 2012, 12:02 last edited by
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!
-
wrote on 30 Mar 2012, 12:24 last edited by
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.
-
wrote on 30 Mar 2012, 13:08 last edited by
Nice, works!
-
wrote on 16 Apr 2012, 02:38 last edited by
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. -
wrote on 16 Apr 2012, 10:49 last edited by
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? :)
-
wrote on 16 Apr 2012, 21:27 last edited by
I want to desroy the object when the button is clicked not when the application have been closed.
-
wrote on 18 Apr 2012, 11:45 last edited by
in which version of Qt i can find these files, <Logger.h> and <ConsoleAppender.h> ??? :-?
-
wrote on 18 Apr 2012, 11:58 last edited by
[quote author="aekam" date="1334749555"]in which version of Qt i can find these files, <Logger.h> and <ConsoleAppender.h> ??? :-?[/quote]
You can't. It's an external project. See the very first post in this topic. -
wrote on 4 May 2012, 10:46 last edited by
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 !
-
wrote on 4 May 2012, 11:24 last edited by
I don't understand the question. What do you mean with 'logging size'? Do you want to set some kind of maximum size for the log file output or something like that?
-
wrote on 7 May 2012, 07:58 last edited by
Yes, for example : maximum log messages ( last 100 messages ) , or maximum log file size.
-
wrote on 10 May 2012, 05:52 last edited by
I search frew several projects, and no one provide such functionality. Only log4qt, but it hard to understand, and implement.
-
wrote on 10 May 2012, 08:22 last edited by
Personally, I think log rotation is a separate task. It seems quite expensive to do something like limiting to the last 100 messages. It means re-writing the entire logfile for each message, as you cannot remove from the start of a file. Adding is trivial though.
-
wrote on 10 May 2012, 11:59 last edited by
i already tried my self re-writing file and this real complex task, and heavy in time execution... but log can be very fast happend... but what, if i don't need handle a lot of messages ....
-
wrote on 10 May 2012, 14:09 last edited by
I have no idea what you just asked. Sorry.
-
wrote on 19 Jun 2012, 13:53 last edited by
IMO the most correct way to implement a log rotation is to create separate log files for every week/day/hour (choose yours interval) and to automatically remove older logs becoming obsolete. For example, Apache web server logging is organized in such a way. We've implemented that kind of log rotation for one of our projects using Logger some time ago, but I've never published those classes. The problem is I can't share the source because of some licensing restrictions (it was created by another developer working on a commercial project).
Anyone interested in implementing that kind of functionality (and adding it to logger mainstream code) could easily contact me via email or simply post a merge request on gitorious.