@@ -23,7 +23,7 @@ import NIOCore
23
23
public final class LambdaRuntime < Handler> : @unchecked Sendable where Handler: StreamingLambdaHandler {
24
24
// TODO: We want to change this to Mutex as soon as this doesn't crash the Swift compiler on Linux anymore
25
25
let handlerMutex : NIOLockedValueBox < Handler ? >
26
- var logger : Logger
26
+ let logger : Logger
27
27
let eventLoop : EventLoop
28
28
29
29
public init (
@@ -33,6 +33,12 @@ public final class LambdaRuntime<Handler>: @unchecked Sendable where Handler: St
33
33
) {
34
34
self . handlerMutex = NIOLockedValueBox ( handler)
35
35
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
36
42
self . logger = logger
37
43
}
38
44
@@ -55,11 +61,6 @@ public final class LambdaRuntime<Handler>: @unchecked Sendable where Handler: St
55
61
throw LambdaRuntimeError ( code: . runtimeCanOnlyBeStartedOnce)
56
62
}
57
63
58
- // by setting the log level here, we understand it can not be changed dynamically at runtime
59
- // developers have to wait for AWS Lambda to dispose and recreate a runtime environment to pickup a change
60
- // this approach is less flexible but more performant than reading the value of the environment variable at each invocation
61
- self . logger. logLevel = Lambda . env ( " LOG_LEVEL " ) . flatMap ( Logger . Level. init) ?? . info
62
-
63
64
try await LambdaRuntimeClient . withRuntimeClient (
64
65
configuration: . init( ip: ip, port: port) ,
65
66
eventLoop: self . eventLoop,
0 commit comments