diff --git a/Facade/BadLogger.cs b/Facade/BadLogger.cs index 7e6fd11..2cdfa06 100644 --- a/Facade/BadLogger.cs +++ b/Facade/BadLogger.cs @@ -1,6 +1,6 @@ public class BadLogger { - public void Log(string message, LogType logType, Exception? ex) + public void Log(string message, LogType logType, LogTarget target, Exception? ex) { Console.WriteLine($"{DateTime.UtcNow:s} [{logType.ToString().ToUpper()}] {message}"); diff --git a/Facade/LogTarget.cs b/Facade/LogTarget.cs new file mode 100644 index 0000000..991a350 --- /dev/null +++ b/Facade/LogTarget.cs @@ -0,0 +1,6 @@ +public enum LogTarget +{ + Console = 0, + File = 1, + Slack = 2 +} \ No newline at end of file diff --git a/Facade/Logger.cs b/Facade/Logger.cs index 0a753f0..816198a 100644 --- a/Facade/Logger.cs +++ b/Facade/Logger.cs @@ -8,16 +8,16 @@ public class Logger : ILogger public void Information(string message) { - _logger.Log(message, LogType.Info, null); + _logger.Log(message, LogType.Info, LogTarget.Console, null); } public void Error(string message, Exception? ex = null) { - _logger.Log(message, LogType.Error, ex); + _logger.Log(message, LogType.Error, LogTarget.Console, ex); } public void Fatal(string message, Exception? ex = null) { - _logger.Log(message, LogType.Fatal, ex); + _logger.Log(message, LogType.Fatal, LogTarget.Console, ex); } } \ No newline at end of file diff --git a/Facade/Program.cs b/Facade/Program.cs index 3657b2e..d2e2ef9 100644 --- a/Facade/Program.cs +++ b/Facade/Program.cs @@ -3,8 +3,8 @@ // Using the bad logger var badLogger = new BadLogger(); -badLogger.Log("This is an information message", LogType.Info, null); -badLogger.Log("This is an error message", LogType.Error, null); +badLogger.Log("This is an information message", LogType.Info, LogTarget.Console, null); +badLogger.Log("This is an error message", LogType.Error, LogTarget.Console, null); try { @@ -12,7 +12,7 @@ try } catch (Exception ex) { - badLogger.Log("This is an error message with exception", LogType.Error, ex); + badLogger.Log("This is an error message with exception", LogType.Error, LogTarget.Console, ex); } try @@ -21,7 +21,7 @@ try } catch (Exception ex) { - badLogger.Log("This is a fatal error message", LogType.Fatal, ex); + badLogger.Log("This is a fatal error message", LogType.Fatal, LogTarget.Console, ex); } // Using the good logger