Maksasj / bebone

☠️ game development framework/engine aimed for flexible and highly customizable game development
MIT License
7 stars 0 forks source link

Rewrite Logger module #119

Open Soskar1 opened 1 week ago

Soskar1 commented 1 week ago

The Logger class is a static class. Even if you remove the use of Singleton pattern usage, the problem remains the same. It is impossible to create multiple Logger objects. We need to rewrite this module and come up with a better solution

Maksasj commented 1 week ago

I am not sure is it a great idea. 'It is impossible to create multiple Logger objects' actually class is multiton(at least I tried to make it multiton). As for me, best solution would be multiton, since we do not want any additional setup code(we can use just simple macros and everything works out of the box) + these macros are not included in release build.

We could use simple classes for loggers like

auto logger = Logger(...);

logger.log<INFO>("Hey im logged")

but this is not really convenient. If this Logger is needed somewhere else, we need to pass it, or somehow inject it(also logger would be automatically bundled in release builds). Either way, eventually we are gonna have to some sort of static active logger field

Welp, but if you have any good ideas, you are welcome

Soskar1 commented 1 week ago

Ok, I see your idea. I agree with you, that passing the logger to object constructors will lead to a mess. We need to avoid this and come up with a better solution. But it would be nice to be able to create multiple loggers, like in python. I think it would be nice to have an engine logger for engine logs (this could save a lot of time in the future when debugging code) and allow the user to create their own logger objects for logging in-game.

I think we can discuss it later. Logger is not our main priority at the moment 😁