Created
October 24, 2016 21:09
-
-
Save joncardasis/6535cd7c423924b2731c87303e782bd1 to your computer and use it in GitHub Desktop.
A simple and quick logging file for Swift
This file contains 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
// | |
// Logging.swift | |
// JCLogging-Swift | |
// | |
// Created by Cardasis, Jonathan (J.) on 8/29/16. | |
// Copyright © 2016 Jonathan Cardasis. All rights reserved. | |
// | |
import Foundation | |
/** | |
Prints only if building for DEBUG | |
*/ | |
public func printd(items: Any...){ | |
#if DEBUG | |
var context: String { | |
return items.map({ String($0) }).joinWithSeparator("") | |
} | |
Swift.print(context) | |
#endif | |
} | |
/** | |
Prints verbose information. Only prints if building for DEBUG | |
*/ | |
public func printv(items: Any..., fileExecuter: String = #file, callingFunction: String = #function, executionLine: Int = #line){ | |
#if DEBUG | |
let filename = NSURL(string: fileExecuter)?.URLByDeletingPathExtension?.lastPathComponent ?? "" | |
var context: String { | |
return items.map({ String($0) }).joinWithSeparator("") | |
} | |
Swift.print("[\(filename).\(callingFunction): Line \(executionLine)] ", separator: " ", terminator: "") | |
Swift.print(context) | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment