Page 1 of 1

Changing Log Filename

Posted: Tue Jan 13, 2009 02:20
by arn
I'm trying to have my own directory where all the logging of my application is set, the same as CEGUI.log. To achieve this I have the following code:


Code: Select all

_CEGUISystem = new CEGUI::System(_ogreCEGUIRenderer);

CEGUI::Logger * log = &CEGUI::Logger::getSingleton();
log->setLogFilename(addOtherRoute("CEGUI.log"));
log->setLoggingLevel(CEGUI::Informative);


However, a CEGUI.log file is created wherever I execute my program with all the information about the creation of the System, after that, a CEGUI.log is created in the route I wanted. I'd like to avoid the first CEGUI.log. What should I do?

Thanks in advance.

Posted: Tue Jan 13, 2009 08:39
by scriptkid
Hi and welcome :),

you are almost there: you may use a Logger before the System exists, so you should swap the code. This is what we do for the layout editor:

Code: Select all

void CELayoutEditor::InitLogger() const
{
   // Instantiate logger first
   if (!CEGUI::Logger::getSingletonPtr())
      new CEGUI::DefaultLogger();

   // NOTE: The file will be output to the current directory (where the executable is located)
   CEGUI::Logger::getSingleton().setLogFilename("CELayoutEditor.log", false);

   // Set informative logging level
   CEGUI::Logger::getSingleton().setLoggingLevel (CEGUI::Informative);
}


HTH!

Posted: Tue Jan 13, 2009 13:52
by arn
Thanks! It worked.

And I'm glad to be here. I think CEGUI is a very good GUI library :wink:

Posted: Wed Jan 14, 2009 08:12
by scriptkid
Nice that it works now. And thanks :)