Exemple #1
0
        public void Log(UnitLogLevel level, Exception e)
        {
            switch (level)
            {
            case UnitLogLevel.Trace:
                log.Log(LogLevel.Trace, e);
                break;

            case UnitLogLevel.Debug:
                log.Log(LogLevel.Debug, e);
                break;

            case UnitLogLevel.Info:
                log.Log(LogLevel.Info, e);
                break;

            case UnitLogLevel.Warning:
                log.Log(LogLevel.Warn, e);
                break;

            case UnitLogLevel.Error:
                log.Log(LogLevel.Error, e);
                break;

            case UnitLogLevel.Fatal:
                log.Log(LogLevel.Fatal, e);
                break;

            default:
                break;
            }
        }
Exemple #2
0
        public void Log(UnitLogLevel level, string msg, [CallerMemberName] string methodName = "", [CallerLineNumber] int sourceLineNumber = 0)
        {
            StackFrame frame     = new StackFrame(1, false);
            MethodBase method    = frame.GetMethod();
            Type       className = method.DeclaringType;

            msg = msg + " | Method Name: " + className + "." + methodName + " | Line Number: " + sourceLineNumber;

            switch (level)
            {
            case UnitLogLevel.Trace:
                log.Log(LogLevel.Trace, msg);
                break;

            case UnitLogLevel.Debug:
                log.Log(LogLevel.Debug, msg);
                break;

            case UnitLogLevel.Info:
                log.Log(LogLevel.Info, msg);
                break;

            case UnitLogLevel.Warning:
                log.Log(LogLevel.Warn, msg);
                break;

            case UnitLogLevel.Error:
                log.Log(LogLevel.Error, msg);
                break;

            case UnitLogLevel.Fatal:
                log.Log(LogLevel.Fatal, msg);
                break;

            default:
                break;
            }
        }