Skip to content

Commit c6ebe92

Browse files
Improvements to logging in the app using swift-log and structured logging (#168)
This is a draft since I've only done the initial set of changes. The output currently looks like this with the `logger` being used almost everywhere, and with structured logging being used: ```bash $ swift run swift-sdk-generator make-linux-sdk --swift-version 6.0.3-RELEASE --host x86_64-unknown-linux-gnu --target aarch64-unknown-linux-gnu warning: 'swift-algorithms': found 1 file(s) which are unhandled; explicitly declare them as resources or exclude from the target ~/swift-sdk-generator/.build/checkouts/swift-algorithms/Sources/Algorithms/Documentation.docc Building for debugging... [79/79] Linking swift-sdk-generator Build of product 'swift-sdk-generator' complete! (14.74s) 2025-01-17T10:19:19-0500 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Downloading required toolchain packages... 2025-01-17T10:19:21-0500 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Using downloaded artifacts in these locations: 2025-01-17T10:19:21-0500 info org.swift.swift-sdk-generator : path=~/swift-sdk-generator/Artifacts/target_swift_6.0.3-RELEASE_aarch64-unknown-linux-gnu.tar.gz [SwiftSDKGenerator] - 2025-01-17T10:19:21-0500 info org.swift.swift-sdk-generator : path=~/swift-sdk-generator/Artifacts/host_swift_6.0.3-RELEASE_x86_64-unknown-linux-gnu.tar.gz [SwiftSDKGenerator] - 2025-01-17T10:19:21-0500 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Parsing Ubuntu packages list... 2025-01-17T10:19:23-0500 info org.swift.swift-sdk-generator : packageCount=11 [SwiftSDKGenerator] Downloading Ubuntu packages... 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : size=40 KB url=http://ports.ubuntu.com/ubuntu-ports/pool/main/g/gcc-12/libgcc-s1_12.3.0-1ubuntu1~22.04_arm64.deb [SwiftSDKGenerator] Downloaded 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : size=57 KB url=http://ports.ubuntu.com/ubuntu-ports/pool/main/z/zlib/zlib1g_1.2.11.dfsg-2ubuntu9.2_arm64.deb [SwiftSDKGenerator] Downloaded 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : size=1.5 MB url=http://ports.ubuntu.com/ubuntu-ports/pool/main/g/glibc/libc6-dev_2.35-0ubuntu3.8_arm64.deb [SwiftSDKGenerator] Downloaded 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : size=163 KB url=http://ports.ubuntu.com/ubuntu-ports/pool/main/z/zlib/zlib1g-dev_1.2.11.dfsg-2ubuntu9.2_arm64.deb [SwiftSDKGenerator] Downloaded 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : size=2.7 MB url=http://ports.ubuntu.com/ubuntu-ports/pool/main/g/glibc/libc6_2.35-0ubuntu3.8_arm64.deb [SwiftSDKGenerator] Downloaded 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : size=661 KB url=http://ports.ubuntu.com/ubuntu-ports/pool/main/g/gcc-12/libstdc++6_12.3.0-1ubuntu1~22.04_arm64.deb [SwiftSDKGenerator] Downloaded 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : size=1.2 MB url=http://ports.ubuntu.com/ubuntu-ports/pool/main/g/gcc-12/libgcc-12-dev_12.3.0-1ubuntu1~22.04_arm64.deb [SwiftSDKGenerator] Downloaded 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : size=1.3 MB url=http://ports.ubuntu.com/ubuntu-ports/pool/main/l/linux/linux-libc-dev_5.15.0-130.140_arm64.deb [SwiftSDKGenerator] Downloaded 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : size=11.6 MB url=http://ports.ubuntu.com/ubuntu-ports/pool/main/i/icu/libicu-dev_70.1-2_arm64.deb [SwiftSDKGenerator] Downloaded 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : size=2.2 MB url=http://ports.ubuntu.com/ubuntu-ports/pool/universe/g/gcc-12/libstdc++-12-dev_12.3.0-1ubuntu1~22.04_arm64.deb [SwiftSDKGenerator] Downloaded 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : size=10.5 MB url=http://ports.ubuntu.com/ubuntu-ports/pool/main/i/icu/libicu70_70.1-2_arm64.deb [SwiftSDKGenerator] Downloaded 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : fileName=libc6_2.35-0ubuntu3.8_arm64.deb [SwiftSDKGenerator] Extracting deb package... 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : fileName=libc6-dev_2.35-0ubuntu3.8_arm64.deb [SwiftSDKGenerator] Extracting deb package... 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : fileName=libgcc-s1_12.3.0-1ubuntu1~22.04_arm64.deb [SwiftSDKGenerator] Extracting deb package... 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : fileName=libgcc-12-dev_12.3.0-1ubuntu1~22.04_arm64.deb [SwiftSDKGenerator] Extracting deb package... 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : fileName=libicu70_70.1-2_arm64.deb [SwiftSDKGenerator] Extracting deb package... 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : fileName=libicu-dev_70.1-2_arm64.deb [SwiftSDKGenerator] Extracting deb package... 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : fileName=libstdc++-12-dev_12.3.0-1ubuntu1~22.04_arm64.deb [SwiftSDKGenerator] Extracting deb package... 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : fileName=libstdc++6_12.3.0-1ubuntu1~22.04_arm64.deb [SwiftSDKGenerator] Extracting deb package... 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : fileName=linux-libc-dev_5.15.0-130.140_arm64.deb [SwiftSDKGenerator] Extracting deb package... 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : fileName=zlib1g_1.2.11.dfsg-2ubuntu9.2_arm64.deb [SwiftSDKGenerator] Extracting deb package... 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : fileName=zlib1g-dev_1.2.11.dfsg-2ubuntu9.2_arm64.deb [SwiftSDKGenerator] Extracting deb package... 2025-01-17T10:19:25-0500 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Unpacking and copying Swift binaries for the host triple... 2025-01-17T10:19:37-0500 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Unpacking Swift distribution for the target triple... 2025-01-17T10:19:49-0500 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Copying Swift core libraries for the target triple into Swift SDK bundle... 2025-01-17T10:19:50-0500 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Fixing up absolute symlinks... 2025-01-17T10:19:51-0500 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Generating toolset JSON file... 2025-01-17T10:19:51-0500 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Generating destination JSON file... 2025-01-17T10:19:51-0500 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] Generating .artifactbundle manifest file... 2025-01-17T10:19:51-0500 info org.swift.swift-sdk-generator : [SwiftSDKGenerator] All done! Install the newly generated SDK with this command: swift experimental-sdk install ~/swift-sdk-generator/Bundles/6.0.3-RELEASE_ubuntu_jammy_aarch64.artifactbundle After that, use the newly installed SDK when building with this command: swift build --experimental-swift-sdk 6.0.3-RELEASE_ubuntu_jammy_aarch64 2025-01-17T10:19:51-0500 info org.swift.swift-sdk-generator : elapsedTime=31 seconds [GeneratorCLI] Generator run finished successfully. ```
1 parent 6bf9922 commit c6ebe92

16 files changed

+127
-76
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ installed, in case you've used the `swift experimental-sdk install` command befo
2929

3030
## Supported platforms and minimum versions
3131

32-
macOS as a host platform and a few Linux distributions as target platforms are supported by the generator.
33-
Support for Linux as a host platform is currently in development. Eventually, the generator will allow cross-compiling between any
34-
Linux distributions officially supported by the Swift project.
32+
macOS as a host platform and Linux as both host and target platforms are supported by the generator.
33+
The generator also allows cross-compiling between any Linux distributions officially supported by the Swift project.
3534

3635
| Platform | Supported Version as Host | Supported Version as Target |
3736
| -: | :- | :- |

Sources/GeneratorCLI/GeneratorCLI.swift

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,29 @@ import struct SystemPackage.FilePath
1717

1818
@main
1919
struct GeneratorCLI: AsyncParsableCommand {
20+
static let appLogger = Logger(label: "org.swift.swift-sdk-generator")
21+
2022
static let configuration = CommandConfiguration(
2123
commandName: "swift-sdk-generator",
2224
subcommands: [MakeLinuxSDK.self, MakeWasmSDK.self],
2325
defaultSubcommand: MakeLinuxSDK.self
2426
)
2527

28+
static func loggerWithLevel(from options: GeneratorOptions) -> Logger {
29+
var logger = self.appLogger
30+
if options.verbose {
31+
logger.logLevel = .debug
32+
}
33+
return logger
34+
}
35+
2636
static func run(
2737
recipe: some SwiftSDKRecipe,
2838
targetTriple: Triple,
2939
options: GeneratorOptions
3040
) async throws {
41+
let logger = loggerWithLevel(from: options)
3142
let elapsed = try await ContinuousClock().measure {
32-
let logger = Logger(label: "org.swift.swift-sdk-generator")
3343
let generator = try await SwiftSDKGenerator(
3444
bundleVersion: options.bundleVersion,
3545
targetTriple: targetTriple,
@@ -57,7 +67,7 @@ struct GeneratorCLI: AsyncParsableCommand {
5767
try await generatorTask.value
5868
}
5969

60-
print("\nTime taken for this generator run: \(elapsed.intervalString).")
70+
logger.info("Generator run finished successfully.", metadata: ["elapsedTime": .string(elapsed.intervalString)])
6171
}
6272
}
6373

@@ -151,7 +161,7 @@ extension GeneratorCLI {
151161
let current = try SwiftSDKGenerator.getCurrentTriple(isVerbose: self.verbose)
152162
if let arch = hostArch {
153163
let target = Triple(arch: arch, vendor: current.vendor!, os: current.os!)
154-
print("deprecated: Please use `--host \(target.triple)` instead of `--host-arch \(arch)`")
164+
appLogger.warning("deprecated: Please use `--host \(target.triple)` instead of `--host-arch \(arch)`")
155165
return target
156166
}
157167
return current
@@ -202,14 +212,14 @@ extension GeneratorCLI {
202212
}
203213
if let arch = generatorOptions.targetArch {
204214
let target = Triple(arch: arch, vendor: nil, os: .linux, environment: .gnu)
205-
print("deprecated: Please use `--target \(target.triple)` instead of `--target-arch \(arch)`")
215+
appLogger.warning("deprecated: Please use `--target \(target.triple)` instead of `--target-arch \(arch)`")
206216
}
207217
return Triple(arch: hostTriple.arch!, vendor: nil, os: .linux, environment: .gnu)
208218
}
209219

210220
func run() async throws {
211221
if self.isInvokedAsDefaultSubcommand() {
212-
print(
222+
appLogger.warning(
213223
"deprecated: Please explicitly specify the subcommand to run. For example: $ swift-sdk-generator make-linux-sdk"
214224
)
215225
}
@@ -236,7 +246,8 @@ extension GeneratorCLI {
236246
fromContainerImage: self.fromContainerImage,
237247
hostSwiftPackagePath: self.generatorOptions.hostSwiftPackagePath,
238248
targetSwiftPackagePath: self.generatorOptions.targetSwiftPackagePath,
239-
includeHostToolchain: self.generatorOptions.hostToolchain
249+
includeHostToolchain: self.generatorOptions.hostToolchain,
250+
logger: loggerWithLevel(from: self.generatorOptions)
240251
)
241252
try await GeneratorCLI.run(recipe: recipe, targetTriple: targetTriple, options: self.generatorOptions)
242253
}
@@ -290,7 +301,8 @@ extension GeneratorCLI {
290301
},
291302
targetSwiftPackagePath: FilePath(targetSwiftPackagePath),
292303
wasiSysroot: FilePath(self.wasiSysroot),
293-
swiftVersion: self.generatorOptions.swiftVersion
304+
swiftVersion: self.generatorOptions.swiftVersion,
305+
logger: loggerWithLevel(from: self.generatorOptions)
294306
)
295307
let targetTriple = self.deriveTargetTriple()
296308
try await GeneratorCLI.run(recipe: recipe, targetTriple: targetTriple, options: self.generatorOptions)

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Copy.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ extension SwiftSDKGenerator {
1818
baseDockerImage: String,
1919
sdkDirPath: FilePath
2020
) async throws {
21-
logGenerationStep("Launching a container to extract the Swift SDK for the target triple...")
21+
logger.info("Launching a container to extract the Swift SDK for the target triple...")
2222
try await withDockerContainer(fromImage: baseDockerImage) { containerID in
2323
try await inTemporaryDirectory { generator, _ in
2424
let sdkUsrPath = sdkDirPath.appending("usr")
@@ -102,7 +102,7 @@ extension SwiftSDKGenerator {
102102
}
103103

104104
func copyTargetSwift(from distributionPath: FilePath, sdkDirPath: FilePath) async throws {
105-
logGenerationStep("Copying Swift core libraries for the target triple into Swift SDK bundle...")
105+
logger.info("Copying Swift core libraries for the target triple into Swift SDK bundle...")
106106

107107
for (pathWithinPackage, pathWithinSwiftSDK) in [
108108
("lib/swift", sdkDirPath.appending("usr/lib")),

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Download.swift

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import AsyncAlgorithms
14+
import Logging
1415
import Helpers
1516
import RegexBuilder
1617

@@ -23,13 +24,19 @@ import struct SystemPackage.FilePath
2324
private let ubuntuAMD64Mirror = "http://gb.archive.ubuntu.com/ubuntu"
2425
private let ubuntuARM64Mirror = "http://ports.ubuntu.com/ubuntu-ports"
2526

27+
extension FilePath {
28+
var metadataValue: Logger.MetadataValue {
29+
.string(self.string)
30+
}
31+
}
32+
2633
extension SwiftSDKGenerator {
2734
func downloadArtifacts(
2835
_ client: some HTTPClientProtocol, _ engine: QueryEngine,
2936
downloadableArtifacts: inout DownloadableArtifacts,
3037
itemsToDownload: @Sendable (DownloadableArtifacts) -> [DownloadableArtifacts.Item]
3138
) async throws {
32-
logGenerationStep("Downloading required toolchain packages...")
39+
logger.info("Downloading required toolchain packages...")
3340
let hostLLVMURL = downloadableArtifacts.hostLLVM.remoteURL
3441
// Workaround an issue with github.com returning 400 instead of 404 status to HEAD requests from AHC.
3542
let isLLVMBinaryArtifactAvailable = try await type(of: client).with(http1Only: true) {
@@ -46,7 +53,7 @@ extension SwiftSDKGenerator {
4653
let results = try await withThrowingTaskGroup(of: FileCacheRecord.self) { group in
4754
for item in itemsToDownload(downloadableArtifacts) {
4855
group.addTask {
49-
try await engine[DownloadArtifactQuery(artifact: item, httpClient: client)]
56+
try await engine[DownloadArtifactQuery(artifact: item, httpClient: client, logger: self.logger)]
5057
}
5158
}
5259

@@ -57,10 +64,10 @@ extension SwiftSDKGenerator {
5764
return result
5865
}
5966

60-
print("Using downloaded artifacts in these locations:")
61-
for path in results.map(\.path) {
62-
print(path)
63-
}
67+
logger.info("Using downloaded artifacts from cache")
68+
logger.debug("Using downloaded artifacts in these locations.", metadata: [
69+
"paths": .array(results.map(\.path.metadataValue))
70+
])
6471
}
6572

6673
func downloadUbuntuPackages(
@@ -70,7 +77,7 @@ extension SwiftSDKGenerator {
7077
versionsConfiguration: VersionsConfiguration,
7178
sdkDirPath: FilePath
7279
) async throws {
73-
logGenerationStep("Parsing Ubuntu packages list...")
80+
logger.debug("Parsing Ubuntu packages list...")
7481

7582
async let mainPackages = try await client.parseUbuntuPackagesList(
7683
ubuntuRelease: versionsConfiguration.linuxDistribution.release,
@@ -108,12 +115,13 @@ extension SwiftSDKGenerator {
108115
)
109116
}
110117

111-
print("Downloading \(urls.count) Ubuntu packages...")
118+
logger.info("Downloading Ubuntu packages...", metadata: ["packageCount": .stringConvertible(urls.count)])
112119
try await inTemporaryDirectory { fs, tmpDir in
113120
let downloadedFiles = try await self.downloadFiles(from: urls, to: tmpDir, client, engine)
114-
report(downloadedFiles: downloadedFiles)
121+
await report(downloadedFiles: downloadedFiles)
115122

116123
for fileName in urls.map(\.lastPathComponent) {
124+
logger.debug("Extracting deb package...", metadata: ["fileName": .string(fileName)])
117125
try await fs.unpack(file: tmpDir.appending(fileName), into: sdkDirPath)
118126
}
119127
}
@@ -148,13 +156,16 @@ extension SwiftSDKGenerator {
148156
return result
149157
}
150158
}
151-
}
152159

153-
private func report(downloadedFiles: [(URL, UInt64)]) {
154-
let byteCountFormatter = ByteCountFormatter()
160+
private func report(downloadedFiles: [(URL, UInt64)]) {
161+
let byteCountFormatter = ByteCountFormatter()
155162

156-
for (url, bytes) in downloadedFiles {
157-
print("\(url)\(byteCountFormatter.string(fromByteCount: Int64(bytes)))")
163+
for (url, bytes) in downloadedFiles {
164+
logger.debug("Downloaded package", metadata: [
165+
"url": .string(url.absoluteString),
166+
"size": .string(byteCountFormatter.string(fromByteCount: Int64(bytes)))
167+
])
168+
}
158169
}
159170
}
160171

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Entrypoint.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,20 @@ public extension SwiftSDKGenerator {
5959

6060
try await generateArtifactBundleManifest(hostTriples: swiftSDKProduct.hostTriples)
6161

62-
logGenerationStep(
62+
// Extra spaces added for readability for the user
63+
logger.info(
6364
"""
65+
66+
6467
All done! Install the newly generated SDK with this command:
6568
swift experimental-sdk install \(pathsConfiguration.artifactBundlePath)
6669
6770
After that, use the newly installed SDK when building with this command:
6871
swift build --experimental-swift-sdk \(artifactID)
72+
6973
"""
7074
)
7175
}
7276
}
7377
}
7478
}
75-
76-
func logGenerationStep(_ message: String) {
77-
print("\n\(message)")
78-
}

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Fixup.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import struct Foundation.Data
1717

1818
extension SwiftSDKGenerator {
1919
func fixAbsoluteSymlinks(sdkDirPath: FilePath) throws {
20-
logGenerationStep("Fixing up absolute symlinks...")
20+
logger.info("Fixing up absolute symlinks...")
2121

2222
for (source, absoluteDestination) in try findSymlinks(at: sdkDirPath).filter({
2323
$1.string.hasPrefix("/")
@@ -51,7 +51,7 @@ extension SwiftSDKGenerator {
5151
func symlinkClangHeaders() throws {
5252
let swiftStaticClangPath = self.pathsConfiguration.toolchainDirPath.appending("usr/lib/swift_static/clang")
5353
if !doesFileExist(at: swiftStaticClangPath) {
54-
logGenerationStep("Symlinking clang headers...")
54+
logger.info("Symlinking clang headers...")
5555
try self.createSymlink(
5656
at: self.pathsConfiguration.toolchainDirPath.appending("usr/lib/swift_static/clang"),
5757
pointingTo: "../swift/clang"

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Metadata.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ private let encoder: JSONEncoder = {
2222

2323
extension SwiftSDKGenerator {
2424
func generateToolsetJSON(recipe: SwiftSDKRecipe) throws -> FilePath {
25-
logGenerationStep("Generating toolset JSON file...")
25+
logger.info("Generating toolset JSON file...")
2626

2727
let toolsetJSONPath = pathsConfiguration.swiftSDKRootPath.appending("toolset.json")
2828

@@ -44,7 +44,7 @@ extension SwiftSDKGenerator {
4444
}
4545

4646
func generateDestinationJSON(toolsetPath: FilePath, sdkDirPath: FilePath, recipe: SwiftSDKRecipe) throws {
47-
logGenerationStep("Generating destination JSON file...")
47+
logger.info("Generating destination JSON file...")
4848

4949
let destinationJSONPath = pathsConfiguration.swiftSDKRootPath.appending("swift-sdk.json")
5050

@@ -87,7 +87,7 @@ extension SwiftSDKGenerator {
8787
}
8888

8989
func generateArtifactBundleManifest(hostTriples: [Triple]?) throws {
90-
logGenerationStep("Generating .artifactbundle manifest file...")
90+
logger.info("Generating .artifactbundle info JSON file...")
9191

9292
let artifactBundleManifestPath = pathsConfiguration.artifactBundlePath.appending("info.json")
9393

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator+Unpack.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ let unusedHostLibraries = [
4545

4646
extension SwiftSDKGenerator {
4747
func unpackHostSwift(hostSwiftPackagePath: FilePath) async throws {
48-
logGenerationStep("Unpacking and copying Swift binaries for the host triple...")
48+
logger.info("Unpacking and copying Swift binaries for the host triple...")
4949
let pathsConfiguration = self.pathsConfiguration
5050

5151
try self.createDirectoryIfNeeded(at: pathsConfiguration.toolchainDirPath)
@@ -98,7 +98,7 @@ extension SwiftSDKGenerator {
9898
relativePathToRoot: [FilePath.Component],
9999
sdkDirPath: FilePath
100100
) async throws {
101-
logGenerationStep("Unpacking Swift distribution for the target triple...")
101+
logger.info("Unpacking Swift distribution for the target triple...")
102102

103103
try await inTemporaryDirectory { fs, tmpDir in
104104
try await fs.unpack(file: targetSwiftPackagePath, into: tmpDir)
@@ -109,7 +109,7 @@ extension SwiftSDKGenerator {
109109
}
110110

111111
func prepareLLDLinker(_ engine: QueryEngine, llvmArtifact: DownloadableArtifacts.Item) async throws {
112-
logGenerationStep("Unpacking and copying `lld` linker...")
112+
logger.info("Unpacking and copying `lld` linker...")
113113
let pathsConfiguration = self.pathsConfiguration
114114
let targetOS = self.targetTriple.os
115115

Sources/SwiftSDKGenerator/Generator/SwiftSDKGenerator.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ public actor SwiftSDKGenerator {
3434
isVerbose: Bool,
3535
logger: Logger
3636
) async throws {
37-
logGenerationStep("Looking up configuration values...")
38-
3937
let sourceRoot = FilePath(#filePath)
4038
.removingLastComponent()
4139
.removingLastComponent()
@@ -253,7 +251,11 @@ public actor SwiftSDKGenerator {
253251
let isVerbose = self.isVerbose
254252
try await self.inTemporaryDirectory { _, tmp in
255253
try await Shell.run(#"cd "\#(tmp)" && ar -x "\#(debFile)""#, shouldLogCommands: isVerbose)
256-
try await print(Shell.readStdout("ls \(tmp)"))
254+
if isVerbose {
255+
let cmd = "ls \(tmp)"
256+
let lsOutput = try await Shell.readStdout(cmd)
257+
logger.debug("Files unpacked from deb file", metadata: ["cmd": .string(cmd), "output": .string(lsOutput)])
258+
}
257259

258260
try await Shell.run(
259261
#"tar -C "\#(directoryPath)" -xf "\#(tmp)"/data.tar.*"#,

0 commit comments

Comments
 (0)