Skip to content

Commit

Permalink
Merge pull request #292 from aws/asmarp/master-fixup
Browse files Browse the repository at this point in the history
Fix dev and master sync up
  • Loading branch information
philasmar authored Dec 16, 2024
2 parents 168e52d + a2729db commit ec3931e
Show file tree
Hide file tree
Showing 22 changed files with 249 additions and 207 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Release 2024-12-16

### AWS.Logger.AspNetCore (3.5.4)
* Update package dependencies to address security vulnerabilities
### AWS.Logger.SeriLog (3.4.4)
* Update package dependencies to address security vulnerabilities

## Release 2024-05-22

### AWS.Logger.Core (3.3.3)
Expand Down
18 changes: 9 additions & 9 deletions test/AWS.Logger.AspNetCore.Tests/TestClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ private void LoggingSetup(string configFileName, string configSectionInfoBlockNa
/// 10 debug messages to CloudWatchLogs. The results are then verified.
/// </summary>
[Fact]
public void ILogger()
public async Task ILogger()
{
LoggingSetup("appsettings.json",null);
SimpleLoggingTest(ConfigSection.Config.LogGroup);
await SimpleLoggingTest(ConfigSection.Config.LogGroup);
}

[Fact]
Expand Down Expand Up @@ -129,10 +129,10 @@ public async Task MultiThreadTestMock()
/// threads that log 200 debug messages each to CloudWatchLogs. The results are then verified.
/// </summary>
[Fact]
public void MultiThreadTest()
public async Task MultiThreadTest()
{
LoggingSetup("multiThreadTest.json",null);
MultiThreadTestGroup(ConfigSection.Config.LogGroup);
await MultiThreadTestGroup(ConfigSection.Config.LogGroup);
}

/// <summary>
Expand All @@ -143,17 +143,17 @@ public void MultiThreadTest()
/// inorder to force a buffer full scenario. The results are then verified.
/// </summary>
[Fact]
public void MultiThreadBufferFullTest()
public async Task MultiThreadBufferFullTest()
{
LoggingSetup("multiThreadBufferFullTest.json",null);
MultiThreadBufferFullTestGroup(ConfigSection.Config.LogGroup);
await MultiThreadBufferFullTestGroup(ConfigSection.Config.LogGroup);
}

[Fact]
public void OverrideLogStreamNameTest()
public async Task OverrideLogStreamNameTest()
{
LoggingSetup("overrideLogStreamName.json", null);
MultiThreadTestGroup(ConfigSection.Config.LogGroup, ConfigSection.Config.LogStreamName);
await MultiThreadTestGroup(ConfigSection.Config.LogGroup, ConfigSection.Config.LogStreamName);
}

/// <summary>
Expand All @@ -165,7 +165,7 @@ protected override void LogMessages(int count)
Logger.LogError(0, new Exception("Exception message."), "Error message");
for (int i = 0; i < count-2; i++)
{
Logger.LogDebug(string.Format("Test logging message {0} Ilogger, Thread Id:{1}", i, Thread.CurrentThread.ManagedThreadId));
Logger.LogDebug(string.Format("Test logging message {0} Ilogger, Thread Id:{1}", i, Environment.CurrentManagedThreadId));
}
Logger.LogDebug(LASTMESSAGE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- A1 is set to be a ConsoleAppender -->
<appender name="MultiThreadBufferFullTest" type="AWS.Logger.Log4net.AWSAppender,AWS.Logger.Log4net" >

<LogGroup>AWSLog4NetGroupMultiThreadBufferFullTest</LogGroup>
<LogGroup>{LOG_GROUP_NAME}</LogGroup>
<Region>us-west-2</Region>
<MaxQueuedMessages>10</MaxQueuedMessages>

Expand Down
2 changes: 1 addition & 1 deletion test/AWS.Logger.Log4Net.Tests/MultiThreadTest.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- A1 is set to be a ConsoleAppender -->
<appender name="MultiThreadTest" type="AWS.Logger.Log4net.AWSAppender,AWS.Logger.Log4net" >

<LogGroup>AWSLog4NetGroupLog4NetMultiThreadTest</LogGroup>
<LogGroup>{LOG_GROUP_NAME}</LogGroup>
<Region>us-west-2</Region>

<layout type="log4net.Layout.PatternLayout">
Expand Down
2 changes: 1 addition & 1 deletion test/AWS.Logger.Log4Net.Tests/OverrideLogStreamName.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!-- A1 is set to be a ConsoleAppender -->
<appender name="OverrideLogStreamName" type="AWS.Logger.Log4net.AWSAppender,AWS.Logger.Log4net" >

<LogGroup>AWSLog4NetGroupOverrideLogStreamName</LogGroup>
<LogGroup>{LOG_GROUP_NAME}</LogGroup>
<LogStreamName>CustomStreamName</LogStreamName>
<Region>us-west-2</Region>
<LogStreamNameSuffix>Custom</LogStreamNameSuffix> <!-- should be ignored since LogStreamName is set -->
Expand Down
2 changes: 2 additions & 0 deletions test/AWS.Logger.Log4Net.Tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: Xunit.CollectionBehavior(DisableTestParallelization = true)]
46 changes: 30 additions & 16 deletions test/AWS.Logger.Log4Net.Tests/TestClass.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using AWS.Logger.Log4net;
using AWS.Logger.TestUtils;
using log4net;
using log4net.Config;
Expand All @@ -12,13 +17,18 @@ public class Log4NetTestClass : BaseTestClass
{
public ILog Logger;

private void GetLog4NetLogger(string fileName, string logName)
private void GetLog4NetLogger(string fileName, string logName, string logGroupName)
{
// Create logger
var repositoryAssembly = typeof(Log4NetTestClass).GetTypeInfo().Assembly;
var loggerRepository = LogManager.GetRepository(repositoryAssembly);
XmlConfigurator.Configure(loggerRepository, new System.IO.FileInfo(fileName));
Logger = LogManager.GetLogger(repositoryAssembly, logName);
var fileInfo = new FileInfo(fileName);
var fileContent = File.ReadAllText(fileInfo.FullName);
using (Stream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(fileContent.Replace("{LOG_GROUP_NAME}", logGroupName))))
{
XmlConfigurator.Configure(loggerRepository, memoryStream);
Logger = LogManager.GetLogger(repositoryAssembly, logName);
}
}

public Log4NetTestClass(TestFixture testFixture) : base(testFixture)
Expand All @@ -27,42 +37,46 @@ public Log4NetTestClass(TestFixture testFixture) : base(testFixture)

#region Test Cases
[Fact]
public void Log4Net()
public async Task Log4Net()
{
GetLog4NetLogger("log4net.config","Log4Net");
SimpleLoggingTest("AWSLog4NetGroupLog4Net");
var logGroupName = $"AWSLog4NetGroupLog4Net{Guid.NewGuid().ToString().Split('-').Last()}";
GetLog4NetLogger("log4net.config","Log4Net", logGroupName);
await SimpleLoggingTest(logGroupName);
}

[Fact]
public void MultiThreadTest()
public async Task MultiThreadTest()
{
GetLog4NetLogger("MultiThreadTest.config", "MultiThreadTest");
MultiThreadTestGroup("AWSLog4NetGroupLog4NetMultiThreadTest");
var logGroupName = $"AWSLog4NetGroupLog4NetMultiThreadTest{Guid.NewGuid().ToString().Split('-').Last()}";
GetLog4NetLogger("MultiThreadTest.config", "MultiThreadTest", logGroupName);
await MultiThreadTestGroup(logGroupName);
}

[Fact]
public void MultiThreadBufferFullTest()
public async Task MultiThreadBufferFullTest()
{
GetLog4NetLogger("MultiThreadBufferFullTest.config", "MultiThreadBufferFullTest");
MultiThreadBufferFullTestGroup("AWSLog4NetGroupMultiThreadBufferFullTest");
var logGroupName = $"AWSLog4NetGroupMultiThreadBufferFullTest{Guid.NewGuid().ToString().Split('-').Last()}";
GetLog4NetLogger("MultiThreadBufferFullTest.config", "MultiThreadBufferFullTest", logGroupName);
await MultiThreadBufferFullTestGroup(logGroupName);
}

/// <summary>
/// Verifies that multiple producers can log to the same log stream
/// when an override log stream name is provided
/// </summary>
[Fact]
public void CustomLogStreamNameTest()
public async Task CustomLogStreamNameTest()
{
GetLog4NetLogger("OverrideLogStreamName.config", "OverrideLogStreamName");
MultiThreadTestGroup("AWSLog4NetGroupOverrideLogStreamName");
var logGroupName = $"AWSLog4NetGroupMultiThreadBufferFullTest{Guid.NewGuid().ToString().Split('-').Last()}";
GetLog4NetLogger("OverrideLogStreamName.config", "OverrideLogStreamName", logGroupName);
await MultiThreadTestGroup(logGroupName);
}

protected override void LogMessages(int count)
{
for (int i = 0; i < count-1; i++)
{
Logger.Debug(string.Format("Test logging message {0} Log4Net, Thread Id:{1}", i, Thread.CurrentThread.ManagedThreadId));
Logger.Debug(string.Format("Test logging message {0} Log4Net, Thread Id:{1}", i, Environment.CurrentManagedThreadId));
}
Logger.Debug(LASTMESSAGE);
}
Expand Down
2 changes: 1 addition & 1 deletion test/AWS.Logger.Log4Net.Tests/log4net.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!-- A1 is set to be a ConsoleAppender -->
<appender name="AWS" type="AWS.Logger.Log4net.AWSAppender,AWS.Logger.Log4net" >

<LogGroup>AWSLog4NetGroupLog4Net</LogGroup>
<LogGroup>{LOG_GROUP_NAME}</LogGroup>
<Region>us-west-2</Region>
<LogStreamNameSuffix>Custom</LogStreamNameSuffix>
<LogStreamNamePrefix>CustomPrefix</LogStreamNamePrefix>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<add assembly ="NLog.AWS.Logger"/>
</extensions>
<targets>
<target name="AWSNLogGroupEventSizeExceededTest" type="AWSTarget" logGroup="AWSNLogGroupEventSizeExceededTest" region="us-west-2" logStreamNameSuffix="Custom"/>
<target name="{LOG_GROUP_NAME}" type="AWSTarget" logGroup="{LOG_GROUP_NAME}" region="us-west-2" logStreamNameSuffix="Custom"/>
<target name="loggerRegular" xsi:type="Console" layout="${callsite} ${message}" />
</targets>
<rules>
<logger name="loggerRegularEventSizeExceeded" minlevel="Debug" writeTo="loggerRegular,AWSNLogGroupEventSizeExceededTest"/>
<logger name="loggerRegularEventSizeExceeded" minlevel="Debug" writeTo="loggerRegular,{LOG_GROUP_NAME}"/>
</rules>
</nlog>
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<add assembly ="NLog.AWS.Logger"/>
</extensions>
<targets>
<target name="AWSNLogGroupMultiThreadBufferFullTest" type="AWSTarget" logGroup="AWSNLogGroupMultiThreadBufferFullTest" region="us-west-2" MaxQueuedMessages="10"/>
<target name="{LOG_GROUP_NAME}" type="AWSTarget" logGroup="{LOG_GROUP_NAME}" region="us-west-2" MaxQueuedMessages="10"/>
<target name="loggerRegular" xsi:type="Console" layout="${callsite} ${message}" />
</targets>
<rules>
<logger name="loggerMultiThreadBufferFull" minlevel="Debug" writeTo="loggerRegular,AWSNLogGroupMultiThreadBufferFullTest" />
<logger name="loggerMultiThreadBufferFull" minlevel="Debug" writeTo="loggerRegular,{LOG_GROUP_NAME}" />
</rules>
</nlog>
4 changes: 2 additions & 2 deletions test/AWS.Logger.NLog.Tests/AWSNLogGroupMultiThreadTest.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<add assembly ="NLog.AWS.Logger"/>
</extensions>
<targets>
<target name="AWSNLogGroupMultiThreadTest" type="AWSTarget" logGroup="AWSNLogGroupMultiThreadTest" region="us-west-2"/>
<target name="{LOG_GROUP_NAME}" type="AWSTarget" logGroup="{LOG_GROUP_NAME}" region="us-west-2"/>
<target name="loggerRegular" xsi:type="Console" layout="${callsite} ${message}" />
</targets>
<rules>
<logger name="loggerMultiThread" minlevel="Debug" writeTo="loggerRegular,AWSNLogGroupMultiThreadTest" />
<logger name="loggerMultiThread" minlevel="Debug" writeTo="loggerRegular,{LOG_GROUP_NAME}" />
</rules>
</nlog>
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<add assembly ="NLog.AWS.Logger"/>
</extensions>
<targets>
<target name="AWSNLogOverrideLogStreamName" type="AWSTarget" logGroup="AWSNLogOverrideLogStreamName" region="us-west-2" logStreamNameSuffix="Custom" logStreamNamePrefix="CustomPrefix" logStreamName="CustomStreamName"/>
<target name="{LOG_GROUP_NAME}" type="AWSTarget" logGroup="{LOG_GROUP_NAME}" region="us-west-2" logStreamNameSuffix="Custom" logStreamNamePrefix="CustomPrefix" logStreamName="CustomStreamName"/>
<target name="overrideLogStreamName" xsi:type="Console" layout="${callsite} ${message}" />
</targets>
<rules>
<logger name="overrideLogStreamName" minlevel="Debug" writeTo="overrideLogStreamName,AWSNLogOverrideLogStreamName"/>
<logger name="overrideLogStreamName" minlevel="Debug" writeTo="overrideLogStreamName,{LOG_GROUP_NAME}"/>
</rules>
</nlog>
4 changes: 2 additions & 2 deletions test/AWS.Logger.NLog.Tests/Regular.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<add assembly ="NLog.AWS.Logger"/>
</extensions>
<targets>
<target name="AWSNLogGroup" type="AWSTarget" logGroup="AWSNLogGroup" region="us-west-2" logStreamNameSuffix="Custom" logStreamNamePrefix="CustomPrefix"/>
<target name="{LOG_GROUP_NAME}" type="AWSTarget" logGroup="{LOG_GROUP_NAME}" region="us-west-2" logStreamNameSuffix="Custom" logStreamNamePrefix="CustomPrefix"/>
<target name="loggerRegular" xsi:type="Console" layout="${callsite} ${message}" />
</targets>
<rules>
<logger name="loggerRegular" minlevel="Debug" writeTo="loggerRegular,AWSNLogGroup"/>
<logger name="loggerRegular" minlevel="Debug" writeTo="loggerRegular,{LOG_GROUP_NAME}"/>
</rules>
</nlog>
Loading

0 comments on commit ec3931e

Please sign in to comment.