// 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.swift
file.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 aDispatchQueue
label:Alternatively, you can use
SwiftyBeaver
only inDEBUG
build and don’t print anything inRELEASE
build: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,
SwiftLog
defines 7 levels whileSwiftyBeaver
has only 5. So an 1-to-1 mapping betweenSwiftLog
andSwiftyBeaver
is not possible. Following is a table for the mapping:trace
verbose
debug
debug
info
info
notice
warning
warning
warning
error
error
critical
error
Origin 🗄
This program was developed by @shivahuang as part of Taiwan Social Distancing.