Skip to content

interface ILogger

cangjie
public interface ILogger

功能:定义日志记录器的公共接口。

成员概览

成员功能
func log(LogLevel, EventId, TState, ?Exception, (TState, ?Exception) -> String)按指定级别记录日志。
func log(LogEntry<TState>)按日志条目记录日志。
func log(LogLevel, ?String)按消息记录日志。
func log(LogLevel, EventId, ?String)按事件标识和消息记录日志。
func log(LogLevel, ?Exception, ?String)按异常和消息记录日志。
func log(LogLevel, EventId, ?Exception, ?String)按事件标识、异常和消息记录日志。
func isEnabled(LogLevel)检查指定日志级别是否启用。
func trace(?String)记录一条跟踪级别日志。
func trace(EventId, ?String)记录一条带事件标识的跟踪级别日志。
func trace(?Exception, ?String)记录一条带异常的跟踪级别日志。
func trace(EventId, ?Exception, ?String)记录一条带事件标识和异常的跟踪级别日志。
func debug(?String)记录一条调试级别日志。
func debug(EventId, ?String)记录一条带事件标识的调试级别日志。
func debug(?Exception, ?String)记录一条带异常的调试级别日志。
func debug(EventId, ?Exception, ?String)记录一条带事件标识和异常的调试级别日志。
func info(?String)记录一条信息级别日志。
func info(EventId, ?String)记录一条带事件标识的信息级别日志。
func info(?Exception, ?String)记录一条带异常的信息级别日志。
func info(EventId, ?Exception, ?String)记录一条带事件标识和异常的信息级别日志。
func warn(?String)记录一条警告级别日志。
func warn(EventId, ?String)记录一条带事件标识的警告级别日志。
func warn(?Exception, ?String)记录一条带异常的警告级别日志。
func warn(EventId, ?Exception, ?String)记录一条带事件标识和异常的警告级别日志。
func error(?String)记录一条错误级别日志。
func error(EventId, ?String)记录一条带事件标识的错误级别日志。
func error(?Exception, ?String)记录一条带异常的错误级别日志。
func error(EventId, ?Exception, ?String)记录一条带事件标识和异常的错误级别日志。
func fatal(?String)记录一条致命级别日志。
func fatal(EventId, ?String)记录一条带事件标识的致命级别日志。
func fatal(?Exception, ?String)记录一条带异常的致命级别日志。
func fatal(EventId, ?Exception, ?String)记录一条带事件标识和异常的致命级别日志。

func log(LogLevel, EventId, TState, ?Exception, (TState, ?Exception) -> String)

cangjie
func log<TState>(logLevel: LogLevel, eventId: EventId, state: TState, exception: ?Exception,
formatter: (TState, ?Exception) -> String): Unit where TState <: ToString

功能:按指定级别记录日志。

参数:

  • logLevel: LogLevel - 日志级别。
  • eventId: EventId - 事件标识。
  • state: TState - 日志状态对象。
  • exception: ?Exception - 关联的异常对象。
  • formatter: (TState, ?Exception) -> String - 将状态格式化为字符串的函数。

返回值:

  • Unit

func log(LogEntry<TState>)

cangjie
func log<TState>(entry: LogEntry<TState>): Unit where TState <: ToString

功能:按日志条目记录日志。

参数:

  • entry: LogEntry<TState> - 单条日志记录的完整上下文。

返回值:

  • Unit

func log(LogLevel, ?String)

cangjie
func log(logLevel: LogLevel, message: ?String): Unit

功能:按消息记录日志。

参数:

  • logLevel: LogLevel - 日志级别。
  • message: ?String - 日志消息。

返回值:

  • Unit

func log(LogLevel, EventId, ?String)

cangjie
func log(logLevel: LogLevel, eventId: EventId, message: ?String): Unit

功能:按事件标识和消息记录日志。

参数:

  • logLevel: LogLevel - 日志级别。
  • eventId: EventId - 事件标识。
  • message: ?String - 日志消息。

