Skip to content

Commit

Permalink
fixing logging for BitnessServer
Browse files Browse the repository at this point in the history
  • Loading branch information
leogdion committed Oct 21, 2024
1 parent d2ed8f9 commit 0609809
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 36 deletions.
8 changes: 3 additions & 5 deletions Sources/FelinePine/Feline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ import Foundation
#if swift(<6.0)
#if canImport(os)
import os
#elseif canImport(Logging)
import Logging

#endif
#else
#if canImport(os)
public import os
#elseif canImport(Logging)
public import Logging

#endif
#endif

Expand All @@ -54,7 +52,7 @@ public protocol Feline {
}
}

#if canImport(os) || canImport(Logging)
#if canImport(os)
extension Feline where Self: Pine {
/// Use the ``loggingCategory`` to define the shared logger for type.
public static var logger: Logger {
Expand Down
2 changes: 1 addition & 1 deletion Sources/FelinePine/Loggable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import Foundation

#if canImport(os) || canImport(Logging)
#if canImport(os)
public typealias FelinePineProtocol = Feline & Pine
#else
public typealias FelinePineProtocol = Feline
Expand Down
8 changes: 3 additions & 5 deletions Sources/FelinePine/Logger+LoggerCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@
#if swift(<6.0)
#if canImport(os)
import os
#elseif canImport(Logging)
import Logging

#endif
#else
#if canImport(os)
public import os
#elseif canImport(Logging)
public import Logging

#endif
#endif

#if canImport(os) || canImport(Logging)
#if canImport(os)

Check notice on line 42 in Sources/FelinePine/Logger+LoggerCategory.swift

View check run for this annotation

codefactor.io / CodeFactor

Sources/FelinePine/Logger+LoggerCategory.swift#L42

Lines should not have trailing whitespace. (trailing_whitespace)
extension Logger {
internal init<Category: RawRepresentable>(
subsystem: String,
Expand Down
9 changes: 2 additions & 7 deletions Sources/FelinePine/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,17 @@
#if swift(<6.0)
#if canImport(os)
import os
#elseif canImport(Logging)
import Logging

#endif
#else
#if canImport(os)
public import os
#elseif canImport(Logging)
public import Logging

#endif
#endif

#if canImport(os)
/// os.Logger
public typealias Logger = os.Logger
#elseif canImport(Logging)
/// swift-log Logging.Logger
public typealias Logger = Logging.Logger
#endif
// swiftlint:enable file_types_order
10 changes: 4 additions & 6 deletions Sources/FelinePine/LoggingSystem+LoggingSystemRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ import Foundation
#if swift(<6.0)
#if canImport(os)
import os
#elseif canImport(Logging)
import Logging

#endif
#else
#if canImport(os)
public import os
#elseif canImport(Logging)
public import Logging

#endif
#endif

Expand All @@ -54,7 +52,7 @@ private class LoggingSystemRepository: @unchecked Sendable {
self.items = items
}

#if canImport(os) || canImport(Logging)
#if canImport(os)
fileprivate func loggingSystem<LoggingSystemType: LoggingSystem>(
for system: LoggingSystemType.Type,
using value: @autoclosure () -> [LoggingSystemType.Category: Logger]
Expand Down Expand Up @@ -94,7 +92,7 @@ extension LoggingSystem {
}
}

#if canImport(os) || canImport(Logging)
#if canImport(os)
extension LoggingSystem where Category: CaseIterable {
private static var loggers: [Category: Logger] {
LoggingSystemRepository.shared.loggingSystem(
Expand Down
8 changes: 3 additions & 5 deletions Sources/FelinePine/LoggingSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ import Foundation
#if swift(<6.0)
#if canImport(os)
import os
#elseif canImport(Logging)
import Logging

#endif
#else
#if canImport(os)
public import os
#elseif canImport(Logging)
public import Logging

#endif
#endif

Expand All @@ -54,7 +52,7 @@ public protocol LoggingSystem: Sendable {
/// Subsystem to use for each ``Logger``.
/// By default, this is `Bundle.main.bundleIdentifier`.
static var subsystem: String { get }
#if canImport(os) || canImport(Logging)
#if canImport(os)
/// Fetches the correct logger based on the category.
static func logger(forCategory category: Category) -> Logger
#endif
Expand Down
8 changes: 3 additions & 5 deletions Sources/FelinePine/Pine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@ import Foundation
#if swift(<6.0)
#if canImport(os)
import os
#elseif canImport(Logging)
import Logging

#endif
#else
#if canImport(os)
public import os
#elseif canImport(Logging)
public import Logging

#endif
#endif

#if canImport(os) || canImport(Logging)
#if canImport(os)
/// Defines a shared logger for the type.
///
/// Provides a shared ``Logger`` to use in this type.
Expand Down
2 changes: 1 addition & 1 deletion Tests/FelinePineTests/FelinePineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import XCTest

internal final class FelinePineTests: XCTestCase {
internal func testLogger() throws {
#if canImport(os) || canImport(Logging)
#if canImport(os)
_ = MockType.logger
XCTAssert(true)
#else
Expand Down
2 changes: 1 addition & 1 deletion Tests/FelinePineTests/LoggingSystemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal final class LoggingSystemTests: XCTestCase {
}

internal func testLogger() throws {
#if canImport(os) || canImport(Logging)
#if canImport(os)
for category in MockSystem.Category.allCases {
_ = MockSystem.logger(forCategory: category)
}
Expand Down

0 comments on commit 0609809

Please sign in to comment.