Skip to content

Commit 7016dfc

Browse files
authored
Set the log level to LOG_LEVEL env variable (#417)
* set the log level to LOG_LEVEL env variable * remove need for `var logger` * swift-format * [ci] update static sdk to 6.0.2
1 parent 4992ba5 commit 7016dfc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.github/workflows/pull_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ jobs:
4747
# https://github.com/swiftlang/github-workflows/issues/34
4848
musl:
4949
runs-on: ubuntu-latest
50-
container: swift:6.0-noble
50+
container: swift:6.0.2-noble
5151
timeout-minutes: 30
5252
steps:
5353
- name: Check out code
5454
uses: actions/checkout@v4
5555
- name: Install SDK
56-
run: swift sdk install https://download.swift.org/swift-6.0.1-release/static-sdk/swift-6.0.1-RELEASE/swift-6.0.1-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz --checksum d4f46ba40e11e697387468e18987ee622908bc350310d8af54eb5e17c2ff5481
56+
run: swift sdk install https://download.swift.org/swift-6.0.2-release/static-sdk/swift-6.0.2-RELEASE/swift-6.0.2-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz --checksum aa5515476a403797223fc2aad4ca0c3bf83995d5427fb297cab1d93c68cee075
5757
- name: Build
5858
run: swift build --swift-sdk x86_64-swift-linux-musl

Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ public final class LambdaRuntime<Handler>: @unchecked Sendable where Handler: St
3333
) {
3434
self.handlerMutex = NIOLockedValueBox(handler)
3535
self.eventLoop = eventLoop
36+
37+
// by setting the log level here, we understand it can not be changed dynamically at runtime
38+
// developers have to wait for AWS Lambda to dispose and recreate a runtime environment to pickup a change
39+
// this approach is less flexible but more performant than reading the value of the environment variable at each invocation
40+
var log = logger
41+
log.logLevel = Lambda.env("LOG_LEVEL").flatMap(Logger.Level.init) ?? .info
3642
self.logger = logger
3743
}
3844

0 commit comments

Comments
 (0)