Swiftpack.co - hugo-h-tang/hades-logger as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by hugo-h-tang.
hugo-h-tang/hades-logger v0.1
A logging library for ios, with support for printing logs to console, and saving to file. Provides in-app log viewing and log sharing functions.
⭐️ 0
🕓 1 week ago
iOS macOS tvOS
.package(url: "https://github.com/hugo-h-tang/hades-logger.git", from: "v0.1")

hades-logger

A logging library for ios, with support for printing logs to console, and saving to file summaries. Provides in-app log viewing and log sharing functions.

Features

  • Easier to filter log in both cosole at bottom of Xcode and Console.app
  • Easier to shre logs for writing logs into files

How to use?

Initialize the log module.

  let label = "xyz.123.qqq"
  let handler = HadesLogger.hadesHandler(label: label)
  log = Logger(label: label, handler)
  log.logLevel = .debug
  LoggingSystem.bootstrapInternal() { _ in handler }

You can print your logs with these methods (log.debug(), log.info()...). It's useful to print logs with category of metadata when you want to debug code via logs. You can filter logs with category to focus logs you want.

filter xcode

filter console

log.debug("hugo", metadata: ["category": "hugo"])
log.debug("mask", metadata: ["category": "mask"])
log.debug("default")

Share logs

You can send the zip file to others later if the zip is successful.

let url = try fileLogHandler.zipLogs()

zip logs

For iOS side, you can share logs through UIActivityViewController, e.g.

guard let url = try? hadesLogger.zipLogs() else {
    return
}
var filesToShare = [Any]src="https://raw.github.com/hugo-h-tang/hades-logger/main/s://raw.github.com/hugo-h-tang/hades-logger/main/)
filesToShare.append(url)
let activityViewController = UIActivityViewController(
    activityItems: filesToShare,
    applicationActivities: nil
)
share logs at iOS device

Class Diagram

class diagram

GitHub

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

Release Notes

First version
1 week ago

What's Changed

  • print logs in Xcode and console.app
  • output logs into files

New Contributors

Full Changelog: https://github.com/hugo-h-tang/hades-logger/commits/v0.1

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