Currently there's an API kinda methods exposed to trace the logs for another dependent applications
public class Logger {
public static void Init() {}
public static void Verbose(string msg) {}
public static void Warn(string msg) {}
public static void Error(string msg) {}
}
With some design changes, I want to introduce another type of Logger, will be activated based on certain conditions
protected class FileLogger {
public static void Verbose(string msg) {}
public static void Warn(string msg) {}
public static void Error(string msg) {}
}
protected class ConsoleLogger {
public static void Verbose(string msg) { //do diff}
public static void Warn(string msg) { // do different}
public static void Error(string msg) {}
}
The Logger
is already exposed and which can be called in static way Logger.Warn("test")
. What would be the ideal design pattern/implementation to hide the implementation without breaking the contract.
One simple way is to use if and else
in the main Logger
to push which one should be called which seems to be pretty vague.
Since it's Logger which didn't expose an interface
and with static
methods, what's the right design to solve the problem?
Aucun commentaire:
Enregistrer un commentaire