Latest 3.1.0
Homepage https://github.com/APUtils/LogsManager
License MIT
Platforms ios 8.0
Dependencies CocoaLumberjack/Swift
Frameworks Foundation, UIKit
Authors

Carthage compatible
Version
License
Platform
CI Status

Logs manager on top of CocoaLumberjack. Allows to easily configure log components depending on your app infrastucture. Have several convenience loggers: ConsoleLogger, AlertLogger, NotificationLogger.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

Carthage

Please check official guide

Cartfile:

github "APUtils/LogsManager" ~> 4.0

CocoaPods

LogsManager is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'LogsManager', '~> 4.0'

Usage

You have to add logs component first if you want your logs to be separated by components:

let vcComponent = LogComponent(name: "ViewController", logName: "VC") { filePath, _ in
    let fileName = String.getFileName(filePath: filePath)
    return fileName == "ViewController"
}
LoggersManager.shared.registerLogComponent(vcComponent)

let didAppearComponent = LogComponent(name: "Did Appear", logName: "viewDidAppear") { _, function in
    return function.hasPrefix("viewDidAppear")
}
LoggersManager.shared.registerLogComponent(didAppearComponent)

Then you need to add loggers and specify their components and log levels:

// Log all ViewController debug messages
let logger = ConsoleLogger(logComponents: [vcComponent], logLevel: .debug, newLinesSeparation: false)
LoggersManager.shared.addTextLogger(logger)

// Present alert for any error log
let allAlertLogger = AlertLogger(logComponents: nil, logLevel: .error)
LoggersManager.shared.addTextLogger(allAlertLogger)

You can use convenience global function to leave logs:

logInfo(message: "Staring network request to: (request.url)")
logDebug(message: "Received data")
logVerbose(message: "Data payload: (data)")
logError(reason: "Got error response", error: error, data: ["request": request])

See example and test projects for more details.

Contributions

Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub.

Author

Anton Plebanovich, [email protected]

License

LogsManager is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "LogsManager",
    "version": "3.1.0",
    "summary": "Logs manager on top of CocoaLumberjack.",
    "description": "Logs manager on top of CocoaLumberjack. Allows to easily configure log components depending on your app infrastucture. Have several convenience loggers: ConsoleLogger, AlertLogger, NotificationLogger.",
    "homepage": "https://github.com/APUtils/LogsManager",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Anton Plebanovich": "[email protected]"
    },
    "source": {
        "git": "https://github.com/APUtils/LogsManager.git",
        "tag": "3.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "swift_versions": [
        "5.0",
        "5.0"
    ],
    "source_files": "LogsManager/Classes/**/*",
    "frameworks": [
        "Foundation",
        "UIKit"
    ],
    "dependencies": {
        "CocoaLumberjack/Swift": []
    },
    "swift_version": "5.0"
}

Pin It on Pinterest

Share This