返回值:

  • Unit

func log(LogLevel, ?Exception, ?String)

cangjie
func log(logLevel: LogLevel, exception: ?Exception, message: ?String): Unit

功能:按异常和消息记录日志。

参数:

  • logLevel: LogLevel - 日志级别。
  • exception: ?Exception - 关联的异常对象。
  • message: ?String - 日志消息。

返回值:

  • Unit

func log(LogLevel, EventId, ?Exception, ?String)

cangjie
func log(logLevel: LogLevel, eventId: EventId, exception: ?Exception, message: ?String): Unit

功能:按事件标识、异常和消息记录日志。

参数:

  • logLevel: LogLevel - 日志级别。
  • eventId: EventId - 事件标识。
  • exception: ?Exception - 关联的异常对象。
  • message: ?String - 日志消息。

返回值:

  • Unit

func isEnabled(LogLevel)

cangjie
func isEnabled(logLevel: LogLevel): Bool

功能:检查指定日志级别是否启用。

参数:

  • logLevel: LogLevel - 要检查的日志级别。

返回值:

  • Bool - 如果该级别已启用则返回 true,否则返回 false

func trace(?String)

cangjie
func trace(message: ?String): Unit

功能:记录一条跟踪级别日志。

参数:

  • message: ?String - 日志消息。

返回值:

  • Unit

func trace(EventId, ?String)

cangjie
func trace(eventId: EventId, message: ?String): Unit

功能:记录一条带事件标识的跟踪级别日志。

参数:

  • eventId: EventId - 事件标识。
  • message: ?String - 日志消息。

返回值:

  • Unit

func trace(?Exception, ?String)

cangjie
func trace(exception: ?Exception, message: ?String): Unit

功能:记录一条带异常的跟踪级别日志。

参数:

  • exception: ?Exception - 关联的异常对象。
  • message: ?String - 日志消息。

返回值:

  • Unit

func trace(EventId, ?Exception, ?String)

cangjie
func trace(eventId: EventId, exception: ?Exception, message: ?String): Unit

功能:记录一条带事件标识和异常的跟踪级别日志。

参数:

  • eventId: EventId - 事件标识。
  • exception: ?Exception - 关联的异常对象。
  • message: ?String - 日志消息。

返回值:

  • Unit

func debug(?String)

cangjie
func debug(message: ?String): Unit

功能:记录一条调试级别日志。

参数:

  • message: ?String - 日志消息。

返回值:

  • Unit

func debug(EventId, ?String)

cangjie
func debug(eventId: EventId, message: ?String): Unit

功能:记录一条带事件标识的调试级别日志。

参数:

  • eventId: EventId - 事件标识。
  • message: ?String - 日志消息。

返回值:

  • Unit

func debug(?Exception, ?String)

cangjie
func debug(exception: ?Exception, message: ?String): Unit

功能:记录一条带异常的调试级别日志。

参数:

  • exception: ?Exception - 关联的异常对象。
  • message: ?String - 日志消息。

返回值:

  • Unit

func debug(EventId, ?Exception, ?String)

cangjie
func debug(eventId: EventId, exception: ?Exception, message: ?String): Unit

功能:记录一条带事件标识和异常的调试级别日志。

参数:

  • eventId: EventId - 事件标识。
  • exception: ?Exception - 关联的异常对象。
  • message: ?String - 日志消息。

返回值:

  • Unit

func info(?String)

cangjie
func info(message: ?String): Unit

功能:记录一条信息级别日志。

参数:

  • message: ?String - 日志消息。

返回值:

  • Unit

func info(EventId, ?String)

cangjie
func info(eventId: EventId, message: ?String): Unit

功能:记录一条带事件标识的信息级别日志。

参数:

  • eventId: EventId - 事件标识。
  • message: ?String - 日志消息。

返回值:

  • Unit

func info(?Exception, ?String)

