Skip to content

Clickable links in your Xcode console, so you never wonder which class logged the message.

License

Notifications You must be signed in to change notification settings

wangshengjia/KZLinkedConsole

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KZLinkedConsole

Ever wondered which part of your application logged the message you just saw in console?

Wonder no more, instead just click on it to jump to the culprit. Simple as that.

Installation

Download the source, build the Xcode project and restart Xcode. The plugin will automatically be installed in ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins. To uninstall, just remove the plugin from there (and restart Xcode).

Alcatraz

This plugin can be installed using Alcatraz. Search for KZLinkedConsole in Alcatraz.

Details

If a console logs a fileName.extension:123 that name turns into a clickable hyperlink that will open the specific file and highlight the line.

That way you can either use your own logging mechanism and just add this simple prefix, e.g.

func logMessage(message: String, filename: String = __FILE__, line: Int = __LINE__, function: String = __FUNCTION__) {
    print("\(filename.lastPathComponent):\(line) \(function):\r\(message)")
}

Integration with popular loggers

QorumLogs.KZLinkedConsoleSupportEnabled = true
  • CocoaLumberjack supported, with a log formatter printing fileName.extension:123, here's my log formatter for it:

Swift version (Objective-C version is part of KZBootstrap):

import Foundation
import CocoaLumberjack.DDDispatchQueueLogFormatter

class KZFormatter: DDDispatchQueueLogFormatter {

  lazy var formatter: NSDateFormatter = {
      let dateFormatter = NSDateFormatter()
      dateFormatter.formatterBehavior = .Behavior10_4
      dateFormatter.dateFormat = "HH:mm:ss.SSS"
      return dateFormatter
  }()

  override func formatLogMessage(logMessage: DDLogMessage!) -> String {
      let dateAndTime = formatter.stringFromDate(logMessage.timestamp)

      var logLevel: String
      let logFlag = logMessage.flag
      if logFlag.contains(.Error) {
          logLevel = "ERR"
      } else if logFlag.contains(.Warning){
          logLevel = "WRN"
      } else if logFlag.contains(.Info) {
          logLevel = "INF"
      } else if logFlag.contains(.Debug) {
          logLevel = "DBG"
      } else if logFlag.contains(.Verbose) {
          logLevel = "VRB"
      } else {
          logLevel = "???"
      }

      let formattedLog = "\(dateAndTime) |\(logLevel)| \((logMessage.file as NSString).lastPathComponent):\(logMessage.line): ( \(logMessage.function) ): \(logMessage.message)"
      return formattedLog;
  }
}

More info

Read more about creation of this plugin on my blog

Follow me on twitter for more useful iOS stuff

About

Clickable links in your Xcode console, so you never wonder which class logged the message.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Swift 60.2%
  • Objective-C 39.8%