Initial commit
This commit is contained in:
@ -6,3 +6,38 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftyBeaver
|
||||
|
||||
let logger = SwiftyBeaver.self
|
||||
|
||||
func setupLogging() {
|
||||
let console = ConsoleDestination()
|
||||
let file = FileDestination()
|
||||
//file.logFileURL = URL(fileURLWithPath: "/path/to/your/log/file.log")
|
||||
|
||||
// use custom format and set console output to short time, log level & message
|
||||
// console.format = "$DHH:mm:ss$d $L $M"
|
||||
// or use this for JSON output:
|
||||
// console.format = "$J"
|
||||
|
||||
// In Xcode 15, specifying the logging method as .logger to display color, subsystem, and category information in the console.(Relies on the OSLog API)
|
||||
//console.logPrintWay = .logger(subsystem: "Main", category: "UI")
|
||||
|
||||
// If you prefer not to use the OSLog API, you can use print instead.
|
||||
// console.logPrintWay = .print
|
||||
|
||||
|
||||
console.format = "$DHH:mm:ss$d $C$L$c $N.$F:$l - $M"
|
||||
|
||||
// 自定义颜色
|
||||
console.levelColor.verbose = "⚪️ " // White
|
||||
console.levelColor.debug = "🔵 " // Blue
|
||||
console.levelColor.info = "🟢 " // Green
|
||||
console.levelColor.warning = "🟡 " // Yellow
|
||||
console.levelColor.error = "🔴 " // Red
|
||||
|
||||
logger.addDestination(console)
|
||||
logger.addDestination(file)
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user