Skip to content

Instantly share code, notes, and snippets.

@ozgurodabasi
Created December 4, 2018 21:38
Show Gist options
  • Save ozgurodabasi/dc74d40bdc508ff18cf4644a390ccbd8 to your computer and use it in GitHub Desktop.
Save ozgurodabasi/dc74d40bdc508ff18cf4644a390ccbd8 to your computer and use it in GitHub Desktop.
import os.log
import Foundation
let oslog = Log()
struct Log {
func info<T>(_ object: T, _ file: String = #file, _ function: String = #function, _ line: Int = #line) {
if AppConfig.loggingEnabled {
let fileName: String = (NSURL(string: file)?.lastPathComponent)!
let infoString: String = " πŸš€ -> \(fileName):\(function):[\(line)]: \(object)"
os_log(">> %{public}@", infoString)
}
}
func error<T>(_ object: T, _ file: String = #file, _ function: String = #function, _ line: Int = #line) {
if AppConfig.loggingEnabled {
let fileName: String = (NSURL(string: file)?.lastPathComponent)!
let infoString: String = " πŸ’”βŒ ERROR -> \(fileName):\(function):[\(line)]: \(object)"
os_log(">> %{public}@", infoString)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment