julian-weinert / LinkedLog

LinkedLog is a Xcode plugin that includes a Xcode PCH header file template that adds the macros `LLog` and `LLogF` and parses their output to link from the console to the corresponding file and line.
MIT License
22 stars 2 forks source link

Parse and Link all log statements #9

Closed yoiang closed 8 years ago

yoiang commented 8 years ago

Hey @julian-weinert , the project is such a neat / thisshouldalreadyexistApple / useful idea!

I apologize if this is out of the scope of the project but I was wondering if it would be difficult to extend the linking to all log statements, say any obvious [File name]:[Line number] match.

Considering how many log libraries are out there that people are tied to, especially libraries that by now are very extensive, it would be awesome if LinkedLog was agnostic to logging method you used, just so long as you matched an obvious pattern.

julian-weinert commented 8 years ago

You are right – this isn't an issue. Please use the chat for discussions next time ;)

LinkedLog chat

Thanks for your feedback, btw

LinkedLog does parse everything that goes into the log. This is also one reason it sometimes crashes Xcode.

This is the regular expression that is used to match the statements: ^[\d]{4}-[\d]{2}-[\d]{2}\s[\d]{2}:[\d]{2}:[\d]{2}.[\d]{3}\s[^\[]*\[\d*:\d*\]\s(.+\/([^\/:]+:\d+)):\s.*

It looks for sequences matching:

Example: 2015-11-04 17:53:48.045 myApp[9054:9026288] /Users/jw/Desktop/myApp/myApp/JFWAppDelegate.m:68: UIDeviceWhiteColorSpace 0.85 1 Prints as 2015-11-04 17:53:48.045 myApp[9054:9026288] JFWAppDelegate.m:68: UIDeviceWhiteColorSpace 0.85 1

Summarised, any log input that follows this format will be parsed by LinkedLog. This should be any log input that uses NSLog under its hood or at least NSLog's logging format (2015-11-04 17:53:48.045 myApp[9054:9026288]) in the beginning of the line followed by an absolute file path-colon-line number-colon-logstring.