1
+ using System ;
2
+ using System . Runtime . Versioning ;
3
+
1
4
namespace Amazon . Lambda . Core
2
5
{
3
6
#if NET6_0_OR_GREATER
@@ -62,7 +65,7 @@ public interface ILambdaLogger
62
65
#if NET6_0_OR_GREATER
63
66
64
67
/// <summary>
65
- /// Log message catagorized by the given log level
68
+ /// Log message categorized by the given log level
66
69
/// <para>
67
70
/// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
68
71
/// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
@@ -73,7 +76,7 @@ public interface ILambdaLogger
73
76
void Log ( string level , string message ) => LogLine ( message ) ;
74
77
75
78
/// <summary>
76
- /// Log message catagorized by the given log level
79
+ /// Log message categorized by the given log level
77
80
/// <para>
78
81
/// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
79
82
/// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
@@ -142,6 +145,222 @@ public interface ILambdaLogger
142
145
/// </summary>
143
146
/// <param name="message"></param>
144
147
void LogCritical ( string message ) => Log ( LogLevel . Critical . ToString ( ) , message ) ;
148
+
149
+
150
+ private const string ParameterizedPreviewMessage =
151
+ "Parameterized logging is in preview till a new version of .NET Lambda runtime client that supports parameterized logging " +
152
+ "has been deployed to the .NET Lambda managed runtime. Till deployment has been made the feature can be used by deploying as an " +
153
+ "executable including the latest version of Amazon.Lambda.RuntimeSupport and setting the \" EnablePreviewFeatures\" in the Lambda " +
154
+ "project file to \" true\" " ;
155
+
156
+ /// <summary>
157
+ /// Log message categorized by the given log level
158
+ /// <para>
159
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
160
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
161
+ /// </para>
162
+ /// </summary>
163
+ /// <param name="level">Log level of the message.</param>
164
+ /// <param name="message">Message to log.</param>
165
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
166
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
167
+ void Log ( string level , string message , params object [ ] args ) => Log ( level , message , args ) ;
168
+
169
+ /// <summary>
170
+ /// Log message categorized by the given log level
171
+ /// <para>
172
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
173
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
174
+ /// </para>
175
+ /// </summary>
176
+ /// <param name="level">Log level of the message.</param>
177
+ /// <param name="exception">Exception to include with the logging.</param>
178
+ /// <param name="message">Message to log.</param>
179
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
180
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
181
+ void Log ( string level , Exception exception , string message , params object [ ] args )
182
+ {
183
+ Log ( level , message , args ) ;
184
+ Log ( level , exception . ToString ( ) , args ) ;
185
+ }
186
+
187
+ /// <summary>
188
+ /// Log message categorized by the given log level
189
+ /// <para>
190
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
191
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
192
+ /// </para>
193
+ /// </summary>
194
+ /// <param name="level">Log level of the message.</param>
195
+ /// <param name="message">Message to log.</param>
196
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
197
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
198
+ void Log ( LogLevel level , string message , params object [ ] args ) => Log ( level . ToString ( ) , message , args ) ;
199
+
200
+ /// <summary>
201
+ /// Log message categorized by the given log level
202
+ /// <para>
203
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
204
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
205
+ /// </para>
206
+ /// </summary>
207
+ /// <param name="level">Log level of the message.</param>
208
+ /// <param name="exception">Exception to include with the logging.</param>
209
+ /// <param name="message">Message to log.</param>
210
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
211
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
212
+ void Log ( LogLevel level , Exception exception , string message , params object [ ] args ) => Log ( level . ToString ( ) , exception , message , args ) ;
213
+
214
+ /// <summary>
215
+ /// Log trace message.
216
+ /// <para>
217
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
218
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
219
+ /// </para>
220
+ /// </summary>
221
+ /// <param name="message">Message to log.</param>
222
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
223
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
224
+ void LogTrace ( string message , params object [ ] args ) => Log ( LogLevel . Trace . ToString ( ) , message , args ) ;
225
+
226
+ /// <summary>
227
+ /// Log trace message.
228
+ /// <para>
229
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
230
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
231
+ /// </para>
232
+ /// </summary>
233
+ /// <param name="exception">Exception to include with the logging.</param>
234
+ /// <param name="message">Message to log.</param>
235
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
236
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
237
+ void LogTrace ( Exception exception , string message , params object [ ] args ) => Log ( LogLevel . Trace . ToString ( ) , exception , message , args ) ;
238
+
239
+ /// <summary>
240
+ /// Log debug message.
241
+ /// <para>
242
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
243
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
244
+ /// </para>
245
+ /// </summary>
246
+ /// <param name="message">Message to log.</param>
247
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
248
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
249
+ void LogDebug ( string message , params object [ ] args ) => Log ( LogLevel . Debug . ToString ( ) , message , args ) ;
250
+
251
+ /// <summary>
252
+ /// Log debug message.
253
+ /// <para>
254
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
255
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
256
+ /// </para>
257
+ /// </summary>
258
+ /// <param name="exception">Exception to include with the logging.</param>
259
+ /// <param name="message">Message to log.</param>
260
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
261
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
262
+ void LogDebug ( Exception exception , string message , params object [ ] args ) => Log ( LogLevel . Debug . ToString ( ) , exception , message , args ) ;
263
+
264
+ /// <summary>
265
+ /// Log information message.
266
+ /// <para>
267
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
268
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
269
+ /// </para>
270
+ /// </summary>
271
+ /// <param name="message">Message to log.</param>
272
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
273
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
274
+ void LogInformation ( string message , params object [ ] args ) => Log ( LogLevel . Information . ToString ( ) , message , args ) ;
275
+
276
+ /// <summary>
277
+ /// Log information message.
278
+ /// <para>
279
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
280
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
281
+ /// </para>
282
+ /// </summary>
283
+ /// <param name="exception">Exception to include with the logging.</param>
284
+ /// <param name="message">Message to log.</param>
285
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
286
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
287
+ void LogInformation ( Exception exception , string message , params object [ ] args ) => Log ( LogLevel . Information . ToString ( ) , exception , message , args ) ;
288
+
289
+ /// <summary>
290
+ /// Log warning message.
291
+ /// <para>
292
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
293
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
294
+ /// </para>
295
+ /// </summary>
296
+ /// <param name="message">Message to log.</param>
297
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
298
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
299
+ void LogWarning ( string message , params object [ ] args ) => Log ( LogLevel . Warning . ToString ( ) , message , args ) ;
300
+
301
+ /// <summary>
302
+ /// Log warning message.
303
+ /// <para>
304
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
305
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
306
+ /// </para>
307
+ /// </summary>
308
+ /// <param name="exception">Exception to include with the logging.</param>
309
+ /// <param name="message">Message to log.</param>
310
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
311
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
312
+ void LogWarning ( Exception exception , string message , params object [ ] args ) => Log ( LogLevel . Warning . ToString ( ) , exception , message , args ) ;
313
+
314
+ /// <summary>
315
+ /// Log error message.
316
+ /// <para>
317
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
318
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
319
+ /// </para>
320
+ /// </summary>
321
+ /// <param name="message">Message to log.</param>
322
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
323
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
324
+ void LogError ( string message , params object [ ] args ) => Log ( LogLevel . Error . ToString ( ) , message , args ) ;
325
+
326
+ /// <summary>
327
+ /// Log error message.
328
+ /// <para>
329
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
330
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
331
+ /// </para>
332
+ /// </summary>
333
+ /// <param name="exception">Exception to include with the logging.</param>
334
+ /// <param name="message">Message to log.</param>
335
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
336
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
337
+ void LogError ( Exception exception , string message , params object [ ] args ) => Log ( LogLevel . Error . ToString ( ) , exception , message , args ) ;
338
+
339
+ /// <summary>
340
+ /// Log critical message.
341
+ /// <para>
342
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
343
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
344
+ /// </para>
345
+ /// </summary>
346
+ /// <param name="message">Message to log.</param>
347
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
348
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
349
+ void LogCritical ( string message , params object [ ] args ) => Log ( LogLevel . Critical . ToString ( ) , message , args ) ;
350
+
351
+ /// <summary>
352
+ /// Log critical message.
353
+ /// <para>
354
+ /// To configure the minimum log level set the AWS_LAMBDA_HANDLER_LOG_LEVEL environment variable. The value should be set
355
+ /// to one of the values in the LogLevel enumeration. The default minimum log level is "Information".
356
+ /// </para>
357
+ /// </summary>
358
+ /// <param name="exception">Exception to include with the logging.</param>
359
+ /// <param name="message">Message to log.</param>
360
+ /// <param name="args">Values to be replaced in log messages that are parameterized.</param>
361
+ [ RequiresPreviewFeatures ( ParameterizedPreviewMessage ) ]
362
+ void LogCritical ( Exception exception , string message , params object [ ] args ) => Log ( LogLevel . Critical . ToString ( ) , exception , message , args ) ;
363
+
145
364
#endif
146
365
147
366
}
0 commit comments