krzysztofzablocki / LinkedConsole

Clickable links in your Xcode console, so you never wonder which class logged the message.
http://merowing.info
MIT License
931 stars 63 forks source link

Not work with CocoaLumberjack #4

Closed CyrusNG closed 8 years ago

CyrusNG commented 8 years ago

I rewrite one formatter to make the specific format the plugin need with CocoaLumberjack , but not work. my xCode is 6.4 and 7.1.1 with xCodeColor plugin. Log Detail: 2015-12-09 16:28:28:963 [WARN] | AppDelegate.m:90: [application:didFinishLaunchingWithOptions:]: Testing!!!!!!!!!!!!

krzysztofzablocki commented 8 years ago

you need to be a little bit more specific, does it highlight the text?

CyrusNG commented 8 years ago

I mean AppDelegate.m:90 is NOT a link. It can NOT clickable.

krzysztofzablocki commented 8 years ago

are you sure the plugin is loaded? did you have to click allow plugin?

GuyKahlon commented 8 years ago

Hi, it doesn't work for me also. I installed the Plugin via Alcatraz. I use with Xcode Version 7.1.1 (7B1005) and CocoaLumberjack. I can see the Log messages in the console but they aren't clickable.

Can you assist pleas?

My Code:

import Foundation import CocoaLumberjack import CocoaLumberjack.DDDispatchQueueLogFormatter

class MyLogger {

class func initializLogger(logLevel: DDLogLevel = .Debug){

  #if DEBUG
      defaultDebugLevel = logLevel
  #else
      defaultDebugLevel = .Off
  #endif

  DDLog.addLogger(DDASLLogger.sharedInstance()) //Logger for the Apple system log facility
  DDLog.addLogger(DDTTYLogger.sharedInstance()) //Logger for Terminal output/Xcode console
  DDTTYLogger.sharedInstance().colorsEnabled = true
  DDTTYLogger.sharedInstance().setForegroundColor(UIColor.greenColor(), backgroundColor: nil, forFlag: .Info)
  DDTTYLogger.sharedInstance().setForegroundColor(UIColor.magentaColor(), backgroundColor: nil, forFlag: .Debug)
  DDTTYLogger.sharedInstance().logFormatter = KZFormatter()
}

}

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;

} }

GuyKahlon commented 8 years ago

How can I check if the plugin is allow? I loaded the bundle after reset the Xcode!

CyrusNG commented 8 years ago

I also wanna know how I can check the plugin is allow. And, I also installed the Plugin via Alcatraz. please help.

krzysztofzablocki commented 8 years ago

When you remove the plugin and then reinstall it, xcode should ask if you allow to load the package. Can you try reinstalling?

CyrusNG commented 8 years ago

Tried and click "load bundle", but still not work.

GuyKahlon commented 8 years ago

Ok, After reinstall works great for a device, but doesn't work for a simulator.

krzysztofzablocki commented 8 years ago

@GuyKahlon can you run it from xcode and see where is it not going through on simulator for you ? something in KZLinkedConsole.swift or NSTextStorage+Extensions must be failing if you are not getting highlighted links

GuyKahlon commented 8 years ago

Checking...

CyrusNG commented 8 years ago

If I don't use lastPathComponent, how can I get file name?

krzysztofzablocki commented 8 years ago

I've updated the plugin, try reinstalling and see if it works now?

CyrusNG commented 8 years ago

It's ok now. This plugin is very cool, it can help me debug easier. Thanks.

krzysztofzablocki commented 8 years ago

awesome ;)

GuyKahlon commented 8 years ago

@krzysztofzablocki Thanks for this awesome plugin.

krzysztofzablocki commented 8 years ago

happy I was able to solve the issue for you guys :)