Vapor 2.0 - 日志(Log)

前往 Vapor 2.0 - 文档目录

使用drop.log日志信息。

drop.log.info("Informational log")

类型(Types)

下面是您可以调用日志协议的方法。只有在生产(production)模式下才会出现errorfatal

Method Production
info No
warning No
verbose No
debug No
error Yes
fatal Yes

协议(Protocol)

通过遵循LogProtocol创建您自己的日志记录器。

/// Logger protocol. Custom loggers must conform
/// to this protocol
/// 记录器的协议。自定义日志程序必须遵守该协议
public protocol LogProtocol: class {
    /// Enabled log levels. Only levels in this
    /// array should be logged.
    /// 启用日志级别。只有在这个数组中才会被记录。
    var enabled: [LogLevel] { get set }

    /// Log the given message at the passed filter level.
    /// file, function and line of the logging call
    /// are automatically injected in the convenience function.
    /// 在传递的过滤器级别上记录给定的消息。日志记录调用的文件、函数和行被自动地注入到便利函数中。
    func log(_ level: LogLevel, message: String, file: String, function: String, line: Int)
}

你可能感兴趣的:(Vapor 2.0 - 日志(Log))