StaticLogger

1.0.3

A Swift macro for automatically adding Loggers to types
finnvoor/StaticLogger

What's New

v1.0.3

2023-10-14T16:01:56Z

Added support for attaching @StaticLogger to an actor.

StaticLogger

A simple Swift macro that adds a static logger method to a class, struct, or enum, with a default subsystem and category based on the bundle identifier and type name.

Usage

import OSLog
import StaticLogger

@StaticLogger
struct MyStruct {
    let x: Int

    func test() {
        Self.logger.debug("X is \(x)")
    }
}

Expands to:

struct MyStruct {
    let x: Int

    func test() {
        Self.logger.debug("X is \(x)")
    }

    static let logger = Logger(subsystem: Bundle.main.bundleIdentifier ?? "", category: "MyStruct")
}

You can also override the logger's subsystem or category by passing them to @StaticLogger:

@StaticLogger(subsystem: "MySubsystem", category: "MyCategory")

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

Last updated: Sun May 05 2024 00:13:03 GMT-0900 (Hawaii-Aleutian Daylight Time)