// logging an informational message
logger.info("Hello World!")
// ouch, something went wrong
logger.error("Houston, we have a problem: \(problem)")
Log Levels 💜💚💙💛❤️
It’s a good habit to distinguish logs by levels. However, SwiftLog defines 7 levels while SwiftyBeaver has only 5. So an 1-to-1 mapping between SwiftLog and SwiftyBeaver is not possible. Following is a table for the mapping:
LoggingSwiftyBeaver
A logging backend for SwiftLog that sends log messages to SwiftyBeaver.
Installation 📦
Add the LoggingSwiftyBeaver package as a dependency to your
Package.swiftfile.Add LoggingSwiftyBeaver to your target’s dependencies.
Usage 📝
1. Let’s import the logging API package:
2. Create a
logger, the label works similarly to aDispatchQueuelabel:Alternatively, you can use
SwiftyBeaveronly inDEBUGbuild and don’t print anything inRELEASEbuild:Futher, you can custom format and set console output to short time, log level & message:
3. We’re now ready to use it:
Log Levels 💜💚💙💛❤️
It’s a good habit to distinguish logs by levels. However,
SwiftLogdefines 7 levels whileSwiftyBeaverhas only 5. So an 1-to-1 mapping betweenSwiftLogandSwiftyBeaveris not possible. Following is a table for the mapping:traceverbosedebugdebuginfoinfonoticewarningwarningwarningerrorerrorcriticalerrorOrigin 🗄
This program was developed by @shivahuang as part of Taiwan Social Distancing.