/// <summary> /// Writes a Log message /// </summary> /// <param name="message">Log data</param> public static void Debug(this IKLogger logger, string message, [System.Runtime.CompilerServices.CallerMemberName] string memberName = null, [System.Runtime.CompilerServices.CallerLineNumber] int lineNumber = 0, [System.Runtime.CompilerServices.CallerFilePath] string memberType = null) { if (logger == null) { return; } logger.Log(LogLevel.Debug, message, memberName, lineNumber, memberType); }
/// <summary> /// Writes a Log message /// </summary> /// <param name="args"> /// <para>A collection of Log data</para> /// <para>Eg: new KissLog.Args("value1", 100)</para> /// </param> public static void Trace(this IKLogger logger, Args args, JsonSerializeOptions options = null, [System.Runtime.CompilerServices.CallerMemberName] string memberName = null, [System.Runtime.CompilerServices.CallerLineNumber] int lineNumber = 0, [System.Runtime.CompilerServices.CallerFilePath] string memberType = null) { if (logger == null) { return; } logger.Log(LogLevel.Trace, args, options, memberName, lineNumber, memberType); }
/// <summary> /// Writes a Log message /// </summary> /// <param name="ex">Log data</param> public static void Trace(this IKLogger logger, Exception ex, [System.Runtime.CompilerServices.CallerMemberName] string memberName = null, [System.Runtime.CompilerServices.CallerLineNumber] int lineNumber = 0, [System.Runtime.CompilerServices.CallerFilePath] string memberType = null) { if (logger == null) { return; } logger.Log(LogLevel.Trace, ex, memberName, lineNumber, memberType); }
/// <summary> /// Writes a Log message /// </summary> /// <param name="json">Log data</param> public static void Critical(this IKLogger logger, object json, JsonSerializeOptions options = null, [System.Runtime.CompilerServices.CallerMemberName] string memberName = null, [System.Runtime.CompilerServices.CallerLineNumber] int lineNumber = 0, [System.Runtime.CompilerServices.CallerFilePath] string memberType = null) { if (logger == null) { return; } logger.Log(LogLevel.Critical, json, options, memberName, lineNumber, memberType); }
protected override void Write(LogEventInfo logEvent) { if (logEvent == null) { return; } LogLevel logLevel = GetLogLevel(logEvent.Level.Name); string message = Layout.Render(logEvent); IKLogger logger = Logger.Factory.Get(); if (!string.IsNullOrEmpty(logEvent.CallerClassName)) { logger.Log(logLevel, message, logEvent.CallerMemberName, logEvent.CallerLineNumber, logEvent.CallerClassName); } else { logger.Log(logLevel, message, string.Empty, 0, string.Empty); } }
protected override void Append(LoggingEvent loggingEvent) { if (loggingEvent == null) { return; } LogLevel logLevel = GetLogLevel(loggingEvent.Level.Name); string message = RenderLoggingEvent(loggingEvent); IKLogger logger = Logger.Factory.Get(); if (!string.IsNullOrEmpty(loggingEvent.LocationInformation?.ClassName)) { int lineNumber = 0; int.TryParse(loggingEvent.LocationInformation?.LineNumber, out lineNumber); logger.Log(logLevel, message, loggingEvent.LocationInformation.MethodName, lineNumber, loggingEvent.LocationInformation.ClassName); } else { logger.Log(logLevel, message, string.Empty, 0, string.Empty); } }