diff --git a/Package.swift b/Package.swift index ee53167..3b587d5 100644 --- a/Package.swift +++ b/Package.swift @@ -2,29 +2,37 @@ import PackageDescription +var products: [Product] = [ + .library( + name: "Logger", + targets: ["Logger"]), + .library( + name: "LoggerUI", + targets: ["LoggerUI"]), + .library( + name: "LoggerKit", + targets: ["LoggerKit"]), + .library( + name: "LoggerTestSupport", + targets: ["LoggerTestSupport"]) +] + + +#if os(macOS) +products.append( + .executable( + name: "LoggerExample", + targets: ["LoggerExample"] + ) +) +#endif + let package = Package( name: "Logger", platforms: [ .macOS(.v10_13), .iOS(.v12), .tvOS(.v12), .watchOS(.v5) ], - products: [ - .library( - name: "Logger", - targets: ["Logger"]), - .library( - name: "LoggerUI", - targets: ["LoggerUI"]), - .library( - name: "LoggerKit", - targets: ["LoggerKit"]), - .library( - name: "LoggerTestSupport", - targets: ["LoggerTestSupport"]), - .executable( - name: "LoggerExample", - targets: ["LoggerExample"] - ) - ], + products: products, dependencies: [ ], targets: [ @@ -49,6 +57,5 @@ let package = Package( .testTarget( name: "LoggerKitTests", dependencies: ["LoggerKit", "LoggerTestSupport"]), - ], - swiftLanguageVersions: [.v4_2] + ] ) diff --git a/Sources/Logger/Channel.swift b/Sources/Logger/Channel.swift index 2295421..e4ab432 100644 --- a/Sources/Logger/Channel.swift +++ b/Sources/Logger/Channel.swift @@ -159,13 +159,16 @@ public class Channel { public func debug(_ logged : @autoclosure () -> Any, file: StaticString = #file, line: UInt = #line, column: UInt = #column, function: StaticString = #function) { #if DEBUG - log(logged, file: file, line: line, column: column, function: function) + if (enabled) { + log(logged(), file: file, line: line, column: column, function: function) + } #endif } public func fatal(_ logged : @autoclosure () -> Any, file: StaticString = #file, line: UInt = #line, column: UInt = #column, function: StaticString = #function) -> Never { - log(logged, file: file, line: line, column: column, function: function) - manager.fatalHandler(logged(), self, file, line) + let value = logged() + log(value, file: file, line: line, column: column, function: function) + manager.fatalHandler(value, self, file, line) } }