From ea29f17ed045e43d63fcf84be537158896923147 Mon Sep 17 00:00:00 2001 From: Andrei Chasovskikh Date: Wed, 26 Apr 2023 10:25:17 +0200 Subject: [PATCH 1/3] Add Peek() method to ThreadContextStack and LogicalThreadContextStack. --- src/log4net/Util/LogicalThreadContextStack.cs | 36 ++++++++++++++----- src/log4net/Util/ThreadContextStack.cs | 20 +++++++++++ 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/log4net/Util/LogicalThreadContextStack.cs b/src/log4net/Util/LogicalThreadContextStack.cs index 005b6c1f0..6496db9bc 100644 --- a/src/log4net/Util/LogicalThreadContextStack.cs +++ b/src/log4net/Util/LogicalThreadContextStack.cs @@ -198,15 +198,35 @@ public IDisposable Push(string message) return new AutoPopStackFrame(contextStack, stack.Count - 1); } - #endregion Public Methods - - #region Internal Methods + /// + /// Returns the top context from this stack. + /// + /// The message in the context from the top of this stack. + /// + /// + /// Returns the top context from this stack. If this stack is empty then an + /// empty string (not ) is returned. + /// + /// + public string Peek() + { + Stack stack = m_stack; + if (stack.Count > 0) + { + return ((StackFrame)stack.Peek()).Message; + } + return ""; + } + + #endregion Public Methods + + #region Internal Methods - /// - /// Gets the current context information for this stack. - /// - /// The current context information. - internal string GetFullMessage() + /// + /// Gets the current context information for this stack. + /// + /// The current context information. + internal string GetFullMessage() { Stack stack = m_stack; if (stack.Count > 0) diff --git a/src/log4net/Util/ThreadContextStack.cs b/src/log4net/Util/ThreadContextStack.cs index d723dca44..468efa2f7 100644 --- a/src/log4net/Util/ThreadContextStack.cs +++ b/src/log4net/Util/ThreadContextStack.cs @@ -159,6 +159,26 @@ public IDisposable Push(string message) return new AutoPopStackFrame(stack, stack.Count - 1); } + /// + /// Returns the top context from this stack. + /// + /// The message in the context from the top of this stack. + /// + /// + /// Returns the top context from this stack. If this stack is empty then an + /// empty string (not ) is returned. + /// + /// + public string Peek() + { + Stack stack = m_stack; + if (stack.Count > 0) + { + return ((StackFrame)stack.Peek()).Message; + } + return ""; + } + #endregion Public Methods #region Internal Methods From eb9ea3ffe04f2bc32cd57160fc95c46dd605796b Mon Sep 17 00:00:00 2001 From: Andrei Chasovskikh Date: Wed, 26 Apr 2023 10:43:11 +0200 Subject: [PATCH 2/3] Use tabs. --- src/log4net/Util/LogicalThreadContextStack.cs | 72 +++++++++---------- src/log4net/Util/ThreadContextStack.cs | 36 +++++----- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/log4net/Util/LogicalThreadContextStack.cs b/src/log4net/Util/LogicalThreadContextStack.cs index 6496db9bc..29597b381 100644 --- a/src/log4net/Util/LogicalThreadContextStack.cs +++ b/src/log4net/Util/LogicalThreadContextStack.cs @@ -26,16 +26,16 @@ namespace log4net.Util { - /// + /// /// Delegate type used for LogicalThreadContextStack's callbacks. /// - #if NET_2_0 || MONO_2_0 || NETSTANDARD + #if NET_2_0 || MONO_2_0 || NETSTANDARD public delegate void TwoArgAction(T1 t1, T2 t2); - #else + #else public delegate void TwoArgAction(string t1, LogicalThreadContextStack t2); - #endif + #endif - /// + /// /// Implementation of Stack for the /// /// @@ -65,7 +65,7 @@ public sealed class LogicalThreadContextStack : IFixingRequired /// #if NET_2_0 || MONO_2_0 || NETSTANDARD private TwoArgAction m_registerNew; - #else + #else private TwoArgAction m_registerNew; #endif @@ -83,7 +83,7 @@ public sealed class LogicalThreadContextStack : IFixingRequired /// #if NET_2_0 || MONO_2_0 || NETSTANDARD internal LogicalThreadContextStack(string propertyKey, TwoArgAction registerNew) - #else + #else internal LogicalThreadContextStack(string propertyKey, TwoArgAction registerNew) #endif { @@ -198,35 +198,35 @@ public IDisposable Push(string message) return new AutoPopStackFrame(contextStack, stack.Count - 1); } - /// - /// Returns the top context from this stack. - /// - /// The message in the context from the top of this stack. - /// - /// - /// Returns the top context from this stack. If this stack is empty then an - /// empty string (not ) is returned. - /// - /// - public string Peek() - { - Stack stack = m_stack; - if (stack.Count > 0) - { - return ((StackFrame)stack.Peek()).Message; - } - return ""; - } - - #endregion Public Methods - - #region Internal Methods - - /// - /// Gets the current context information for this stack. - /// - /// The current context information. - internal string GetFullMessage() + /// + /// Returns the top context from this stack. + /// + /// The message in the context from the top of this stack. + /// + /// + /// Returns the top context from this stack. If this stack is empty then an + /// empty string (not ) is returned. + /// + /// + public string Peek() + { + Stack stack = m_stack; + if (stack.Count > 0) + { + return ((StackFrame)stack.Peek()).Message; + } + return ""; + } + + #endregion Public Methods + + #region Internal Methods + + /// + /// Gets the current context information for this stack. + /// + /// The current context information. + internal string GetFullMessage() { Stack stack = m_stack; if (stack.Count > 0) diff --git a/src/log4net/Util/ThreadContextStack.cs b/src/log4net/Util/ThreadContextStack.cs index 468efa2f7..53d6fbae5 100644 --- a/src/log4net/Util/ThreadContextStack.cs +++ b/src/log4net/Util/ThreadContextStack.cs @@ -159,25 +159,25 @@ public IDisposable Push(string message) return new AutoPopStackFrame(stack, stack.Count - 1); } - /// - /// Returns the top context from this stack. - /// - /// The message in the context from the top of this stack. - /// - /// - /// Returns the top context from this stack. If this stack is empty then an - /// empty string (not ) is returned. - /// - /// - public string Peek() + /// + /// Returns the top context from this stack. + /// + /// The message in the context from the top of this stack. + /// + /// + /// Returns the top context from this stack. If this stack is empty then an + /// empty string (not ) is returned. + /// + /// + public string Peek() { - Stack stack = m_stack; - if (stack.Count > 0) - { - return ((StackFrame)stack.Peek()).Message; - } - return ""; - } + Stack stack = m_stack; + if (stack.Count > 0) + { + return ((StackFrame)stack.Peek()).Message; + } + return ""; + } #endregion Public Methods From 3899635104f40f0d9fbeea25008e4d237a05f7c1 Mon Sep 17 00:00:00 2001 From: Andrei Chasovskikh Date: Wed, 26 Apr 2023 10:47:37 +0200 Subject: [PATCH 3/3] Tab fixes. --- src/log4net/Util/LogicalThreadContextStack.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/log4net/Util/LogicalThreadContextStack.cs b/src/log4net/Util/LogicalThreadContextStack.cs index 29597b381..dbad39a20 100644 --- a/src/log4net/Util/LogicalThreadContextStack.cs +++ b/src/log4net/Util/LogicalThreadContextStack.cs @@ -35,7 +35,7 @@ namespace log4net.Util public delegate void TwoArgAction(string t1, LogicalThreadContextStack t2); #endif - /// + /// /// Implementation of Stack for the /// /// @@ -65,7 +65,7 @@ public sealed class LogicalThreadContextStack : IFixingRequired /// #if NET_2_0 || MONO_2_0 || NETSTANDARD private TwoArgAction m_registerNew; - #else + #else private TwoArgAction m_registerNew; #endif @@ -83,7 +83,7 @@ public sealed class LogicalThreadContextStack : IFixingRequired /// #if NET_2_0 || MONO_2_0 || NETSTANDARD internal LogicalThreadContextStack(string propertyKey, TwoArgAction registerNew) - #else + #else internal LogicalThreadContextStack(string propertyKey, TwoArgAction registerNew) #endif {