LoggerHelper

1.0.0

A simple Swift logging library for macOS apps. Log messages at different levels (info, warning, debug, error), control logging globally, and customize subsystem and category for each message.
Krusty84/LoggerHelper

What's New

1.0.0

2025-05-04T15:59:27Z

LoggerHelper

A simple Swift logging library for macOS apps. Log messages at different levels (info, warning, debug, error), control logging globally, and customize subsystem and category for each message.

Features

  • Four log levels: info, warning, debug, error
  • Enable or disable all logging with one flag
  • Default subsystem is your app’s bundle identifier (overrideable)
  • Default category is "General" (overrideable)
  • Each log entry includes file name, line number, and function name

Requirements

  • macOS 10.15 or later
  • Swift 5.5 or later

Installation

Swift Package Manager

  1. In Xcode, choose File ▸ Add Packages…
  2. Enter the URL of this repository:
    https://github.com/YourUserName/LoggerHelper.git
    
  3. Select the version (for example, Up to Next Major 1.0.0) and add it to your app target.

Usage

  1. Enable logging early in your app (e.g. in AppDelegate):

    import LoggerHelper
    
    @main
    class AppDelegate: NSObject, NSApplicationDelegate {
      func applicationDidFinishLaunching(_ notification: Notification) {
        // Turn logging on or off as needed
        #if DEBUG
        LoggerHelper.loggingEnabled = true
        #else
        LoggerHelper.loggingEnabled = false
        #endif
    
        LoggerHelper.info("App did finish launching")
      }
    }
  2. Log with defaults:

    LoggerHelper.info("Hello, world!")
    • Uses Bundle.main.bundleIdentifier as subsystem
    • Uses "General" as category
  3. Log with custom subsystem or category:

    LoggerHelper.debug(
      "User tapped button",
      subsystem: "com.mycompany.mytool",
      category: "UI"
    )
  4. Other levels:

    LoggerHelper.warning("Low disk space")
    LoggerHelper.error("Failed to load data")

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu May 15 2025 21:59:05 GMT-0900 (Hawaii-Aleutian Daylight Time)