0

How could you override print() to include the class and line number it was called from?

So print("Hello world") on line 17 of ViewController.swift would output:

ViewController, 17: Hello world

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Ivan Lesko
  • 1,274
  • 13
  • 26
  • Use a [logging library](https://github.com/CocoaLumberjack/CocoaLumberjack). – nhgrif Apr 14 '16 at 21:52
  • 1
    Take a look at this thread http://stackoverflow.com/questions/24495039/print-class-name-of-current-file-in-swift – Evgeny Karkan Apr 14 '16 at 21:53
  • I was hoping to override the functionality of print() without using a third party lib or using __FILE__ macro in every single print() statement. I understand it may not be possible though. – Ivan Lesko Apr 14 '16 at 22:58

0 Answers0