samedi 8 juin 2019

C++ - is it bad design to have static and non-static versions of the same method

The problem I am facing is connected with my logger library. I can create my own loggers, but at the same time, I want to be able to operate with a "default" or "global" logger.

So I figured that some of the methods of my logger class should have static versions which will be dealing with this "default" logger. That ultimately felt wrong in terms of design.

Here is an example of what I want to be doing

std::shared_ptr<lwlog::logger> core_logger = std::make_shared<lwlog::logger>("LOGGER");  //creating some custom logger
core_logger->critical("A very critical message!"); //logging from some custom logger

lwlog::logger::critical("A very critical message!"); //logging from default logger

Aucun commentaire:

Enregistrer un commentaire