如何关闭每个日志的日期和时间?

时间:2016-06-29 00:38:44

标签: xcglogger

我真的不需要打印到xcode控制台的每个日志的日期和时间。我试过log.dateFormatter = nil,但似乎没有为我做任何事情。

1 个答案:

答案 0 :(得分:1)

其repo的Advanced Usage部分指定了一个参数showDate,可以将其设置为false

// Create a logger object with no destinations
let log = XCGLogger(identifier: "advancedLogger", includeDefaultDestinations: false)

// Create a destination for the system console log (via NSLog)
let systemLogDestination = XCGNSLogDestination(owner: log, identifier: "advancedLogger.systemLogDestination")

// Optionally set some configuration options
systemLogDestination.outputLogLevel = .Debug
systemLogDestination.showLogIdentifier = false
systemLogDestination.showFunctionName = true
systemLogDestination.showThreadName = true
systemLogDestination.showLogLevel = true
systemLogDestination.showFileName = true
systemLogDestination.showLineNumber = true
systemLogDestination.showDate = false

// Add the destination to the logger
log.addLogDestination(systemLogDestination)