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

Page  
2

March 30, 2012

Bobs Bobs
Lab Rat
34 posts

Please update to the current version of Logger. As of commit c7d9a27 [gitorious.org] QDebug header is included into Logger.h.

 Signature 

Nokia Certified Qt Specialist.

March 30, 2012

nomiz nomiz
Lab Rat
2 posts

Nice, works!

April 16, 2012

01amit 01amit
Lab Rat
5 posts

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.

April 16, 2012

Bobs Bobs
Lab Rat
34 posts

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 [gitorious.org] 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? :)

 Signature 

Nokia Certified Qt Specialist.

April 16, 2012

01amit 01amit
Lab Rat
5 posts

I want to desroy the object when the button is clicked not when the application have been closed.

April 18, 2012

aekam aekam
Lab Rat
87 posts

in which version of Qt i can find these files, <Logger.h> and <ConsoleAppender.h> ??? :-?

 Signature 

If you take care of inches, you won’t have to worry about miles… :)

April 18, 2012

Andre Andre
Robot Herder
6416 posts

aekam wrote:
in which version of Qt i can find these files, <Logger.h> and <ConsoleAppender.h> ??? :-?

You can’t. It’s an external project. See the very first post in this topic.

May 4, 2012

maxvanceffer maxvanceffer
Lab Rat
64 posts

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 !

May 4, 2012

Andre Andre
Robot Herder
6416 posts

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?

May 7, 2012

maxvanceffer maxvanceffer
Lab Rat
64 posts

Yes, for example : maximum log messages ( last 100 messages ) , or maximum log file size.

May 10, 2012

maxvanceffer maxvanceffer
Lab Rat
64 posts

I search frew several projects, and no one provide such functionality. Only log4qt, but it hard to understand, and implement.

May 10, 2012

Andre Andre
Robot Herder
6416 posts

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.

May 10, 2012

maxvanceffer maxvanceffer
Lab Rat
64 posts

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

May 10, 2012

Andre Andre
Robot Herder
6416 posts

I have no idea what you just asked. Sorry.

June 19, 2012

Bobs Bobs
Lab Rat
34 posts

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.

 Signature 

Nokia Certified Qt Specialist.

Page  
2

  ‹‹ Cumulus - Flight computer for glider pilots      VDK 1.1 released ››

You must log in to post a reply. Not a member yet? Register here!