为了集成 NLog,我们想要定义一个接口,并且正在考虑两种方法。我们正在使用 C#。
方法一:
public interface ILoggingManager
{
void DoErrorLogging(type , string )
void DoErrorLogging(type , string , exception )
void DoTraceLogging(type , string )
void DoTrace Logging(type , string , exception )
// And so on for all the types that Nlog supports.
....
// Finally would have 10 methods defined in this interface.
}
方法二:
//Have an Enum defined for the logging levels
public enum LoggingLevel
{
Error,
Warn,
Info,
Debug,
Trace
}
public interface ILoggingManager
{
void DoLogging(type , LoggingLevel , string )
void DoLogging(type , LoggingLevel , exception )
}
问题:
- 牢记设计原则(如 SOLID),哪种方法更好?
- 就性能而言,哪种方法更好?