TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Oct 2016 |
Maintained by Cédric Luthi.
Depends on: | |
CocoaLumberjack | >= 2.0 |
NSLogger | >= 1.7 |
XCDLumberjackNSLogger is a CocoaLumberjack logger which sends logs to NSLogger.
XCDLumberjackNSLogger is available through CocoaPods and Carthage.
CocoaPods:
pod "XCDLumberjackNSLogger", "~> 1.1"
Carthage:
github "0xced/XCDLumberjackNSLogger" ~> 1.1
XCDLumberjackNSLogger is fully documented.
The easiest way to use XCDLumberjackNSLogger is to bind a logger to a user defaults key.
[XCDLumberjackNSLogger bindToBonjourServiceNameUserDefaultsKey:@"NSLoggerBonjourServiceName" configurationHandler:nil];
Anytime you change the user defaults key (NSLoggerBonjourServiceName
in this example), the logger reconnects to the desktop viewer with the given service name.
You can change the service name user defaults manually with
[[NSUserDefaults standardUserDefaults] setObject:serviceName forKey:@"NSLoggerBonjourServiceName"];
or with a Settings bundle:
<dict>
<key>AutocapitalizationType</key>
<string>None</string>
<key>AutocorrectionType</key>
<string>No</string>
<key>DefaultValue</key>
<string></string>
<key>IsSecure</key>
<false/>
<key>Key</key>
<string>NSLoggerBonjourServiceName</string>
<key>KeyboardType</key>
<string>Alphabet</string>
<key>Title</key>
<string>NSLogger Service Name</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
This is very handy to get logs even in the App Store with zero overhead. Just open the settings of your app (in the iOS Settings app) and change the service name to automatically activate the logger.
When debugging with Xcode you can set -NSLoggerBonjourServiceName "Your Service Name"
in Arguments Passed On Launch in your scheme to set the NSLoggerBonjourServiceName
user default.
[DDLog addLogger:[XCDLumberjackNSLogger new]];
NSString *bonjourServiceName = [[[NSProcessInfo processInfo] environment] objectForKey:@"NSLOGGER_BONJOUR_SERVICE_NAME"];
[DDLog addLogger:[[XCDLumberjackNSLogger alloc] initWithBonjourServiceName:bonjourServiceName]];
XCDLumberjackNSLogger *logger = [XCDLumberjackNSLogger new];
logger.tags = @{ @80 : @"CocoaHTTPServer", @((NSInteger)0xced70676) : @"XCDYouTubeKit" };
[DDLog addLogger:logger];
XCDLumberjackNSLogger *logger = [XCDLumberjackNSLogger new];
LoggerSetViewerHost(logger.logger, CFSTR("10.0.1.7"), 50000);
[DDLog addLogger:logger];
Cédric Luthi
XCDLumberjackNSLogger is available under the MIT license. See the LICENSE file for more information.