• Stars
    star
    931
  • Rank 49,076 (Top 1.0 %)
  • Language
    Swift
  • License
    MIT License
  • Created almost 9 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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

More Repositories

1

Sourcery

Meta-programming for Swift, stop writing boilerplate code.
Swift
7,677
star
2

LifetimeTracker

Find retain cycles / memory leaks sooner.
Swift
3,144
star
3

Playgrounds

Better playgrounds that work both for Objective-C and Swift
Objective-C
2,633
star
4

Inject

Hot Reloading for Swift applications!
Swift
2,127
star
5

Swift-Macros

A curated list of awesome Swift Macros
Swift
2,120
star
6

Bootstrap

iOS project bootstrap aimed at high quality coding.
Objective-C
2,047
star
7

LineDrawing

Beatiful and fast smooth line drawing algorithm for iOS - as seen in Foldify.
Objective-C
1,288
star
8

Difference

Simple way to identify what is different between 2 instances of any type. Must have for TDD.
Swift
1,217
star
9

PropertyMapper

Property mapping for Objective-C iOS apps.
Objective-C
1,124
star
10

KZFileWatchers

A micro-framework for observing file changes, both local and remote. Helpful in building developer tools.
Swift
1,078
star
11

Traits

Modify your native iOS app in real time.
Swift
904
star
12

IconOverlaying

Build informations on top of your app icon.
Shell
650
star
13

crafter

Crafter - Xcode project configuration CLI made easy.
Ruby
547
star
14

Strongify

Strongify is a 1-file µframework providing a nicer API for avoiding weak-strong dance.
Swift
444
star
15

KZNodes

Have you ever wonder how you could make Origami like editor in 1h ?
Objective-C
336
star
16

SFObservers

NSNotificationCenter and KVO auto removal of observers.
Objective-C
307
star
17

AutomaticSettings

Data driven settings UI generation.
Swift
302
star
18

CCNode-SFGestureRecognizers

Adding UIGestureRecognizers to cocos2d, painless.
Objective-C
202
star
19

DetailsMatter

Objective-C
199
star
20

Pinch-to-reveal

Pinch to reveal animation transition built with Layer masking, as seen in boeing app for iPad.
Objective-C
192
star
21

ViewModelOwners

Protocols that help make your MVVM setup more consistent
Swift
143
star
22

KZAsserts

Asserts on roids, test all your assumptions with ease.
Objective-C
100
star
23

OhSnap

Reproduce bugs your user saw by capturing and replaying data snapshots with ease.
Swift
89
star
24

Versionable

Migration for `Codable` objects.
Swift
83
star
25

SFContainerViewController

UIViewControllers containment predating Apple implementation. Works in both 4.x and 5.x iOS, no memory or hierarchy issues.
Objective-C
82
star
26

Swift-Observable

Native KVO like behaviour build in Swift.
Swift
64
star
27

BehavioursExample

Objective-C
58
star
28

SourceryWorkshops

Swift
45
star
29

Learn-iOS-GameDev-Level-0

Teeter clone accompanying tutorial at http://merowing.info/2013/04/learn-ios-game-dev-level-0/
Objective-C
24
star
30

XibReferencing

Simple category and sample showing how you can reference one Xib view from another
Objective-C
20
star
31

KZImageSplitView

Objective-C
17
star
32

NSObject-SFExecuteOnDealloc

A simple category on NSObject that allows you to execute block when object is deallocated
Objective-C
17
star
33

jenkins_jobs_to_statusboard

Ruby script that generates html table for embedding in StatusBoard by Panic http://panic.com/statusboard/
Ruby
15
star
34

SourceryPro-Feedback

Repository for discussing https://merowing.info/sourcery-pro/
12
star
35

krzysztofzablocki

2
star
36

krzysztofzablocki.github.io

Blog
HTML
2
star
37

starter-hugo-academic

Jupyter Notebook
1
star