[Solved] Singelton assert failes when calling setLogFilename

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

User avatar
d-Pixie
Just popping in
Just popping in
Posts: 11
Joined: Mon Oct 18, 2010 16:19
Location: Uppsala, Sweden
Contact:

[Solved] Singelton assert failes when calling setLogFilename

Postby d-Pixie » Sun Oct 24, 2010 13:42

Hi all.

I ran in to a irritating problem today. It's a simple matter of wanting to change the CEGUI log file path to my apps directory (I'm on linux and CEGUI defaults to putting it in ~/ while I have a cross platform script to resolve the resource path for my app that yields ~/.app_name on linux). I figured this should be a piece of cake (famous last words tm) and quickly found the CEGUI::Logger::getSingleton().setLogFilename() function for this purpose.

Problem is that it fails with a assert failed when I call it. I have tried to call it high and low in the initialization chain (saw a post or two that pointed out it has to be called before CEGUI::System is created) but to no avail. I noticed, however, that all the forum posts where for older versions of CEGUI (some as old as 0.2.0 ;o) and I know a lot has changed since then (initialization of System for example) and figured it might be something like that.

I have also tried to use the CEGUI::System::create() method passing it the log file as an argument. This seem to work for the log but all of a sudden my resource manager got amnesia and forgot all of my loaded resources (I use Ogres resource loader to load them and CEGUI::DefaultResourceProvider() to get that to CEGUI, worked like a charm before this) despite the fact that I send it a handle to my resource provider.

I don't mind using the System::create() route for this (I'm all for knowing and being able to affect how the system initializes) but the documentation for more advanced initialization is spotty and old for the most part (or hidden? I haven't found it ;/) ...

Any help and/or pointers appreciated on this. I'll post code if you need it but I'm thinking I must have missed something completely so I'm skipping that for now ;o)

Cheers!
Last edited by d-Pixie on Sun Nov 14, 2010 15:37, edited 1 time in total.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: singelton assert failes when calling Logger setLogFilename

Postby Kulik » Sun Oct 24, 2010 13:58

IMO the best way is to instantiate CEGUI::Logger yourself and set it's filename and then bootstrap the system. It will use your created logger. I do this to route all the logged CEGUI messages to my log system.

If you try to call CEGUI::Logger::getSingleton() before it's instantiate you will definitely get the mentioned assert fail.

Code:

Code: Select all

new CEGUI::Logger();

CEGUI::Logger::getSingleton()....

bootstrap

User avatar
d-Pixie
Just popping in
Just popping in
Posts: 11
Joined: Mon Oct 18, 2010 16:19
Location: Uppsala, Sweden
Contact:

Re: singelton assert failes when calling Logger setLogFilename

Postby d-Pixie » Sun Oct 24, 2010 14:17

Oh :oops:

Might have been expected to figure that out on my own I guess ;o) It works nicely (however, to anyone comming along later, the CEGUI::Logger is partially virtual and you want to use the CEGUI::DefaultLogger instead). Thanks for that Kulik ;o)

BTW, is there any way to pass CEGUI the Ogre logger? Just figure that, down the line, you don't want to have three log files lying around (Ogre, CEGUI and your own) and want to roll them in to one. Writing your own log manager is an option but since both CEGUI and Ogre has them I figure I might as well use one of them for now.

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: singelton assert failes when calling Logger setLogFilename

Postby Kulik » Sun Oct 24, 2010 14:22

It should be DefaultLogger, sorry about that.

d-Pixie wrote:BTW, is there any way to pass CEGUI the Ogre logger? Just figure that, down the line, you don't want to have three log files lying around (Ogre, CEGUI and your own) and want to roll them in to one. Writing your own log manager is an option but since both CEGUI and Ogre has them I figure I might as well use one of them for now.


Yeah, by inheriting from CEGUI::Logger and implementing the methods to call Ogre's log system's or your own log system's method.

User avatar
d-Pixie
Just popping in
Just popping in
Posts: 11
Joined: Mon Oct 18, 2010 16:19
Location: Uppsala, Sweden
Contact:

Re: singelton assert failes when calling Logger setLogFilename

Postby d-Pixie » Sun Oct 24, 2010 14:56

Thanks again Kulik.

I have been thinking about the log manager since I last posted and have convinced myself that writing my own might be handy after all. So I'll probable replace both CEGUIs and Ogres defaults with my own (tomorrow I think, or maybe the day after that ;o)


Return to “Help”

Who is online

Users browsing this forum: No registered users and 27 guests