Skip to content

Commit 9ac85e0

Browse files
authored
Improved Swift 6 handling (#11)
* update timestamp handling * resolve warning * update devcontainer for swift 6 * add swift 6 mode compat * test swift 5.9 and 6 * remove gha verbose logging
1 parent a1e27ec commit 9ac85e0

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
lines changed

.devcontainer/devcontainer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "Swift",
3-
"image": "swift:5.9.1",
3+
"image": "swift:6.0",
44
"features": {
55
"ghcr.io/devcontainers/features/common-utils:2": {
66
"installZsh": "false",
77
"username": "vscode",
8-
"userUid": "1000",
9-
"userGid": "1000",
8+
"userUid": "1001",
9+
"userGid": "1001",
1010
"upgradePackages": "false"
1111
},
1212
"ghcr.io/devcontainers/features/git:1": {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Unit Test
1+
name: Test Swift 5.9
22

33
on:
44
push:
@@ -8,11 +8,11 @@ on:
88

99
jobs:
1010
build:
11-
11+
container: swift:5.9
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v4
1515
- name: Build
16-
run: swift build -v
16+
run: swift build
1717
- name: Run tests
18-
run: swift test -v
18+
run: swift test

.github/workflows/swift-6.0.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Test Swift 6.0
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
container: swift:6.0
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Build
16+
run: swift build
17+
- name: Run tests
18+
run: swift test

Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ let package = Package(
2525
.testTarget(
2626
name: "DataDogLogTests",
2727
dependencies: ["DataDogLog"]),
28-
]
28+
],
29+
swiftLanguageVersions: [.version("6"), .v5]
2930
)
3031

3132
#if os(Linux)

Sources/DataDogLog/Internal/Extensions/String+Timestamp.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ extension String {
44
static var timestamp: String {
55
var buffer = [Int8](repeating: 0, count: 255)
66
var timestamp = time(nil)
7-
let localTime = localtime(&timestamp)
7+
guard let localTime = localtime(&timestamp) else {
8+
return "<unknown>"
9+
}
810
strftime(&buffer, buffer.count, "%Y-%m-%dT%H:%M:%S%z", localTime)
11+
912
return buffer.withUnsafeBufferPointer {
1013
$0.withMemoryRebound(to: CChar.self) {
1114
String(cString: $0.baseAddress!)

Sources/DataDogLog/Internal/NetworkClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class NetworkClient: Sendable {
2424

2525
deinit {
2626
#if os(Linux)
27-
client.shutdown()
27+
client.shutdown { _ in }
2828
#endif
2929
}
3030

0 commit comments

Comments
 (0)