But then I started playing around with Swift. But the same library is not done in the same quality for Swift. Yes - I get coloured logs, but one of XcodeColors features I loved was that it also logged out pretty timestamp and function from which it was called. I could simply write
DLog();
And it would output in console something like:
And it was great! but for swift it produces:
So, I was not in search of something similar to Obj-C alternative.
Of course if you simply replace print with NSLog, then it at once becomes more usable:
But still, no function origin.
So I searched the web, StackOverflow until I could gather together a simple class, which gives me just those capabilities: https://github.com/GuntisTreulands/ColorLogger-Swift
So now I can get pretty timestamp, original function name, and coloured output. And usage is as similar to Obj-C alternative as possible!
Log()
Log(window)
LogRed("Blue test")
LogBlue("Red fountain")
LogOrange("Yellow submarine")
LogBlue("text count \(5) and object \(window)")
LogOrange(("text", "bext", 5, temp))
No comments:
Post a Comment