Wrapper around Apple's Swift unified logging APIs, particularly Logger.
Provides public and private logging with an app-facing AppLogLevel abstraction, so clients do not need to import os to choose a log level. The default level is .default, which maps to OSLogType.default and shows up in Console.app without requiring debug filtering.
For more information, please refer to this WWDC20 video: Explore logging in Swift
import AppLogger
let logger = AppLogger(subsystem: "com.example.app", category: "network")
// Log public information.
logger.log("Request started")
// Log private information.
logger.log(level: .info, "Request headers: \(headers)", isPrivate: true)
// Set custom levels.
logger.log(level: .error, "Request failed: \(error.localizedDescription)")public struct Defaults {
public static let subsystem = Bundle.main.bundleIdentifier ?? "AppLogger"
public static let category = "default"
public static let isPrivate = false
public static let level: AppLogLevel = .default
}public enum AppLogLevel {
case debug
case info
case `default`
case error
case fault
}.default, .error, and .fault logs are shown by default in the Console app. If you emit debug logs, enable Action / Include Info/Debug Messages to display them.
Keep in mind that private information will still be visible in the Console app as clear text if the device is attached to the debugger. Apparently this is by design.
Use Xcode's built-in support for SPM.
In your Package.swift, add AppLogger as a dependency:
dependencies: [
.package(
url: "https://github.com/thatfactory/applogger",
from: "1.0.0"
)
]Associate the dependency with your target:
targets: [
.target(
name: "YourTarget",
dependencies: [
.product(
name: "AppLogger",
package: "applogger"
)
]
)
]Run: swift build


