Skip to content

Commit

Permalink
chore: extract WireLogger into Swift package - WPB-11881 (#1938)
Browse files Browse the repository at this point in the history
  • Loading branch information
caldrian authored Dec 6, 2024
1 parent 57ac870 commit d7a70a3
Show file tree
Hide file tree
Showing 278 changed files with 673 additions and 1,040 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/test_pr_changes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ jobs:
- 'wire-ios-request-strategy/**'
WireAPI:
- 'WireAPI/**'
- 'wire-ios-mono.xcworkspace/xcshareddata/xcschemes/WireAPIAll.xcscheme'
WireAnalytics:
- 'WireAnalytics/Sources/WireAnalytics/**'
- 'WireAnalytics/Sources/WireDatadog/**'
- 'WireAnalytics/**'
- 'wire-ios-mono.xcworkspace/xcshareddata/xcschemes/WireAnalyticsAll.xcscheme'
WireDomain:
- 'WireDomain/**'
WireLogging:
- 'WireLogging/**'
- 'wire-ios-mono.xcworkspace/xcshareddata/xcschemes/WireLoggingAll.xcscheme'
wire-ios-data-model:
- 'wire-ios-data-model/**'
wire-ios-transport:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ playground.xcworkspace
# .swiftpm

.build/
# Ignore Package.resolved files in packages and projects, only track the one in the workspace.
**/Package.resolved
!wire-ios-mono.xcworkspace/xcshareddata/swiftpm/Package.resolved

# CocoaPods
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public final class AnalyticsService: AnalyticsServiceProtocol {

public convenience init(
config: Config?,
logger: @escaping (String) -> Void
logger: @escaping (String) -> Void // TODO: [WPB-11881] import WireLogging and remove this workaround
) {
self.init(
config: config,
Expand Down
1,024 changes: 38 additions & 986 deletions WireDomain/Project/WireDomain Project.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import Foundation
import WireAPI
import WireDataModel
import WireLogging

// sourcery: AutoMockable
/// Decrypt the E2EE content within update events.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//

import WireAPI
import WireLogging
import WireSystem

/// Process conversation create events.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//

import WireAPI
import WireLogging
import WireSystem

/// Process conversation receipt mode update events.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//

import WireAPI
import WireLogging
import WireSystem

/// Process user properties delete events.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import CoreData
import WireDataModel
import WireLogging

// sourcery: AutoMockable
/// A local store dedicated to conversations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import Foundation
import WireAPI
import WireDataModel
import WireLogging

// sourcery: AutoMockable
/// Facilitate access to conversations related domain objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//

import WireDataModel
import WireLogging

// sourcery: AutoMockable
public protocol ConversationLabelsLocalStoreProtocol {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import WireAPI
import WireDataModel
import WireLogging

// sourcery: AutoMockable
/// Facilitates access to conversation labels related domain objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//

import WireDataModel
import WireLogging

protocol FeatureConfigLocalStoreProtocol {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import Combine
import WireAPI
import WireDataModel
import WireLogging

/// Facilitates access to feature configs related domain objects.
protocol FeatureConfigRepositoryProtocol {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import WireDataModel
import WireFoundation
import WireLogging

// sourcery: AutoMockable
protocol UpdateEventsLocalStoreProtocol {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Foundation
import WireAPI
import WireDataModel
import WireFoundation
import WireLogging

// sourcery: AutoMockable
/// Access update events.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//

import WireDataModel
import WireLogging

// sourcery: AutoMockable
/// A local store dedicated to user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Foundation
import WireAPI
import WireDataModel
import WireFoundation
import WireLogging

// sourcery: AutoMockable
/// Facilitate access to users related domain objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//

import WireDataModel
import WireLogging

// sourcery: AutoMockable
public protocol UserClientsLocalStoreProtocol {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import CoreData
import WireAPI
import WireDataModel
import WireLogging

// sourcery: AutoMockable
/// Resolves 1:1 conversations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import CoreData
import Foundation
import WireAPI
import WireDataModel
import WireLogging
import WireSystem

protocol SyncManagerProtocol {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import WireAPI
import WireDataModel
import WireLogging
import WireSystem

// sourcery: AutoMockable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import WireAPI
import WireDomainSupport
import XCTest

@testable import WireDomain

final class FeatureConfigUpdateEventProcessorTests: XCTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import WireAPISupport
import WireDataModel
import WireDataModelSupport
import XCTest

@testable import WireDomain
@testable import WireDomainSupport

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,34 @@
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "WireLogging"
BuildableName = "WireLogging"
BlueprintName = "WireLogging"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "WireLoggingSupport"
BuildableName = "WireLoggingSupport"
BlueprintName = "WireLoggingSupport"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
Expand All @@ -73,6 +101,16 @@
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "WireLoggingTests"
BuildableName = "WireLoggingTests"
BlueprintName = "WireLoggingTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
1 change: 0 additions & 1 deletion WireFoundation/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ let package = Package(
)

for target in package.targets {
guard target.type != .plugin else { continue }
target.swiftSettings = (target.swiftSettings ?? []) + [
.enableUpcomingFeature("InternalImportsByDefault"),
.enableUpcomingFeature("FullTypedThrows"),
Expand Down
7 changes: 7 additions & 0 deletions WireFoundation/Tests/TestPlans/AllTests.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
"testExecutionOrdering" : "random"
},
"testTargets" : [
{
"target" : {
"containerPath" : "container:WireFoundation",
"identifier" : "WireLoggingTests",
"name" : "WireLoggingTests"
}
},
{
"target" : {
"containerPath" : "container:WireFoundation",
Expand Down
8 changes: 8 additions & 0 deletions WireLogging/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FILEHEADER</key>
<string>
// Wire
// Copyright (C) ___YEAR___ Wire Swiss GmbH
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see http://www.gnu.org/licenses/.
//</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
<false/>
</dict>
</plist>
37 changes: 37 additions & 0 deletions WireLogging/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "WireLogging",
platforms: [.iOS(.v16), .macOS(.v12)],
products: [
.library(name: "WireLogging", targets: ["WireLogging"]),
.library(name: "WireLoggingSupport", targets: ["WireLoggingSupport"])
],
dependencies: [
.package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.1.0"),
.package(path: "../WirePlugins")
],
targets: [
.target(name: "WireLogging"),
.target(
name: "WireLoggingSupport",
dependencies: ["WireLogging"],
plugins: [.plugin(name: "SourceryPlugin", package: "WirePlugins")]
),
.testTarget(
name: "WireLoggingTests",
dependencies: ["WireLogging", "WireLoggingSupport"]
)
]
)

for target in package.targets {
target.swiftSettings = (target.swiftSettings ?? []) + [
.enableUpcomingFeature("InternalImportsByDefault"),
.enableUpcomingFeature("FullTypedThrows"),
.enableUpcomingFeature("ExistentialAny")
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// along with this program. If not, see http://www.gnu.org/licenses/.
//

import Foundation

final class AggregatedLogger: LoggerProtocol {
private var loggers: [any LoggerProtocol]

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// along with this program. If not, see http://www.gnu.org/licenses/.
//

public import Foundation

public protocol LoggerProtocol {

func debug(_ message: any LogConvertible, attributes: LogAttributes...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
// along with this program. If not, see http://www.gnu.org/licenses/.
//

import Foundation
public import Foundation

import OSLog

public protocol FileLoggerDestination {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// along with this program. If not, see http://www.gnu.org/licenses/.
//

public import Foundation

public struct WireLogger: LoggerProtocol, Sendable {

public static func initialize(loggers: [any LoggerProtocol]) {
Expand Down
Loading

0 comments on commit d7a70a3

Please sign in to comment.