Skip to content

Wrapper around Apple's Swift logging APIs (OSLog/Unified Logging/Logger) πŸ“’

License

Notifications You must be signed in to change notification settings

backslash-f/applogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

swift-version swift-package-manager platform CI license

AppLogger

Wrapper around Apple's new Swift logging APIs, particularly Logger.

Provides a basic public / private logging functionality at a given level (e.g. debug (default)).

For more information, please refer to this WWDC20 video: Explore logging in Swift

Supported platforms

  • iOS 14+
  • macOS 11+ (BigSur+)
  • Mac Catalyst 14.0+
  • tvOS 14+
  • watchOS 7+
  • Xcode 12.0+

Usage

import AppLogger

// Create an instance of the "AppLogger with default options.
let logger = AppLogger()

// Log public information.
logger.log("iPhone screen size: \(screenSize)")

// Log private information.
logger.log("Username: \(username); Password: \(password)", isPrivate: true)

Defaults

public struct Defaults {
    public static let subsystem = Bundle.main.bundleIdentifier ?? "AppLogger"
    public static let category = "default"
    public static let isPrivate = false
}

Output

Xcode console

Xcode Sample

macOS Console app

⚠️ Make sure you have enabled Action / Include Info/Debug Messages in the Console app in order to see debug messages from your app.

Console App

macOS Console app: a note on .private

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.

Console App Private Debugger

Integration

Xcode

Use Xcode's built-in support for SPM.

Package.swift

In your Package.swift, add AppLogger as a dependency:

dependencies: [
  .package(url: "https://github.com/backslash-f/applogger", from: "1.0.0")
],

Associate the dependency with your target:

targets: [
  .target(name: "App", dependencies: ["AppLogger"])
]

Run: swift build

About

Wrapper around Apple's Swift logging APIs (OSLog/Unified Logging/Logger) πŸ“’

Topics

Resources

License

Stars

Watchers

Forks

Languages