-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathMethodTimeLogger.cs
40 lines (34 loc) · 1.08 KB
/
MethodTimeLogger.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// using System.Reflection;
// using Catel.Logging;
// using System;
// /// <summary>
// /// Note: do not rename this class or put it inside a namespace.
// /// </summary>
// internal static class MethodTimeLogger
// {
// #region Methods
// public static void Log(MethodBase methodBase, long milliseconds, string message)
// {
// Log(methodBase.DeclaringType, methodBase.Name, milliseconds, message);
// }
// public static void Log(Type type, string methodName, long milliseconds, string message)
// {
// if (type is null)
// {
// return;
// }
// if (milliseconds == 0)
// {
// // Don't log superfast methods
// return;
// }
// var finalMessage = $"[METHODTIMER] {type.Name}.{methodName} took '{milliseconds.ToString()}' ms";
// if (!string.IsNullOrWhiteSpace(message))
// {
// finalMessage += $" | {message}";
// }
// var logger = LogManager.GetLogger(type);
// logger.Debug(finalMessage);
// }
// #endregion
// }