public static ILogLevel String2Enum(string value) { ILogLevel result = ILogLevel.Debug; Enum.TryParse(InitCap(value), out result); return(result); }
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; }
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); } }
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)); }
public bool Contains(ILogLevel other) => (Flag & other.Flag) == other.Flag;
public void SetLevel(string level) { _logLevel = String2Enum(level); }
public ILogger Log(ILogLevel logLevel, Action <ILog> logAction) => this;
public static NLogWrapper.ILogger CreateLogger(Type T, ILogLevel logLevel, string fallbackPath = null) { //leave for compaitibility return(new Logger(T, logLevel.ToString(), fallbackPath)); }
public void Log(ILogLevel level, string message) { Log(new LogEntity(message, level)); }
public Logger(ILogWriter logWriter, LogLevel defaultLevel = null) { DefaultLevel = defaultLevel ?? LogLevel.OFF; LogWriter = logWriter; }