Skip to content

Commit 1b4e150

Browse files
committed
add logger to more convenience initializers
1 parent a742c8f commit 1b4e150

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/AWSLambdaRuntime/LambdaHandlers.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ extension LambdaRuntime {
191191
/// - Parameters:
192192
/// - encoder: The encoder object that will be used to encode the generic `Output` into a `ByteBuffer`.
193193
/// - decoder: The decoder object that will be used to decode the incoming `ByteBuffer` event into the generic `Event` type.
194+
/// - logger: The logger to use for the runtime. Defaults to a logger with label "LambdaRuntime".
194195
/// - body: The handler in the form of a closure.
195196
public convenience init<
196197
Event: Decodable,
@@ -200,6 +201,7 @@ extension LambdaRuntime {
200201
>(
201202
encoder: sending Encoder,
202203
decoder: sending Decoder,
204+
logger: Logger = Logger(label: "LambdaRuntime"),
203205
body: sending @escaping (Event, LambdaContext) async throws -> Output
204206
)
205207
where
@@ -219,15 +221,17 @@ extension LambdaRuntime {
219221
handler: streamingAdapter
220222
)
221223

222-
self.init(handler: codableWrapper)
224+
self.init(handler: codableWrapper, logger: logger)
223225
}
224226

225227
/// Initialize an instance with a ``LambdaHandler`` defined in the form of a closure **with a `Void` return type**, an encoder, and a decoder.
226228
/// - Parameters:
227229
/// - decoder: The decoder object that will be used to decode the incoming `ByteBuffer` event into the generic `Event` type.
230+
/// - logger: The logger to use for the runtime. Defaults to a logger with label "LambdaRuntime".
228231
/// - body: The handler in the form of a closure.
229232
public convenience init<Event: Decodable, Decoder: LambdaEventDecoder>(
230233
decoder: sending Decoder,
234+
logger: Logger = Logger(label: "LambdaRuntime"),
231235
body: sending @escaping (Event, LambdaContext) async throws -> Void
232236
)
233237
where
@@ -244,6 +248,6 @@ extension LambdaRuntime {
244248
handler: LambdaHandlerAdapter(handler: ClosureHandler(body: body))
245249
)
246250

247-
self.init(handler: handler)
251+
self.init(handler: handler, logger: logger)
248252
}
249253
}

0 commit comments

Comments
 (0)