You can simplify the process by mkaing a few changes to the Log
class to have it call the global log functions instead. This reduce or eliminate extensive changes to how the logging is currently being used.
class Log {
public:
explicit Log(const std::string& name) : name(name) {}
void Print(const std::string& message) const {
GlobalLogPrint(name, message);
}
private:
const std::string name;
};
You can continue to dynamically allocate instances of the Log
object or you can use composition.
class Module {
public:
explicit Module(const std::string& name) : log(name) {}
virtual void Update() = 0;
protected:
Log log;
};
class Renderer : public Module {
public:
void Update() {
log.Print("Hello World!");
}
};