示例#1
0
        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);
        }
示例#2
0
        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));
        }
示例#3
0
 public static void RegisterCommonTape(ILogTape tape)
 {
     commonLogTape = tape;
 }
示例#4
0
 public ScopeLogger(string scopeName, ILogTape baseLogger)
 {
     scopeSource = scopeName;
     this.baseLogger = baseLogger;
 }
示例#5
0
 public ScopeLogger(string scopeName, ILogTape baseLogger)
 {
     scopeSource     = scopeName;
     this.baseLogger = baseLogger;
 }
示例#6
0
 public static void RegisterCommonTape(ILogTape tape)
 {
     commonLogTape = tape;
 }