Swiftpack.co - APUtils/LogsManager as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by APUtils.
APUtils/LogsManager 10.0.1
Logs managers on top of CocoaLumberjack with ability to easily split logs for components.
⭐️ 4
🕓 31 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/APUtils/LogsManager.git", from: "10.0.1")

LogsManager

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 DEPRECATED

Please check official guide

Cartfile:

github "APUtils/LogsManager" "9.1.19"

Install command: carthage bootstrap

Add LogsManager framework to the main app and app extensions if any. Add LogsManagerExtensionUnsafe framework for the main app only (excluding app extensions if any).

Carthage with XCFrameworks DEPRECATED

Please check official guide

Cartfile:

github "APUtils/LogsManager" "9.1.20"

Install command: carthage bootstrap --use-xcframeworks

Add LogsManager framework to the main app and app extensions if any. Add LogsManagerExtensionUnsafe framework for the main app only (excluding app extensions if any).

CocoaPods

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

For the main app target:

pod 'LogsManager', '~> 9.1'

For the app extension target:

pod 'LogsManager/Core', '~> 9.1'

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("Staring network request to: \(request.url)")
logDebug("Received data")
logVerbose("Data payload: \(data)")
logError("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, anton.plebanovich@gmail.com

License

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

GitHub

link
Stars: 4
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics