Skip to content

Commit

Permalink
Fixing Logging for BitnessServer (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
leogdion authored Oct 22, 2024
1 parent d2ed8f9 commit b89389f
Show file tree
Hide file tree
Showing 18 changed files with 130 additions and 161 deletions.
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
39 changes: 39 additions & 0 deletions .devcontainer/swift-5.8/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "Swift",
"image": "swift:5.8",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "false",
"username": "vscode",
"upgradePackages": "false"
},
"ghcr.io/devcontainers/features/git:1": {
"version": "os-provided",
"ppa": "false"
}
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"lldb.library": "/usr/lib/liblldb.so"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"sswg.swift-lang"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "root"
}
39 changes: 39 additions & 0 deletions .devcontainer/swift-6.0/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "Swift",
"image": "swift:6.0",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "false",
"username": "vscode",
"upgradePackages": "false"
},
"ghcr.io/devcontainers/features/git:1": {
"version": "os-provided",
"ppa": "false"
}
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"lldb.library": "/usr/lib/liblldb.so"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"sswg.swift-lang"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
37 changes: 13 additions & 24 deletions .github/workflows/FelinePine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ jobs:
if: "!contains(github.event.head_commit.message, 'ci skip')"
strategy:
matrix:
runs-on: [ubuntu-20.04, ubuntu-22.04]
swift-version: [5.8.1, 5.9, "5.10", "6.0.1"]
runs-on: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04]
swift-version: [5.8.1, 5.9, "5.10.1", "6.0.1"]
exclude:
- runs-on: ubuntu-24.04
swift-version: 5.9
- runs-on: ubuntu-24.04
swift-version: 5.8.1
steps:
- uses: actions/checkout@v4
- name: Cache swift package modules
Expand Down Expand Up @@ -76,12 +81,6 @@ jobs:
strategy:
matrix:
include:
- runs-on: macos-13
xcode: "/Applications/Xcode_14.3.1.app"
iOSVersion: "16.4"
watchOSVersion: "9.4"
watchName: "Apple Watch Series 5 (40mm)"
iPhoneName: "iPhone 14"
- runs-on: macos-13
xcode: "/Applications/Xcode_15.0.1.app"
iOSVersion: "17.0.1"
Expand All @@ -101,11 +100,11 @@ jobs:
watchName: "Apple Watch Series 9 (45mm)"
iPhoneName: "iPhone 15 Pro"
- runs-on: macos-15
xcode: "/Applications/Xcode_16.1.app"
iOSVersion: "18.0"
watchOSVersion: "11.0"
watchName: "Apple Watch Series 10 (42mm)"
iPhoneName: "iPhone 16"
xcode: "/Applications/Xcode_16.1.app"
iOSVersion: "18.1"
watchOSVersion: "11.1"
watchName: "Apple Watch Series 10 (46mm)"
iPhoneName: "iPhone 16 Pro"
steps:
- uses: actions/checkout@v4
- name: Cache swift package modules
Expand Down Expand Up @@ -145,7 +144,7 @@ jobs:
- name: Build
run: swift build
- name: Run Swift Package tests
run: swift test -v --enable-code-coverage
run: swift test -v --enable-code-coverage
- uses: sersoft-gmbh/swift-coverage-action@v4
id: coverage-files-spm
with:
Expand All @@ -161,16 +160,6 @@ jobs:
- name: Lint
run: ./scripts/lint.sh
if: ${{ github.event_name == 'pull_request' && ( github.base_ref == 'main' || endsWith( github.ref_name , 'Prep') ) && matrix.xcode == '/Applications/Xcode_16.1.app' }}
- name: Dump PIF
if: startsWith(matrix.xcode,'/Applications/Xcode_14')
run: |
swift package dump-pif > /dev/null
MAX_ATTEMPT=3
ATTEMPT=0
while [ -z $SUCCESS ] && [ "$ATTEMPT" -le "$MAX_ATTEMPT" ]; do
xcodebuild clean -scheme FelinePine -destination 'generic/platform=iOS' | grep -q "CLEAN SUCCEEDED" && SUCCESS=true
ATTEMPT=$(($ATTEMPT+1))
done
- name: Run iOS target tests
run: xcodebuild test -scheme FelinePine -sdk iphonesimulator -destination 'platform=iOS Simulator,name=${{ matrix.iPhoneName }},OS=${{ matrix.iOSVersion }}' -enableCodeCoverage YES build test
- uses: sersoft-gmbh/swift-coverage-action@v4
Expand Down
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"lldb.library": "/usr/lib/liblldb.so",
"lldb.launch.expressions": "native"
}
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ let package = Package(
SwiftSetting.enableUpcomingFeature("ImplicitOpenExistentials"),
SwiftSetting.enableUpcomingFeature("StrictConcurrency"),
SwiftSetting.enableUpcomingFeature("DisableOutwardActorInference"),
SwiftSetting.enableExperimentalFeature("StrictConcurrency")
SwiftSetting.enableExperimentalFeature("StrictConcurrency"),
SwiftSetting.enableExperimentalFeature("AccessLevelOnImport")
]
),
.testTarget(
Expand Down
Binary file modified Sources/FelinePine/Documentation.docc/Resources/FelinePine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Sources/FelinePine/Documentation.docc/Resources/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Sources/FelinePine/Documentation.docc/Resources/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 3 additions & 13 deletions Sources/FelinePine/Feline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,8 @@

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
#if canImport(os)
public import os
#endif

/// Defines the ``LoggingSystem`` to use as well as the category.
Expand All @@ -54,7 +44,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
11 changes: 8 additions & 3 deletions Sources/FelinePine/Loggable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@

import Foundation

#if canImport(os) || canImport(Logging)
// swiftlint:disable missing_docs
#if canImport(os)
@_documentation(visibility: internal)
public typealias FelinePineProtocol = Feline & Pine
#else
@_documentation(visibility: internal)
public typealias FelinePineProtocol = Feline
#endif
// swiftlint:enable missing_docs

/// Loggable type for a ``LoggingSystem``.
public protocol Loggable<LoggingSystemType>: FelinePineProtocol
where LoggingSystemType: LoggingSystem {}
public protocol Loggable<LoggingSystemType>: FelinePineProtocol {
associatedtype LoggingSystemType: LoggingSystem
}
23 changes: 3 additions & 20 deletions Sources/FelinePine/Logger+LoggerCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,15 @@
// OTHER DEALINGS IN THE SOFTWARE.
//

#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)
public import os

#if canImport(os) || canImport(Logging)
extension Logger {
internal init<Category: RawRepresentable>(
subsystem: String,
category: Category
) where Category.RawValue == String {
#if canImport(os)
self.init(subsystem: subsystem, category: category.rawValue)
#else
self.init(label: subsystem)
self[metadataKey: "category"] = "\(category)"
#endif
self.init(subsystem: subsystem, category: category.rawValue)
}
}
#endif
52 changes: 0 additions & 52 deletions Sources/FelinePine/Logger.swift

This file was deleted.

18 changes: 4 additions & 14 deletions Sources/FelinePine/LoggingSystem+LoggingSystemRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,8 @@

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
#if canImport(os)
public import os
#endif

// swiftlint:disable strict_fileprivate
Expand All @@ -54,7 +44,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 +84,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
16 changes: 3 additions & 13 deletions Sources/FelinePine/LoggingSystem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,8 @@

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
#if canImport(os)
public import os
#endif

/// Defines the logging categories for your application.
Expand All @@ -54,7 +44,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
Loading

0 comments on commit b89389f

Please sign in to comment.