Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.
/ hades-logger Public archive

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.

License

Notifications You must be signed in to change notification settings

iHugo-Tang/hades-logger

Repository files navigation

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]()
filesToShare.append(url)
let activityViewController = UIActivityViewController(
    activityItems: filesToShare,
    applicationActivities: nil
)

share logs at iOS device

Class Diagram

class diagram

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Languages