Swiftpack.co - Package - sushichop/Puppy

Puppy 🐶

release CI codecov license

Swift5.0+ CocoaPods Carthage SwiftPM platforms platforms

Puppy is a flexible logging library written in Swift.

Features

  • Written in Swift.
  • Supports console, file, syslog, and oslog as loggers.
  • Supports automatic log roration about file logger.
  • Supports both Darwin and Linux.
  • Supports apple/swift-log.

Examples

Logging to console and file using file log rotation feature.

You can basically use CocoaPods, Carthage, and Swift Package Manager for integration.

let console = ConsoleLogger("com.example.yourapp.consolelogger")
let fileURL = URL(fileURLWithPath: "./rotation/foo.log").absoluteURL
let fileRotation = try FileRotationLogger("com.example.yourapp.filerotationlogger",
                                          fileURL: fileURL)

fileRotation.maxFileSize = 10 * 1024 * 1024
fileRotation.maxArchivedFilesCount = 5

let log = Puppy()
log.add(console)
log.add(fileRotation)

log.info("INFO message")
log.warning("WARNING message")

Logging to console and syslog using apple/swift-log.

You can use CocoaPods and Swift Package Manager for integration. (apple/swift-log does not support Carthage integration.)

let console = SystemLogger("com.example.yourapp.consolelogger")
let syslog = SystemLogger("com.example.yourapp.systemlogger")

let puppy = Puppy.default
puppy.add(console)
puppy.add(syslog)

LoggingSystem.bootstrap {
    var handler = PuppyLogHandler(label: $0, puppy: puppy)
    handler.logLevel = .trace
    return handler
}

log.trace("TRACE message")
log.debug("DEBUG message")

License

Puppy is available under the MIT license. See the LICENSE file for details.

Github

link
Stars: 0

Dependencies

Used By

Total: 0

Releases

- 2020-10-18 11:23:49

  • First release