[SOLVED] Disabling log file

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

pianoman
Just popping in
Just popping in
Posts: 12
Joined: Fri Mar 20, 2009 23:22
Location: Nebraska, USA

[SOLVED] Disabling log file

Postby pianoman » Mon Jan 18, 2010 19:02

Hi, I want to prevent the creation of the CEGUI log file, and I saw a post on disabling CEGUI log file creation ( viewtopic.php?f=10&t=3435&p=15557&hilit=disable+logging#p15557 ), so I followed the example code posted there and put the following in my main.cpp:

Code: Select all

//// Disable logging in CEGUI for Release build
#ifndef _DEBUG
class CeguiNonLogger : public CEGUI::Logger{
   void logEvent (const CEGUI::String&, CEGUI::LoggingLevel){}
   void setLogFilename(const CEGUI::String&, bool){}
};
CeguiNonLogger g_ceguiNonLogger;
#endif


But when I do that, when exiting my app I get a failed assertion at CEGUISingleton.h, line 77:

Code: Select all

   ~Singleton( void )
        {  assert( ms_Singleton );  ms_Singleton = 0;  }


Do I need to postpone the instantiation of my logger until a certain point or something?

Edit: I tried making my logger a member variable of my app's main class, and I still had the same problem; then I made it a pointer and instantiated it the line before creating the CEGUI renderer and system objects, and there was no assertion failure :) . But this is also a memory leak, right? :? And I'm just avoiding the assertion by avoiding the CEGUISingleton destructor since I never delete the logger? Or does the logger automatically get deleted, which is why it is 0 in the destructor when I don't heap-allocate it or delete it myself? :?:
Last edited by pianoman on Wed Jan 20, 2010 01:25, edited 1 time in total.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Disabling log file

Postby CrazyEddie » Tue Jan 19, 2010 09:49

Hi,

This is a bug in 0.6.x (should be fixed in 0.7.x).

Basically in 0.6.x, within the CEGUI::System destructor, the logger is always deleted by:

Code: Select all

delete CEGUI::Logger::getSingletonPtr();

regardless of who created it and how (which makes this a particularly nasty bug).

As such, to do this in 0.6.x you must ensure that the logger is created via new, and is not deleted (since the system will do it). However, if you intend upgrading to 0.7.x at any time, that code then becomes a leak, since in 0.7.x we have the correct behaviour (i.e you create it, you delete it).

HTH

CE.

pianoman
Just popping in
Just popping in
Posts: 12
Joined: Fri Mar 20, 2009 23:22
Location: Nebraska, USA

Re: Disabling log file

Postby pianoman » Wed Jan 20, 2010 00:50

Perfect. Thanks! :D


Return to “Help”

Who is online

Users browsing this forum: No registered users and 7 guests