You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by fr...@apache.org on 2024/10/15 09:11:40 UTC
(logging-log4net) branch Feature/TelnetBug updated (cf1aa74d -> 187d319a)
This is an automated email from the ASF dual-hosted git repository.
freeandnil pushed a change to branch Feature/TelnetBug
in repository https://gitbox.apache.org/repos/asf/logging-log4net.git
discard cf1aa74d fixed telnet test
discard 218c8f9b fixed telnet test
discard 6acd036c Test for telnet bug
add bba60f4e fixed encoding (UTF-16 to UTF-8 BOM)
add 79b57e5e added unit test for #193
add 8f3c3d4e update jquery to v1.12.4 fixes https://github.com/apache/logging-log4net/security/dependabot/45 & https://github.com/apache/logging-log4net/security/dependabot/46
new 7ad3c2c0 Test for telnet bug
new 5f0103ef fixed telnet test
new 187d319a fixed telnet test
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (cf1aa74d)
\
N -- N -- N refs/heads/Feature/TelnetBug (187d319a)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
doc/MailTemplate.Announce.txt | Bin 876 -> 427 bytes
doc/MailTemplate.Result.txt | Bin 824 -> 400 bytes
doc/MailTemplate.txt | Bin 1742 -> 850 bytes
src/log4net.Tests/Appender/FileAppenderTest.cs | 48 +
src/site/resources/js/jquery.js | 15394 +++++++++++++----------
src/site/resources/js/jquery.min.js | 9 +-
6 files changed, 8621 insertions(+), 6830 deletions(-)
(logging-log4net) 01/03: Test for telnet bug
Posted by fr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
freeandnil pushed a commit to branch Feature/TelnetBug
in repository https://gitbox.apache.org/repos/asf/logging-log4net.git
commit 7ad3c2c09d40babb8d59e08c2d6b8a87ea91bbf2
Author: Jan Friedrich <fr...@apache.org>
AuthorDate: Sun Oct 13 13:58:08 2024 +0200
Test for telnet bug
---
.../Appender/Internal/SimpleTelnetClient.cs | 34 ++++++++++
src/log4net.Tests/Appender/TelnetAppenderTest.cs | 74 ++++++++++++++++++++++
2 files changed, 108 insertions(+)
diff --git a/src/log4net.Tests/Appender/Internal/SimpleTelnetClient.cs b/src/log4net.Tests/Appender/Internal/SimpleTelnetClient.cs
new file mode 100644
index 00000000..8feddc49
--- /dev/null
+++ b/src/log4net.Tests/Appender/Internal/SimpleTelnetClient.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Net;
+using System.Net.Sockets;
+
+namespace log4net.Tests.Appender.Internal
+{
+ internal sealed class SimpleTelnetClient(Action<string> received, int port = 9090)
+ {
+ internal void Run()
+ {
+ TcpClient client = new("localhost", port);
+ try
+ {
+ // Get a stream object for reading and writing
+ using NetworkStream stream = client.GetStream();
+
+ int i;
+ byte[] bytes = new byte[256];
+
+ // Loop to receive all the data sent by the server
+ while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
+ {
+ string data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
+ received(data);
+ }
+ }
+ finally
+ {
+ client.Dispose();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/log4net.Tests/Appender/TelnetAppenderTest.cs b/src/log4net.Tests/Appender/TelnetAppenderTest.cs
new file mode 100644
index 00000000..626ae65b
--- /dev/null
+++ b/src/log4net.Tests/Appender/TelnetAppenderTest.cs
@@ -0,0 +1,74 @@
+#region Apache License
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to you under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Xml;
+using log4net.Appender;
+using log4net.Config;
+using log4net.Core;
+using log4net.Repository;
+using log4net.Tests.Appender.Internal;
+using NUnit.Framework;
+
+namespace log4net.Tests.Appender;
+
+/// <summary>
+/// Tests for <see cref="TelnetAppender"/>
+/// </summary>
+[TestFixture]
+public class TelnetAppenderTest
+{
+ /// <summary>
+ /// https://stackoverflow.com/questions/79053363/log4net-telnetappender-doesnt-work-after-migrate-to-log4net-3
+ /// </summary>
+ [Test]
+ public void TelnetTest()
+ {
+ List<string> received = [];
+
+ XmlDocument log4netConfig = new();
+ log4netConfig.LoadXml("""
+ <log4net>
+ <appender name="TelnetAppender" type="log4net.Appender.TelnetAppender">
+ <port value="9090" />
+ <layout type="log4net.Layout.PatternLayout">
+ <conversionPattern value="%date{HH:mm:ss.fff} %-5level - %message%newline" />
+ </layout>
+ </appender>
+ <root>
+ <level value="INFO"/>
+ <appender-ref ref="TelnetAppender"/>
+ </root>
+ </log4net>
+""");
+ ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
+ XmlConfigurator.Configure(rep, log4netConfig["log4net"]!);
+ Task task = Task.Run(() => new SimpleTelnetClient(Received).Run());
+ task.Wait(500);
+
+ rep.GetLogger("Telnet").Log(typeof(TelnetAppenderTest), Level.Info, "Log-Message", null);
+
+ Assert.AreEqual(1, received.Count);
+
+ void Received(string message) => received.Add(message);
+ }
+}
\ No newline at end of file
(logging-log4net) 02/03: fixed telnet test
Posted by fr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
freeandnil pushed a commit to branch Feature/TelnetBug
in repository https://gitbox.apache.org/repos/asf/logging-log4net.git
commit 5f0103ef2c8ea1bb0a81703990203f74f7beb89e
Author: Jan Friedrich <fr...@apache.org>
AuthorDate: Sun Oct 13 20:44:14 2024 +0200
fixed telnet test
---
.../Appender/Internal/SimpleTelnetClient.cs | 38 +++++++++++++---------
src/log4net.Tests/Appender/TelnetAppenderTest.cs | 21 +++++++++---
2 files changed, 38 insertions(+), 21 deletions(-)
diff --git a/src/log4net.Tests/Appender/Internal/SimpleTelnetClient.cs b/src/log4net.Tests/Appender/Internal/SimpleTelnetClient.cs
index 8feddc49..619c9c05 100644
--- a/src/log4net.Tests/Appender/Internal/SimpleTelnetClient.cs
+++ b/src/log4net.Tests/Appender/Internal/SimpleTelnetClient.cs
@@ -2,33 +2,39 @@ using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
+using System.Threading.Tasks;
namespace log4net.Tests.Appender.Internal
{
- internal sealed class SimpleTelnetClient(Action<string> received, int port = 9090)
+ internal sealed class SimpleTelnetClient(
+ Action<string> received, TaskCompletionSource<int> taskCompletionSource, int port = 9090): IDisposable
{
+ private readonly TcpClient client = new("localhost", port);
+
internal void Run()
{
- TcpClient client = new("localhost", port);
- try
- {
- // Get a stream object for reading and writing
- using NetworkStream stream = client.GetStream();
+ // Get a stream object for reading and writing
+ using NetworkStream stream = client.GetStream();
- int i;
- byte[] bytes = new byte[256];
+ int i;
+ byte[] bytes = new byte[256];
- // Loop to receive all the data sent by the server
- while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
+ bool wasResultSet = false;
+ // Loop to receive all the data sent by the server
+ while ((i = stream.Read(bytes, 0, bytes.Length)) != 0)
+ {
+ if (!wasResultSet)
{
- string data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
- received(data);
+ taskCompletionSource.SetResult(0);
+ wasResultSet = true;
}
- }
- finally
- {
- client.Dispose();
+
+ string data = System.Text.Encoding.ASCII.GetString(bytes, 0, i);
+ received(data);
}
}
+
+ /// <inheritdoc/>
+ public void Dispose() => client.Dispose();
}
}
\ No newline at end of file
diff --git a/src/log4net.Tests/Appender/TelnetAppenderTest.cs b/src/log4net.Tests/Appender/TelnetAppenderTest.cs
index 626ae65b..9790077f 100644
--- a/src/log4net.Tests/Appender/TelnetAppenderTest.cs
+++ b/src/log4net.Tests/Appender/TelnetAppenderTest.cs
@@ -20,6 +20,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using log4net.Appender;
@@ -62,12 +63,22 @@ public class TelnetAppenderTest
""");
ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
XmlConfigurator.Configure(rep, log4netConfig["log4net"]!);
- Task task = Task.Run(() => new SimpleTelnetClient(Received).Run());
- task.Wait(500);
-
- rep.GetLogger("Telnet").Log(typeof(TelnetAppenderTest), Level.Info, "Log-Message", null);
+ TaskCompletionSource<int> startup = new();
+ using SimpleTelnetClient telnetClient = new(Received, startup);
+ Task.Run(() => telnetClient.Run());
+ startup.Task.Wait();
+ var logger = rep.GetLogger("Telnet");
+ while (received.Count < 1)
+ {
+ Thread.Sleep(10);
+ }
+ logger.Log(typeof(TelnetAppenderTest), Level.Info, "Log-Message", null);
- Assert.AreEqual(1, received.Count);
+ while (received.Count < 2)
+ {
+ Thread.Sleep(10);
+ }
+ Assert.AreEqual(2, received.Count);
void Received(string message) => received.Add(message);
}
(logging-log4net) 03/03: fixed telnet test
Posted by fr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
freeandnil pushed a commit to branch Feature/TelnetBug
in repository https://gitbox.apache.org/repos/asf/logging-log4net.git
commit 187d319ae6441e8347bd99785626805fdc0fc0aa
Author: Jan Friedrich <fr...@apache.org>
AuthorDate: Sun Oct 13 20:50:46 2024 +0200
fixed telnet test
---
src/log4net.Tests/Appender/TelnetAppenderTest.cs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/log4net.Tests/Appender/TelnetAppenderTest.cs b/src/log4net.Tests/Appender/TelnetAppenderTest.cs
index 9790077f..9a910ae3 100644
--- a/src/log4net.Tests/Appender/TelnetAppenderTest.cs
+++ b/src/log4net.Tests/Appender/TelnetAppenderTest.cs
@@ -68,6 +68,7 @@ public class TelnetAppenderTest
Task.Run(() => telnetClient.Run());
startup.Task.Wait();
var logger = rep.GetLogger("Telnet");
+ // wait for welcome message
while (received.Count < 1)
{
Thread.Sleep(10);
@@ -79,6 +80,7 @@ public class TelnetAppenderTest
Thread.Sleep(10);
}
Assert.AreEqual(2, received.Count);
+ StringAssert.Contains("Log-Message", received[1]);
void Received(string message) => received.Add(message);
}