public static ScopeLogger GetClassLogger(ILogTape baseLogger = null, int framesToSkip = 1) { // extracted from: https://github.com/NLog string loggerName; Type declaringType; do { StackFrame frame = new StackFrame(framesToSkip, false); var method = frame.GetMethod(); declaringType = method.DeclaringType; if (declaringType == null) { loggerName = method.Name; break; } framesToSkip++; loggerName = declaringType.FullName; } while (declaringType.Module.Name.Equals("mscorlib.dll", StringComparison.OrdinalIgnoreCase)); if (baseLogger == null) baseLogger = commonLogTape; return new ScopeLogger(loggerName, baseLogger); }
public static ScopeLogger GetClassLogger(ILogTape baseLogger = null, int framesToSkip = 1) { // extracted from: https://github.com/NLog string loggerName; Type declaringType; do { StackFrame frame = new StackFrame(framesToSkip, false); var method = frame.GetMethod(); declaringType = method.DeclaringType; if (declaringType == null) { loggerName = method.Name; break; } framesToSkip++; loggerName = declaringType.FullName; } while (declaringType.Module.Name.Equals("mscorlib.dll", StringComparison.OrdinalIgnoreCase)); if (baseLogger == null) { baseLogger = commonLogTape; } return(new ScopeLogger(loggerName, baseLogger)); }
public static void RegisterCommonTape(ILogTape tape) { commonLogTape = tape; }
public ScopeLogger(string scopeName, ILogTape baseLogger) { scopeSource = scopeName; this.baseLogger = baseLogger; }