cangjie
func info(exception: ?Exception, message: ?String): Unit

功能:记录一条带异常的信息级别日志。

参数:

  • exception: ?Exception - 关联的异常对象。
  • message: ?String - 日志消息。

返回值:

  • Unit

func info(EventId, ?Exception, ?String)

cangjie
func info(eventId: EventId, exception: ?Exception, message: ?String): Unit

功能:记录一条带事件标识和异常的信息级别日志。

参数:

  • eventId: EventId - 事件标识。
  • exception: ?Exception - 关联的异常对象。
  • message: ?String - 日志消息。

返回值:

  • Unit

func warn(?String)

cangjie
func warn(message: ?String): Unit

功能:记录一条警告级别日志。

参数:

  • message: ?String - 日志消息。

返回值:

  • Unit

func warn(EventId, ?String)

cangjie
func warn(eventId: EventId, message: ?String): Unit

功能:记录一条带事件标识的警告级别日志。

参数:

  • eventId: EventId - 事件标识。
  • message: ?String - 日志消息。

返回值:

  • Unit

func warn(?Exception, ?String)

cangjie
func warn(exception: ?Exception, message: ?String): Unit

功能:记录一条带异常的警告级别日志。

参数:

  • exception: ?Exception - 关联的异常对象。
  • message: ?String - 日志消息。

返回值:

  • Unit

func warn(EventId, ?Exception, ?String)

cangjie
func warn(eventId: EventId, exception: ?Exception, message: ?String): Unit

功能:记录一条带事件标识和异常的警告级别日志。

参数:

  • eventId: EventId - 事件标识。
  • exception: ?Exception - 关联的异常对象。
  • message: ?String - 日志消息。

返回值:

  • Unit

func error(?String)

cangjie
func error(message: ?String): Unit

功能:记录一条错误级别日志。

参数:

  • message: ?String - 日志消息。

返回值:

  • Unit

func error(EventId, ?String)

cangjie
func error(eventId: EventId, message: ?String): Unit

功能:记录一条带事件标识的错误级别日志。

参数:

  • eventId: EventId - 事件标识。
  • message: ?String - 日志消息。

返回值:

  • Unit

func error(?Exception, ?String)

cangjie
func error(exception: ?Exception, message: ?String): Unit

功能:记录一条带异常的错误级别日志。

参数:

  • exception: ?Exception - 关联的异常对象。
  • message: ?String - 日志消息。

返回值:

  • Unit

func error(EventId, ?Exception, ?String)

cangjie
func error(eventId: EventId, exception: ?Exception, message: ?String): Unit

功能:记录一条带事件标识和异常的错误级别日志。

参数:

  • eventId: EventId - 事件标识。
  • exception: ?Exception - 关联的异常对象。
  • message: ?String - 日志消息。

返回值:

  • Unit

func fatal(?String)

cangjie
func fatal(message: ?String): Unit

功能:记录一条致命级别日志。

参数:

  • message: ?String - 日志消息。

返回值:

  • Unit

func fatal(EventId, ?String)

cangjie
func fatal(eventId: EventId, message: ?String): Unit

功能:记录一条带事件标识的致命级别日志。

参数:

  • eventId: EventId - 事件标识。
  • message: ?String - 日志消息。

返回值:

  • Unit

func fatal(?Exception, ?String)

cangjie
func fatal(exception: ?Exception, message: ?String): Unit

功能:记录一条带异常的致命级别日志。

参数:

  • exception: ?Exception - 关联的异常对象。
  • message: ?String - 日志消息。

返回值:

  • Unit

func fatal(EventId, ?Exception, ?String)

cangjie
func fatal(eventId: EventId, exception: ?Exception, message: ?String): Unit

功能:记录一条带事件标识和异常的致命级别日志。

参数:

  • eventId: EventId - 事件标识。
  • exception: ?Exception - 关联的异常对象。
  • message: ?String - 日志消息。

返回值:

  • Unit