Open define-private-public opened 7 years ago
I'm guessing so - I create one right when the engine starts so that'd be my guess. I can try experimenting by creating another one somewhere else, and seeing if I get similar behavior.
That's what I was thinking as well. When I was working on parsing I had all of the code I needed in sprite.nim
, so I created a logger in that file, but when I had to start working with OpenGL objects I needed to create something that initialized the engine.
How easy would it be to implement a getLogger
function that will ensure that only one logger is instantiated throughout its usage?
We certainly can. I'll try to address this next.
Alright I took a look at logging and I'm not sure what if anything we should do about it.
Right now the way things stand are - a console logger is created when the engine is initialized - so to use logging after initializing the engine, you should simply import the logging module and use the logging functions available to you.
In your case, where you were already working on code that used a logger and then you initialized zengine - I'm not sure what to do in that scenario. We can't check for existing loggers using the logging package so I guess we're boned.
I eventually think if we want to support things like webassembly, we'll have to get more creative with the approach to logging anyway.
Whilst working on the
ZSprite
reader I noticed that some of my logging output to the console is being duplicated. E.g.:Do you know what's causing this? If you take a look at the
sprite.nim
file in my #13 branch you'll see that I constructed anotherconsoleLogger
object. Could that be the culprit?