Raghav
Raghav

Reputation: 114

How do I turn off the date and time for each log?

I don't really need the date and time for each log that prints to the xcode console. I've tried log.dateFormatter = nil but that didn't seem to do anything for me.

Upvotes: 0

Views: 155

Answers (1)

Dylon
Dylon

Reputation: 1750

The Advanced Usage section of its repo specifies a parameter, showDate, that can be set to 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)

Upvotes: 1

Related Questions