Skip to content

Instantly share code, notes, and snippets.

@warriorg
Forked from xmzio/Macros.swift
Last active September 5, 2015 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warriorg/1cc21d05ef5aa59495ab to your computer and use it in GitHub Desktop.
Save warriorg/1cc21d05ef5aa59495ab to your computer and use it in GitHub Desktop.
My aLog and dLog macros in Swift (to abbreviate NSLog)
//
// 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