Page 1 of 1

Log enhancement

Posted: Thu Jan 22, 2009 8:07 am
by syedhs
A few probably log features which I think is useful (useful to me):-
1) The ability to add 'hundreth of second' to time eg:-
Currently

Code: Select all

01:27:47: Creating resource group General
01:27:47: Creating resource group Internal
01:27:47: Creating resource group Autodetect
and the proposed change will result into something like this:-

Code: Select all

01:27:47.012: Creating resource group General
01:27:47.013: Creating resource group Internal
01:27:47.014: Creating resource group Autodetect
By default, Ogre log behavior should be the same as it is now, but you now have this additional function: LogManager::enableHundrethSecond();

2) The ability to add tab to the log messages:-
Currently

Code: Select all

01:27:47: Installing plugin: ParticleFX
01:27:47: Particle Emitter Type 'Point' registered
01:27:47: Particle Emitter Type 'Box' registered
01:27:47: Particle Emitter Type 'Ellipsoid' registered
01:27:47: Particle Emitter Type 'Cylinder' registered
01:27:47: Particle Emitter Type 'Ring' registered
and the proposed changes will result into something like this:-

Code: Select all

01:27:47: Installing plugin: ParticleFX
01:27:47:       Particle Emitter Type 'Point' registered
01:27:47:       Particle Emitter Type 'Box' registered
01:27:47:       Particle Emitter Type 'Ellipsoid' registered
01:27:47:       Particle Emitter Type 'Cylinder' registered
01:27:47:       Particle Emitter Type 'Ring' registered
The additional functions may be like this:-
LogManager::increaseIndent
LogManager::decreaseIndent
LogManager::clearIndent

Obviously, these are not that hard to implement, so I am offering to do the patches. :D
I created this thread to discuss the better function name or any other useful functions that I am missing.

Re: Log enhancement

Posted: Thu Jan 22, 2009 10:12 am
by spookyboo
How about an additional column with the severity (so not included as part of the message).

Code: Select all

01:27:47: INFO       Installing plugin: ParticleFX
01:27:47: INFO       Particle Emitter Type 'Point' registered
01:27:47: WARNING    bla, bla
01:27:47: EXCEPTION  bla, bla, ...

Re: Log enhancement

Posted: Thu Jan 22, 2009 11:09 am
by steven
syedhs wrote: and the proposed changes will result into something like this:-

Code: Select all

01:27:47: Installing plugin: ParticleFX
01:27:47:       Particle Emitter Type 'Point' registered
01:27:47:       Particle Emitter Type 'Box' registered
01:27:47:       Particle Emitter Type 'Ellipsoid' registered
01:27:47:       Particle Emitter Type 'Cylinder' registered
01:27:47:       Particle Emitter Type 'Ring' registered
The additional functions may be like this:-
LogManager::increaseIndent
LogManager::decreaseIndent
LogManager::clearIndent
Mh... I did this in our engine.
Be warned that it is not so easy if the log manager is accessed from multiple threads.
You can do it correctly with lots of housekeeping... or use a simple & fast solution that sometimes will cause havoc to the indent. Check the LogManager in OGE CVS code (not the SVN because I removed the indent) if you want to see how to do a simple indent.
spookyboo wrote:How about an additional column with the severity (so not included as part of the message).

Code: Select all

01:27:47: INFO       Installing plugin: ParticleFX
01:27:47: INFO       Particle Emitter Type 'Point' registered
01:27:47: WARNING    bla, bla
01:27:47: EXCEPTION  bla, bla, ...
Our logmgr has also a similar methods but has we can choose either to log in an .html, .cvs or .txt we can have different way to represent the log level.
In html the font color is changed :)

Re: Log enhancement

Posted: Thu Jan 22, 2009 11:24 am
by CABAListic
Heh, as far as HTML logs go, I recently worked on a kind of prototype which can blend out certain types of messages so that you can focus on the interesting ones. I figure it might be useful in a more complex environment with several different parts. This is what I've come up with so far:
http://devel.oddbeat.de/logfile.html

I haven't actually written a corresponding log system yet, though.

Re: Log enhancement

Posted: Thu Jan 22, 2009 1:04 pm
by jacmoe
The cool thing about the Ogre logmanager is that you can easily intercept it, and submit it to your own log-handler. :wink:

Re: Log enhancement

Posted: Thu Jan 22, 2009 1:22 pm
by syedhs
steven wrote: Be warned that it is not so easy if the log manager is accessed from multiple threads.
I think the log manager class is not thread-safe. In the past, I inadvertently a few times invoking logMessage from different thread, and saw all those garbage characters in the log.

Spookyboo's additional column is nice, but may need further discussion so that it can be generalized - I dont know, that is just my thought. :)

Re: Log enhancement

Posted: Thu Jan 22, 2009 4:51 pm
by steven
Adding log in a thread-safe fation is the easy part.

What I spoke of was the fact that when you have multiple threads using the log manager
they will call addIndent and decIndent at any moment.

Re: Log enhancement

Posted: Thu Jan 22, 2009 6:35 pm
by reptor
jacmoe wrote:The cool thing about the Ogre logmanager is that you can easily intercept it, and submit it to your own log-handler. :wink:
That's exactly what I am doing.

The formatting of the log file needs to be application-specific, as I see it.

I direct all log messages into the same file. Also do a little bit of my own formatting, to add a "severity" column like someone suggested here, and I also added the name of the subsystem which created the log message to the first columns. Because some subsystems (libraries not made by me) have it in the log message itself but others don't.

Re: Log enhancement

Posted: Sat Jan 24, 2009 2:55 pm
by syedhs
I agree that for some more serious log customization, it is better handled with interception like Jacmoe described.

However, for smaller changes it is just easier to have them built-in the LogManager.