コード例 #1
0
ファイル: Logger.cs プロジェクト: it-arjan/NLog.ZeroConfig
        public static ILogLevel String2Enum(string value)
        {
            ILogLevel result = ILogLevel.Debug;

            Enum.TryParse(InitCap(value), out result);
            return(result);
        }
コード例 #2
0
 public LogEntity(string message,
                  ILogLevel logLevel = null,
                  DateTime?time      = null,
                  string scope       = null,
                  string callerName  = null)
 {
     Message    = message;
     LogLevel   = logLevel;
     Time       = time ?? DateTime.Now;
     Scope      = scope;
     CallerName = callerName;
 }
コード例 #3
0
ファイル: Logger.cs プロジェクト: it-arjan/NLog.ZeroConfig
        private NLog.LogLevel ILevel2NLogLevel(ILogLevel level)
        {
            // didn't see right away how to do this better ;)
            switch (level)
            {
            case ILogLevel.Trace: return(LogLevel.Trace);

            case ILogLevel.Debug: return(LogLevel.Debug);

            case ILogLevel.Info: return(LogLevel.Info);

            case ILogLevel.Error: return(LogLevel.Error);

            case ILogLevel.Off: return(LogLevel.Off);

            default: return(LogLevel.Debug);
            }
        }
コード例 #4
0
ファイル: Logger.cs プロジェクト: it-arjan/NLog.ZeroConfig
        public Logger(Type T, string level, string fallbackLogfolder = null)
        {
            _fallbackLogPath = Path.Combine(Path.GetTempPath(), _fallbackLogFileName);
            _logLevel        = String2Enum(level);
            _logger          = NLog.LogManager.GetLogger(T.Name);

            if (_logLevel != ILogLevel.Off)
            {
                if (fallbackLogfolder != null)
                {
                    if (GoodForLogging(fallbackLogfolder))
                    {
                        _fallbackLogPath = Path.Combine(fallbackLogfolder, _fallbackLogFileName);
                    }
                }
            }
            _callerClass = T.Name;
            NLogConfigure(ILevel2NLogLevel(_logLevel));
        }
コード例 #5
0
ファイル: LogLevel.cs プロジェクト: he-dev/reusable
 public bool Contains(ILogLevel other) => (Flag & other.Flag) == other.Flag;
コード例 #6
0
ファイル: Logger.cs プロジェクト: it-arjan/NLog.ZeroConfig
 public void SetLevel(string level)
 {
     _logLevel = String2Enum(level);
 }
コード例 #7
0
 public ILogger Log(ILogLevel logLevel, Action <ILog> logAction) => this;
コード例 #8
0
 public static NLogWrapper.ILogger CreateLogger(Type T, ILogLevel logLevel, string fallbackPath = null)
 {
     //leave for compaitibility
     return(new Logger(T, logLevel.ToString(), fallbackPath));
 }
コード例 #9
0
 public void Log(ILogLevel level, string message)
 {
     Log(new LogEntity(message, level));
 }
コード例 #10
0
 public Logger(ILogWriter logWriter, LogLevel defaultLevel = null)
 {
     DefaultLevel = defaultLevel ?? LogLevel.OFF;
     LogWriter    = logWriter;
 }