-
-
Save alekseypotapov-dev/86d81dd7b688fd5fdb36e834c21e8d49 to your computer and use it in GitHub Desktop.
My aLog and dLog macros in Swift (to abbreviate NSLog)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Macros.swift | |
// | |
// Created by Xavier Muñiz on 6/12/14. | |
import Foundation | |
// dLog and aLog macros to abbreviate NSLog. | |
// Use like this: | |
// | |
// dLog("Log this!") | |
// | |
#if DEBUG | |
func dLog(message: String, filename: String = __FILE__, function: String = __FUNCTION__, line: Int = __LINE__) { | |
NSLog("[\(filename.lastPathComponent):\(line)] \(function) - \(message)") | |
} | |
#else | |
func dLog(message: String, filename: String = __FILE__, function: String = __FUNCTION__, line: Int = __LINE__) { | |
} | |
#endif | |
func aLog(message: String, filename: String = __FILE__, function: String = __FUNCTION__, line: Int = __LINE__) { | |
NSLog("[\(filename.lastPathComponent):\(line)] \(function) - \(message)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment