Skip to content

Commit 8647a46

Browse files
committed
Address PR comments
1 parent 6e4d92c commit 8647a46

4 files changed

Lines changed: 55 additions & 5 deletions

File tree

.autover/changes/16cc3c6a-8fa0-410b-ba57-74221abb086a.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
},
3131
{
3232
"Name": "Amazon.Lambda.Logging.AspNetCore",
33-
"Type": "Minor",
33+
"Type": "Major",
3434
"ChangelogMessages": [
3535
"Add support Lambda log levels",
3636
"Change build target from .NET Standard 2.0 to .NET 6 and NET 8 to match Amazon.Lambda.AspNetCoreServer"
3737
]
3838
},
3939
{
4040
"Name": "Amazon.Lambda.TestUtilities",
41-
"Type": "Minor",
41+
"Type": "Major",
4242
"ChangelogMessages": [
4343
"Update Amazon.Lambda.TestUtitlies to have implementation of the newer logging methods",
4444
"Change build target from .NET Standard 2.0 to .NET 6 and NET 8 to match Amazon.Lambda.AspNetCoreServer"

Libraries/src/Amazon.Lambda.Logging.AspNetCore/LambdaILogger.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,18 @@ public bool IsEnabled(LogLevel logLevel)
2828
_options.Filter == null ||
2929
_options.Filter(_categoryName, logLevel));
3030
}
31-
31+
32+
/// <summary>
33+
/// The Log method called by the ILogger framework to log message to logger's target. In the Lambda case the formatted logging will be
34+
/// sent to the Amazon.Lambda.Core.LambdaLogger's Log method.
35+
/// </summary>
36+
/// <typeparam name="TState"></typeparam>
37+
/// <param name="logLevel"></param>
38+
/// <param name="eventId"></param>
39+
/// <param name="state"></param>
40+
/// <param name="exception"></param>
41+
/// <param name="formatter"></param>
42+
/// <exception cref="ArgumentNullException"></exception>
3243
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
3344
{
3445
if (formatter == null)
@@ -41,8 +52,6 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
4152
return;
4253
}
4354

44-
var lambdaLogLevel = ConvertLogLevel(logLevel);
45-
4655
var components = new List<string>(4);
4756
if (_options.IncludeLogLevel)
4857
{
@@ -74,6 +83,7 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
7483

7584
var finalText = string.Join(" ", components);
7685

86+
var lambdaLogLevel = ConvertLogLevel(logLevel);
7787
Amazon.Lambda.Core.LambdaLogger.Log(lambdaLogLevel, finalText);
7888
}
7989

Libraries/src/Amazon.Lambda.RuntimeSupport/Bootstrap/UserCodeLoader.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ public void Invoke(Stream lambdaData, ILambdaContext lambdaContext, Stream outSt
150150
_invokeDelegate(lambdaData, lambdaContext, outStream);
151151
}
152152

153+
/// <summary>
154+
/// Sets the backing logger action field in Amazon.Logging.Core to redirect logs into Amazon.Lambda.RuntimeSupport.
155+
/// </summary>
156+
/// <param name="coreAssembly"></param>
157+
/// <param name="customerLoggingAction"></param>
158+
/// <param name="internalLogger"></param>
159+
/// <exception cref="ArgumentNullException"></exception>
153160
internal static void SetCustomerLoggerLogAction(Assembly coreAssembly, Action<string> customerLoggingAction, InternalLogger internalLogger)
154161
{
155162
if (coreAssembly == null)
@@ -188,6 +195,14 @@ internal static void SetCustomerLoggerLogAction(Assembly coreAssembly, Action<st
188195
}
189196
}
190197

198+
/// <summary>
199+
/// Sets the backing logger action field in Amazon.Logging.Core to redirect logs into Amazon.Lambda.RuntimeSupport.
200+
/// </summary>
201+
/// <param name="coreAssembly"></param>
202+
/// <param name="loggingWithLevelAction"></param>
203+
/// <param name="internalLogger"></param>
204+
/// <exception cref="ArgumentNullException"></exception>
205+
191206
internal static void SetCustomerLoggerLogAction(Assembly coreAssembly, Action<string, string, object[]> loggingWithLevelAction, InternalLogger internalLogger)
192207
{
193208
if (coreAssembly == null)
@@ -226,6 +241,13 @@ internal static void SetCustomerLoggerLogAction(Assembly coreAssembly, Action<st
226241
}
227242
}
228243

244+
/// <summary>
245+
/// Sets the backing logger action field in Amazon.Logging.Core to redirect logs into Amazon.Lambda.RuntimeSupport.
246+
/// </summary>
247+
/// <param name="coreAssembly"></param>
248+
/// <param name="loggingWithAndExceptionLevelAction"></param>
249+
/// <param name="internalLogger"></param>
250+
/// <exception cref="ArgumentNullException"></exception>
229251
internal static void SetCustomerLoggerLogAction(Assembly coreAssembly, Action<string, Exception, string, object[]> loggingWithAndExceptionLevelAction, InternalLogger internalLogger)
230252
{
231253
if (coreAssembly == null)

Libraries/src/Amazon.Lambda.TestUtilities/TestLambdaLogger.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,24 @@ public void LogLine(string message)
3838
Console.WriteLine(message);
3939
}
4040

41+
/// <summary>
42+
/// Write log messages to the console and the Buffer.
43+
/// </summary>
44+
/// <param name="level"></param>
45+
/// <param name="message"></param>
4146
public void Log(string level, string message)
4247
{
4348
var formmattedString = $"{level}: {message}";
4449
Buffer.AppendLine(formmattedString);
4550
Console.WriteLine(formmattedString);
4651
}
4752

53+
/// <summary>
54+
/// Write log messages to the console and the Buffer.
55+
/// </summary>
56+
/// <param name="level"></param>
57+
/// <param name="message"></param>
58+
/// <param name="args"></param>
4859
public void Log(string level, string message, params object[] args)
4960
{
5061
var builder = new StringBuilder();
@@ -63,6 +74,13 @@ public void Log(string level, string message, params object[] args)
6374
Console.WriteLine(formmattedString);
6475
}
6576

77+
/// <summary>
78+
/// Write log messages to the console and the Buffer.
79+
/// </summary>
80+
/// <param name="level"></param>
81+
/// <param name="exception"></param>
82+
/// <param name="message"></param>
83+
/// <param name="args"></param>
6684
public void Log(string level, Exception exception, string message, params object[] args)
6785
{
6886
var builder = new StringBuilder();

0 commit comments

Comments
 (0)