Skip to content

Commit

Permalink
feat: add logging option (#10)
Browse files Browse the repository at this point in the history
* feat: add logging option

* chore: update log messages

* wip: fix ubuntu version and swift version mismatch

* wip: add `executionTimeAllowance` only for mac platforms

* wip: remove unnecessary base test class

* wip: remove duplication

* refactor: remove use of lock for synchronization

* wip: add additional logs to continuation tracking

* wip: add more logs

* wip: move all the mutation to actor isolated context

* wip: format code

* wip: add more logs

* wip: add deinitialization log

* wip: remove cleanup logic from actor deinit

* wip: add additional logs

* wip: add `@_unsafeInheritExecutor` flags

* wip: remove `@_unsafeInheritExecutor`

* wip: remove `@escaping` where not needed

* wip: add `@_unsafeInheritExecutor` flags

* test: forward file and line for assertions
  • Loading branch information
soumyamahunt committed Dec 14, 2022
1 parent d1c5531 commit bdd688b
Show file tree
Hide file tree
Showing 29 changed files with 2,882 additions and 1,402 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
"swift": "5.7"
},
{
"os": "ubuntu-latest",
"os": "ubuntu-20.04",
"swift": "5.6"
}
]
Expand Down
22 changes: 22 additions & 0 deletions AsyncObjects.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,31 @@ Pod::Spec.new do |s|
}

s.dependency 'OrderedCollections', '~> 1.0.0'
s.default_subspecs = :none

s.subspec 'Checked' do |ss|
ss.pod_target_xcconfig = {
'OTHER_SWIFT_FLAGS' => '-D ASYNCOBJECTS_USE_CHECKEDCONTINUATION'
}
end

s.subspec 'Logging' do |ss|
ss.dependency 'Logging', '~> 1.0.0'
# ss.default_subspec = 'Info'

for level in ['Debug', 'Info', 'Trace'] do
ss.subspec level do |sss|
sss.pod_target_xcconfig = {
'OTHER_SWIFT_FLAGS' => "-D ASYNCOBJECTS_ENABLE_LOGGING_LEVEL_#{level.upcase}"
}
end
end
end

s.test_spec do |ts|
ts.source_files = "Tests/#{s.name}Tests/**/*.swift"
ts.dependency "#{s.name}/Checked"
ts.dependency "#{s.name}/Logging"
ts.scheme = { :parallelizable => true }
end
end
819 changes: 416 additions & 403 deletions AsyncObjects.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

127 changes: 52 additions & 75 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,97 +3,74 @@
import PackageDescription
import class Foundation.ProcessInfo

let appleGitHub = "https://github.com/apple"
let package = Package(
name: "AsyncObjects",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6),
],
products: [
.library(
name: "AsyncObjects",
targets: ["AsyncObjects"]
),
],
dependencies: [
.package(url: "\(appleGitHub)/swift-collections.git", from: "1.0.0"),
.package(url: "\(appleGitHub)/swift-docc-plugin", from: "1.0.0"),
.package(url: "\(appleGitHub)/swift-format", from: "0.50700.0"),
],
targets: [
.target(
name: "AsyncObjects",
dependencies: [
.product(
name: "OrderedCollections",
package: "swift-collections"
),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "AsyncObjectsTests",
dependencies: ["AsyncObjects"],
swiftSettings: testingSwiftSettings
),
var dependencies: [Target.Dependency] = {
var dependencies: [Target.Dependency] = [
.product(name: "OrderedCollections", package: "swift-collections")
]
)

var swiftSettings: [SwiftSetting] = {
var swiftSettings: [SwiftSetting] = []
if ProcessInfo.processInfo.environment["ASYNCOBJECTS_ENABLE_LOGGING_LEVEL"] != nil {
dependencies.append(.product(name: "Logging", package: "swift-log"))
}

return dependencies
}()

var settings: [SwiftSetting] = {
var settings: [SwiftSetting] = []

if ProcessInfo.processInfo.environment[
"SWIFTCI_CONCURRENCY_CHECKS"
] != nil {
swiftSettings.append(
if ProcessInfo.processInfo.environment["SWIFTCI_CONCURRENCY_CHECKS"] != nil {
settings.append(
.unsafeFlags([
"-Xfrontend",
"-warn-concurrency",
"-enable-actor-data-race-checks",
"-require-explicit-sendable",
"-strict-concurrency=complete"
])
)
}

if ProcessInfo.processInfo.environment[
"SWIFTCI_WARNINGS_AS_ERRORS"
] != nil {
swiftSettings.append(
.unsafeFlags([
"-warnings-as-errors"
])
)
if ProcessInfo.processInfo.environment["SWIFTCI_WARNINGS_AS_ERRORS"] != nil {
settings.append(.unsafeFlags(["-warnings-as-errors"]))
}

if ProcessInfo.processInfo.environment[
"ASYNCOBJECTS_USE_CHECKEDCONTINUATION"
] != nil {
swiftSettings.append(
.define("ASYNCOBJECTS_USE_CHECKEDCONTINUATION")
)
if ProcessInfo.processInfo.environment["ASYNCOBJECTS_USE_CHECKEDCONTINUATION"] != nil {
settings.append(.define("ASYNCOBJECTS_USE_CHECKEDCONTINUATION"))
}

return swiftSettings
}()

var testingSwiftSettings: [SwiftSetting] = {
var swiftSettings: [SwiftSetting] = []

if ProcessInfo.processInfo.environment[
"SWIFTCI_CONCURRENCY_CHECKS"
] != nil {
swiftSettings.append(
.unsafeFlags([
"-Xfrontend",
"-warn-concurrency",
"-enable-actor-data-race-checks",
"-require-explicit-sendable",
])
)
if let level = ProcessInfo.processInfo.environment["ASYNCOBJECTS_ENABLE_LOGGING_LEVEL"] {
if level.caseInsensitiveCompare("TRACE") == .orderedSame {
settings.append(.define("ASYNCOBJECTS_ENABLE_LOGGING_LEVEL_TRACE"))
} else if level.caseInsensitiveCompare("DEBUG") == .orderedSame {
settings.append(.define("ASYNCOBJECTS_ENABLE_LOGGING_LEVEL_DEBUG"))
} else {
settings.append(.define("ASYNCOBJECTS_ENABLE_LOGGING_LEVEL_INFO"))
}
}

return swiftSettings
return settings
}()

let appleGitHub = "https://github.com/apple"
let package = Package(
name: "AsyncObjects",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6),
],
products: [
.library(name: "AsyncObjects", targets: ["AsyncObjects"]),
],
dependencies: [
.package(url: "\(appleGitHub)/swift-collections.git", from: "1.0.0"),
.package(url: "\(appleGitHub)/swift-docc-plugin", from: "1.0.0"),
.package(url: "\(appleGitHub)/swift-format", from: "0.50700.0"),
.package(url: "\(appleGitHub)/swift-log.git", from: "1.0.0"),
],
targets: [
.target(name: "AsyncObjects", dependencies: dependencies, swiftSettings: settings),
.testTarget(name: "AsyncObjectsTests", dependencies: ["AsyncObjects"]),
]
)

0 comments on commit bdd688b

Please sign in to comment.