| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace WireMock.Logging |
| | | 4 | | { |
| | | 5 | | /// <summary> |
| | | 6 | | /// WireMockConsoleLogger which logs to Console |
| | | 7 | | /// </summary> |
| | | 8 | | /// <seealso cref="IWireMockLogger" /> |
| | | 9 | | public class WireMockConsoleLogger : IWireMockLogger |
| | | 10 | | { |
| | | 11 | | /// <see cref="IWireMockLogger.Debug"/> |
| | | 12 | | public void Debug(string formatString, params object[] args) |
| | 0 | 13 | | { |
| | 0 | 14 | | Console.WriteLine(Format("Debug", formatString, args)); |
| | 0 | 15 | | } |
| | | 16 | | |
| | | 17 | | /// <see cref="IWireMockLogger.Info"/> |
| | | 18 | | public void Info(string formatString, params object[] args) |
| | 0 | 19 | | { |
| | 0 | 20 | | Console.WriteLine(Format("Info", formatString, args)); |
| | 0 | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <see cref="IWireMockLogger.Warn"/> |
| | | 24 | | public void Warn(string formatString, params object[] args) |
| | 0 | 25 | | { |
| | 0 | 26 | | Console.WriteLine(Format("Warn", formatString, args)); |
| | 0 | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <see cref="IWireMockLogger.Error"/> |
| | | 30 | | public void Error(string formatString, params object[] args) |
| | 0 | 31 | | { |
| | 0 | 32 | | Console.WriteLine(Format("Error", formatString, args)); |
| | 0 | 33 | | } |
| | | 34 | | |
| | | 35 | | private static string Format(string level, string formatString, params object[] args) |
| | 0 | 36 | | { |
| | 0 | 37 | | string message = string.Format(formatString, args); |
| | | 38 | | |
| | 0 | 39 | | return $"{DateTime.UtcNow} [{level}] : {message}"; |
| | 0 | 40 | | } |
| | | 41 | | } |
| | | 42 | | } |