Skip to content
프로젝트

소개

Xcode 콘솔의 링크를 클릭할 수 있게 해 주므로 어떤 클래스가 메시지를 기록했는지 더 이상 추측할 필요가 없습니다.

기타 프로젝트

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

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).

Swift 3

Xcode8 / Swift3 is on swift3 branch.

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 as NSString).lastPathComponent):\(line) \(function):\r\(message)")
}

Integration with popular loggers

  • XCGLogger is supported out of the box.
  • SwiftyBeaver is supported out of the box.
  • Log is supported out of the box.
  • QorumLogs after enable KZLinkedConsoleSupportEnabled flag.
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;
  }
}

Opening files from outside Xcode

KZLinkedConsole also supports opening files from outside Xcode through distributed notifications. The xed command line tool is supposed to provide this feature but is unfortunately terribly broken.

In order to open the file Example.m and select the line 123, simply do the following:

[[NSDistributedNotificationCenter defaultCenter]
    postNotificationName:@"pl.pixle.KZLinkedConsole.OpenFile"
                  object:@"Example.m"
                userInfo:@{ @"Line": @123 }
      deliverImmediately:YES];

You can also specify an absolute path if you know it. The userInfo dictionary with line number information is optional.

If the file was successfully opened, KZLinkedConsole will post back a pl.pixle.KZLinkedConsole.DidOpenFile distributed notification.

More info

Read more about creation of this plugin on my blog

Follow me on twitter for more useful iOS stuff

관련 프로젝트 살펴보기

불러오는 중…