Latest 0.3.2
Homepage https://github.com/markuswinkler/XCGLoggerNSLoggerConnector
License MIT
Platforms ios 9.0, requires ARC
Dependencies XCGLogger, NSLogger
Authors

Version
License
Platform

By: Markus Winkler

tl;dr

Adds NSLogger support (with images) to XCGLogger.

Compatibility

XCGLoggerNSLoggerConnector works for iOS projects. It is a Swift library intended for use in Swift projects.

How to Use

In your AppDelegate, declare a global constant to the default XCGLogger instance.

import XCGLogger
import NSLogger
import XCGLoggerNSLoggerConnector

let log: XCGLogger = {
    let log = XCGLogger.defaultInstance()
    log.setup(.Debug, showThreadName: false, showLogLevel: true, showFileNames: true, showLineNumbers: true, writeToFile: nil, fileLogLevel: .Debug)

    // NSLogger support
    // only log to the external window
    LoggerSetOptions(LoggerGetDefaultLogger(), UInt32( kLoggerOption_BufferLogsUntilConnection | kLoggerOption_BrowseBonjour | kLoggerOption_BrowseOnlyLocalDomain ))
    LoggerStart(LoggerGetDefaultLogger())
    log.add(destination: XCGNSLoggerLogDestination(owner: log, identifier: "nslogger.identifier"))

    return log
}()

You can also specify to display inline the file & function name (personal preference, makes it slightly easier to read where the call is coming from).

    log.add(destination: XCGNSLoggerLogDestination(owner: log, identifier: "nslogger.identifier", addInlineDebugInfo: true))

Now all levels accept an UIImage as a parameter and will output the content to the NSLogger window as an image.

log.verbose(image)
log.debug(image)
log.info(image)
log.warning(image)
log.error(image)
log.severe(image)

There is a new filter command, "customLabel". You can use that one to add your own label to filter later on in the NSLogger client.
The default value is "image" for image and "string" for string.
Use it to distinguish between different kinds of images or outputs (e.g. database results)

log.customLabel(image, label: "facebook icon")
log.customLabel(String(databaseOutput), label: "Database")

Note: the logLevel for customLabels is Info (3)

References

You can find more info on XCGLogger/NSLogger (documentation and setup) here:
XCGLogger: https://github.com/DaveWoodCom/XCGLogger
NSLogger: https://github.com/fpillet/NSLogger

Change Log

  • Version 0.3.1: (2016/12/08) – removed 2 compiler warnings
  • Version 0.3.0: (2016/12/08) – Xcode 8.1 support. Upgrade to iOS 9.
  • Version 0.2.0: (2016/11/23) – Update for Swift 3
  • Version 0.1.4: (2016/08/23) – added XCGLogger limit <= 3.3 since any version above will break this connector
  • Version 0.1.3: (2016/06/08) – fixes
  • Version 0.1.2: (2016/02/15) – added a switch to display additional debug info inline
  • Version 0.1.1: (2015/11/20) – Initial Release

Latest podspec

{
    "name": "XCGLoggerNSLoggerConnector",
    "version": "0.3.2",
    "summary": "Updated first parameter of XCGLogger extension functions in order to override correctly the updated XCGLogger version",
    "homepage": "https://github.com/markuswinkler/XCGLoggerNSLoggerConnector",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Markus Winkler": "[email protected]"
    },
    "source": {
        "git": "https://github.com/markuswinkler/XCGLoggerNSLoggerConnector.git",
        "tag": "0.3.2"
    },
    "social_media_url": "https://twitter.com/creativegun",
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "source_files": "XCGLoggerNSLoggerConnector/**/*.{swift}",
    "dependencies": {
        "XCGLogger": [
            ">= 4.0"
        ],
        "NSLogger": [
            ">= 1.5"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This