Skip to content

Commit 2442239

Browse files
authored
Log cleanup (#92)
* removing duplicate log statements, compressing log info to a single line for raw command display in debugging * removing commented out optional dependencies from experiments
1 parent 2e6deff commit 2442239

File tree

4 files changed

+8
-23
lines changed

4 files changed

+8
-23
lines changed

Package.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@ let package = Package(
1818
url: "https://github.com/apple/swift-async-dns-resolver",
1919
.upToNextMajor(from: "0.1.0")
2020
),
21-
// .package(url: "https://github.com/Zollerboy1/SwiftCommand.git", from: "1.4.0"),
2221
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
2322
.package(url: "https://github.com/pointfreeco/swift-parsing", from: "0.13.0"),
2423
.package(url: "https://github.com/pointfreeco/swift-dependencies", from: "1.0.0"),
2524
.package(url: "https://github.com/swiftlang/swift-format.git",
2625
.upToNextMajor(from: "600.0.0")),
27-
//.package(url: "https://github.com/orlandos-nl/Citadel/", from: "0.9.0"),
28-
//.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "2.1.0"),
2926
.package(url: "https://github.com/neallester/swift-log-testing.git", from: "0.0.1"),
3027
],
3128
targets: [
@@ -34,13 +31,9 @@ let package = Package(
3431
dependencies: [
3532
.product(name: "ArgumentParser", package: "swift-argument-parser"),
3633
.product(name: "AsyncDNSResolver", package: "swift-async-dns-resolver"),
37-
// .product(name: "SwiftCommand", package: "SwiftCommand"),
3834
.product(name: "Parsing", package: "swift-parsing"),
3935
.product(name: "Dependencies", package: "swift-dependencies"),
4036
.product(name: "Logging", package: "swift-log"),
41-
//.product(name: "Citadel", package: "Citadel"),
42-
//.product(name: "Crypto", package: "swift-crypto"),
43-
//.product(name: "_CryptoExtras", package: "swift-crypto"),
4437
]
4538
),
4639
.testTarget(

Sources/Formic/DependencyProxies/ProcessCommandInvoker.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ struct ProcessCommandInvoker: CommandInvoker {
4141
let cmdString = "'\(cmd.joined(separator: " "))'"
4242
task.arguments = ["-c", cmdString]
4343

44-
logger?.trace("RAW LOCAL COMMAND:")
45-
logger?.trace("/bin/sh -c \(cmdString)")
44+
logger?.trace("FORKED PROCESS: /bin/sh -c \(cmdString)")
4645

4746
let stdOutPipe = Pipe()
4847
let stdErrPipe = Pipe()

Sources/Formic/Engine/Engine.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ public actor Engine {
100100
numberOfRetries += 1
101101
let start = clock.now
102102
do {
103-
logger?.debug("running command \(command) against \(host)")
104103
outputOfLastAttempt = try await command.run(host: host, logger: logger)
105104
// - DISABLED execution timeout checking because it's hanging when
106105
// the process that invokes the commands is Foundation.process, which is all

examples/updateExample/Sources/updateExample.swift

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@ struct configureBastion: AsyncParsableCommand {
3434
try await engine.run(
3535
host: bastionHost, displayProgress: true, detailLevel: detailLevel,
3636
commands: [
37-
SSHCommand("uname -a"), // uses CitadelSSH
38-
SSHCommand("ls -altr"),
39-
4037
ShellCommand("mkdir -p ~/.ssh"), // uses Process and forked 'ssh' locally
4138
ShellCommand("chmod 0700 ~/.ssh"),
4239
CopyInto(location: "~/.ssh/\(keyName)", from: privateKeyLocation),
4340
CopyInto(location: "~/.ssh/\(keyName).pub", from: "\(privateKeyLocation).pub"),
4441
ShellCommand("chmod 0600 ~/.ssh/\(keyName)"),
42+
4543
// CopyFrom(into: "swiftly-install.sh", from: URL(string: "https://swiftlang.github.io/swiftly/swiftly-install.sh")!),
4644
// ShellCommand("chmod 0755 swiftly-install.sh"),
4745
// released version (0.3.0) doesn't support Ubuntu 24.04 - that's pending in 0.4.0...
@@ -54,10 +52,10 @@ struct configureBastion: AsyncParsableCommand {
5452
ShellCommand("sudo apt-get update -q", env: debUnattended),
5553
ShellCommand("sudo apt-get upgrade -y -qq", env: debUnattended),
5654

57-
// latest upgrade looks like it _doesn't_ require a reboot to complete its work.
58-
// ShellCommand("sudo reboot"),
59-
// VerifyAccess(ignoreFailure: false,
60-
// retry: Backoff(maxRetries: 10, strategy: .fibonacci(maxDelay: .seconds(10)))),
55+
// A reboot and "wait for it" to resume setup:
56+
// ShellCommand("sudo reboot"),
57+
// VerifyAccess(ignoreFailure: false,
58+
// retry: Backoff(maxRetries: 10, strategy: .fibonacci(maxDelay: .seconds(10)))),
6159

6260
// "manual install" of Swift
6361
// from https://www.swift.org/install/linux/tarball/ for Ubuntu 24.04
@@ -82,18 +80,14 @@ struct configureBastion: AsyncParsableCommand {
8280
// restart the unattended upgrades
8381
ShellCommand("sudo systemctl start unattended-upgrades.service"),
8482

85-
// yes, I know about Swiftly, but when I'm creating this it wasn't available
86-
// on swift.org and the released version wasn't yet supporting Ubuntu 24.04.
87-
8883
ShellCommand(
8984
"wget -nv https://download.swift.org/swift-6.0.3-release/ubuntu2404/swift-6.0.3-RELEASE/swift-6.0.3-RELEASE-ubuntu24.04.tar.gz"
9085
),
91-
// ~17 seconds
86+
9287
ShellCommand("tar xzf swift-6.0.3-RELEASE-ubuntu24.04.tar.gz"),
93-
// ~43 seconds
88+
9489
ShellCommand("swift-6.0.3-RELEASE-ubuntu24.04/usr/bin/swift -version"),
9590

96-
// reboot to full apply pending updates
9791
ShellCommand("sudo reboot"),
9892
])
9993
}

0 commit comments

Comments
 (0)