8000 GitHub - finnvoor/StaticLogger: A Swift macro for automatically adding Loggers to types
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

finnvoor/StaticLogger

Repository files navigation

StaticLogger

A simple Swift macro that adds a static logger method to a class, struct, actor, 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")

About

A Swift macro for automatically adding Loggers to types

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages

0