[swift-users] Any way to declare a method that suppresses the string interpolation warning?

Rick Mann rmann at latencyzero.com
Fri Apr 21 06:35:30 CDT 2017


I have a debugLog() method that looks like this:

func
debugLog<T>(_ inMsg: T, _ inFile : String = #file, _ inLine : Int = #line)
{
	let df = DateFormatter()
	df.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
	let time = df.string(from: Date())
	
	let file = (inFile as NSString).lastPathComponent
	print("\(time) \(file):\(inLine)    \(inMsg)")
}

Is there any way to decorate it so that string interpolation of optionals passed to it inMsg don't produce the warning about using debugDescription? In the case of debug logging, that's completely acceptable, and I don't want to have to write String(describing:) everywhere.


-- 
Rick Mann
rmann at latencyzero.com




More information about the swift-users mailing list