From e2f8f5095feaac41a8b7fea1033b3ab10b48160b Mon Sep 17 00:00:00 2001 From: bao-qian Date: Wed, 30 Nov 2016 00:39:03 +0000 Subject: [PATCH] fix stopwatch logging type --- Wox.Infrastructure/Logger/Log.cs | 18 ++++++++++++++---- Wox.Infrastructure/Stopwatch.cs | 6 ++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Wox.Infrastructure/Logger/Log.cs b/Wox.Infrastructure/Logger/Log.cs index e4ce5b070b..41be9cff29 100644 --- a/Wox.Infrastructure/Logger/Log.cs +++ b/Wox.Infrastructure/Logger/Log.cs @@ -30,7 +30,7 @@ namespace Wox.Infrastructure.Logger LogManager.Configuration = configuration; } - private static string CallerType() + public static string CallerType() { var stackTrace = new StackTrace(); var stackFrames = stackTrace.GetFrames().NonNull(); @@ -79,22 +79,32 @@ namespace Wox.Infrastructure.Logger } while (e != null); } - public static void Debug(string msg) + public static void Debug(string type, string msg) { - var type = CallerType(); var logger = LogManager.GetLogger(type); System.Diagnostics.Debug.WriteLine($"DEBUG: {msg}"); logger.Debug(msg); } - public static void Info(string msg) + public static void Debug(string msg) { var type = CallerType(); + Debug(type, msg); + } + + public static void Info(string type, string msg) + { var logger = LogManager.GetLogger(type); System.Diagnostics.Debug.WriteLine($"INFO: {msg}"); logger.Info(msg); } + public static void Info(string msg) + { + var type = CallerType(); + Info(type, msg); + } + public static void Warn(string msg) { var type = CallerType(); diff --git a/Wox.Infrastructure/Stopwatch.cs b/Wox.Infrastructure/Stopwatch.cs index 8ce1ca36f0..d9c11af469 100644 --- a/Wox.Infrastructure/Stopwatch.cs +++ b/Wox.Infrastructure/Stopwatch.cs @@ -19,7 +19,8 @@ namespace Wox.Infrastructure stopWatch.Stop(); var milliseconds = stopWatch.ElapsedMilliseconds; string info = $"{name} : {milliseconds}ms"; - Log.Debug(info); + var type = Log.CallerType(); + Log.Debug(type, info); return milliseconds; } @@ -31,7 +32,8 @@ namespace Wox.Infrastructure stopWatch.Stop(); var milliseconds = stopWatch.ElapsedMilliseconds; string info = $"{name} : {milliseconds}ms"; - Log.Info(info); + var type = Log.CallerType(); + Log.Info(type, info); return milliseconds; }