public bool Log(MvxLogLevel logLevel, Func <string> messageFunc, Exception exception, params object[] formatParameters) { if (messageFunc == null) { return(true); } messageFunc = LogMessageFormatter.SimulateStructuredLogging(messageFunc, formatParameters); Write(logLevel, messageFunc(), exception); return(true); }
public bool Log(MvxLogLevel logLevel, Func <string> messageFunc, Exception exception, params object[] formatParameters) { if (messageFunc == null) { //nothing to log.. return(true); } messageFunc = LogMessageFormatter.SimulateStructuredLogging(messageFunc, formatParameters); _logWriteDelegate(ToLogMessageSeverity(logLevel), LogSystem, _skipLevel, exception, true, 0, null, _category, null, messageFunc.Invoke()); return(true); }
public bool Log(MvxLogLevel logLevel, Func <string> messageFunc, Exception exception, params object[] formatParameters) { var severity = MapSeverity(logLevel); if (messageFunc == null) { return(_shouldLog(_loggerName, severity)); } messageFunc = LogMessageFormatter.SimulateStructuredLogging(messageFunc, formatParameters); if (exception != null) { return(LogException(logLevel, messageFunc, exception)); } _writeLog(_loggerName, messageFunc(), severity); return(true); }
public bool Log(MvxLogLevel logLevel, Func <string> messageFunc, Exception exception, params object[] formatParameters) { if (messageFunc == null) { return(IsLogLevelEnable(logLevel)); } if (!IsLogLevelEnable(logLevel)) { return(false); } string message = messageFunc(); IEnumerable <string> patternMatches; string formattedMessage = LogMessageFormatter.FormatStructuredMessage(message, formatParameters, out patternMatches); // determine correct caller - this might change due to jit optimizations with method inlining if (s_callerStackBoundaryType == null) { lock (CallerStackBoundaryTypeSync) s_callerStackBoundaryType = typeof(MvxLog); } var translatedLevel = TranslateLevel(logLevel); object loggingEvent = _createLoggingEvent(_logger, s_callerStackBoundaryType, translatedLevel, formattedMessage, exception); PopulateProperties(loggingEvent, patternMatches, formatParameters); _logDelegate(_logger, loggingEvent); return(true); }
public bool Log(MvxLogLevel logLevel, Func <string> messageFunc, Exception exception, params object[] formatParameters) { if (messageFunc == null) { return(IsLogLevelEnable(logLevel)); } messageFunc = LogMessageFormatter.SimulateStructuredLogging(messageFunc, formatParameters); if (_logEventInfoFact != null) { if (IsLogLevelEnable(logLevel)) { var nlogLevel = TranslateLevel(logLevel); _logger.Log(_logEventInfoFact(_logger.Name, nlogLevel, messageFunc(), exception)); return(true); } return(false); } if (exception != null) { return(LogException(logLevel, messageFunc, exception)); } switch (logLevel) { case MvxLogLevel.Debug: if (_logger.IsDebugEnabled) { _logger.Debug(messageFunc()); return(true); } break; case MvxLogLevel.Info: if (_logger.IsInfoEnabled) { _logger.Info(messageFunc()); return(true); } break; case MvxLogLevel.Warn: if (_logger.IsWarnEnabled) { _logger.Warn(messageFunc()); return(true); } break; case MvxLogLevel.Error: if (_logger.IsErrorEnabled) { _logger.Error(messageFunc()); return(true); } break; case MvxLogLevel.Fatal: if (_logger.IsFatalEnabled) { _logger.Fatal(messageFunc()); return(true); } break; default: if (_logger.IsTraceEnabled) { _logger.Trace(messageFunc()); return(true); } break; } return(false); }