2Q: Ogre::LogManager and Ogre::Exception -- should I use?

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
Feral
Halfling
Posts: 80
Joined: Thu May 26, 2005 9:12 pm
Location: NORTHERN California, USA

2Q: Ogre::LogManager and Ogre::Exception -- should I use?

Post by Feral »

This is in regards to raw 1.0.2 Azathoth Ogre.

I have two questions regarding Ogre::LogManager and Ogre::Exception, in essence I’m wondering if I should use them. Sounds silly doesn’t it ?


What is the preferred method:

Use Ogre’s Logging abilities (and sift through the log file for my information), or use a different logging method (a preexisting log class from another project for instance).

I think I would prefer to use Ogre::LogManager given that if I understand this listener business right I can eves drop and output log messages to say an in game console or the like, which is desirable, but I’d really like to log things before Ogre::Root() is created as such I’d need to manage the LogManager’s lifetime myself, i.e.:

Code: Select all

// in main() {
Ogre::LogManager	* log_manager = NULL;


// Create log manager and default log file if there is no log manager yet
if	(	Ogre::LogManager::getSingletonPtr() == NULL)
{
	log_manager = new LogManager();
	log_manager->createLog("Ogre.log", true, true);
}

// ... try{}catch{}, etc.

if	(	log_manager)
{
	delete log_manager;
	log_manager = NULL;
}

return EXIT_SUCCESS;}
Which if I understand corectly will allow me to “Ogre::LogManager::getSingleton().logMessage("message");” up untill the log_manager above is deleted. In essence exactly what I am used to.

Or is there something about this that I am completely missing the point of ?


I have a similar question regarding Ogre::Exception() … Do I dare use it knowing that the help for “enum Ogre::Exception::ExceptionCodes” explicitly states: “Todo: Add many more exception codes, since we want the user to be able to catch most of them.” I.e. at what point can I add my own error values without stepping on the *possible future* additional Ogre::Exception::ExceptionCodes ? A quick bounds (i.e. “ERR_USER = 1000” in the Ogre::Exception::ExceptionCodes enum would answer this.)

Or should I be throwing my own exception class and let Ogre::Exception remain solely in the domain of Ogre?


Commentary welcome, Thank you (=
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8
Contact:

Post by haffax »

Your LogManager use looks sound. Just use it this way if it suits your needs.
For exceptions, I'd recommend to not use Ogre::Exception for your own exceptions. This way you won't ever have the problem, that you use future ogre error codes and personally I prefer to have different classes for different exceptions instead of just one class. So you don't have to test exceptions for its error code before you decide if you want to handle it, or throw it further.
team-pantheon programmer
creators of Rastullahs Lockenpracht
User avatar
Feral
Halfling
Posts: 80
Joined: Thu May 26, 2005 9:12 pm
Location: NORTHERN California, USA

Post by Feral »

Thank you Haffax (=

I’d not thought of different classes for different classes of exceptions, that is rather clever!

Thank you again.
Post Reply