Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Change log format for errors and warnings to Xcode compatible #105

Closed
tomaz opened this Issue · 8 comments

3 participants

@tomaz
Owner

Sorry took me a little while to get back to this, the format needed is...
[FileName]:[line number]: error: [error description]
or
[FileName]:[line number]: warning: [error description]

So something like:
AppleDoc.h:29: error: divide by cucumber

Would love if this format could be added to the log format options.

(by beelsebob)

@tomaz tomaz was assigned
@beelsebob

Just commenting to get github to tell me when this happens.

@tomaz
Owner

:) I'm planning this shortly, after I finish my current work.

@tomaz tomaz closed this issue from a commit
@tomaz Implemented better Xcode integration for warnings and errors. Closes #…
…105.

By using special log format `--logformat xcode`, appledoc formats warnings and errors related to source files in a way that Xcode is able to catch them and display them in build results. Currently only warnings are using that format (there is no error log message related to source files).

*Implementation details:* Note that implementation required tweaking Cocoa Lumberjack source. Specifically, it required passing in original source code filename and line number to log message. Although logging macros pick up source file and line automatically through `__FILE__` and `__LINE__`, these belong to appledoc sources. But for Xcode warnings making sense, we need to write the file name and line of the context being parsed. To reuse existing macros, I added both values to DDMessage and additional class method to DDLog which needs to be called prior to logging. The method will simply store info to static vars. Then logging method will pick up stored values, write them to message and reset static vars. When emitting log messages, Xcode formatter will check if these values are set and emit specially formatted logs, otherwise it will revert to message only.

*Additional note:* Although I searched for all occurrences of `GBLogWarn` and `GBLogError` in the project and updated those that seemed relevant, some may have been left out - let me know about exact messages and I will check it. Also note that parsing code currently doesn't emit warnings, if something goes wrong, exceptions are raised, which doesn't log the file and line. Didn't take much time to go into this as these usually indicate parsing code needs to be refined.
a63d7b5
@tomaz tomaz closed this in a63d7b5
@jweinberg

There is still a small issue with this. At least in XC4, the error/warning needs to include the full path of the file, not just the name. If it doesn't the jump-to-file functionality doesn't work.

@tomaz tomaz reopened this
@tomaz
Owner

Ok, will update, reopening.

@jweinberg

Great. I'm really liking this project, its nice to get decent looking documentation instead of doxygen. Keep up the good work :)

@tomaz tomaz closed this issue from a commit
@tomaz Fixed Xcode integration warnings and errors full paths handling. Fixes
…#105.

To allow Xcode properly open the file after selecting the warning in build list, it requires full path to it in the output, so I had to add full path to GBSourceInfo and use that when generating Xcode compatible log.

Note that I had appledoc crashed inside `[GBLog logFormatterForLogFormat]` when using standard log formats. The problem was with sending the given format instance `lowercaseString` however in case numerical value was used, the actual instance was `NSNumber`. To compensate, additional check was added to make sure the instance is indeed a `NSString`. Strange no one reported this as I didn't touch this code since last pushing to GitHub (or everyone was hardly waiting for Xcode compatibility and are now using that mode :).

Also added `xcode` log format option to help output and increased build number to 701.
f26d132
@tomaz tomaz closed this in f26d132
@jweinberg
  • Registering short de/Users/jweinberg/Development/Labs-iOS/Keystone/trunk/Keystone/Foundation/RAInvocationProxy.h:30: warning: RAInvocationProxy.h@30: Description for parameter 'thread' missing for -[NSObject(RAInvocationProxy) ra_proxyForThread:waitsUntilDone:]!

There are some issues with the output still as seen above, some log entries are being slammed up against the previous line which isn't completing for some reason. But 99% of the entries are coming out correctly.

@tomaz
Owner

Is this something new or did you experience this before?

@jweinberg

I never noticed it before, but it may have been happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.