Author: bodewig
Date: Sun Apr 5 10:11:47 2015
New Revision: 1671382
URL: http://svn.apache.org/r1671382
Log:
re-indent selected files using VS2012's default settings
Modified:
logging/log4net/trunk/src/log4net.Tests/Appender/AsyncAppenderTest.cs
logging/log4net/trunk/src/log4net/Appender/AsyncAppender.cs
logging/log4net/trunk/src/log4net/Repository/Hierarchy/XmlHierarchyConfigurator.cs
Modified: logging/log4net/trunk/src/log4net.Tests/Appender/AsyncAppenderTest.cs
URL:
http://svn.apache.org/viewvc/logging/log4net/trunk/src/log4net.Tests/Appender/AsyncAppenderTest.cs?rev=1671382&r1=1671381&r2=1671382&view=diff
==============================================================================
--- logging/log4net/trunk/src/log4net.Tests/Appender/AsyncAppenderTest.cs
(original)
+++ logging/log4net/trunk/src/log4net.Tests/Appender/AsyncAppenderTest.cs Sun
Apr 5 10:11:47 2015
@@ -30,13 +30,15 @@ namespace log4net.Tests.Appender
{
[TestFixture]
- public class AsyncAppenderTest {
+ public class AsyncAppenderTest
+ {
private AsyncAppender asyncAppender;
private StringAppender stringAppender;
private Repository.Hierarchy.Hierarchy hierarchy;
[SetUp]
- public void SetupRepository() {
+ public void SetupRepository()
+ {
hierarchy = new Repository.Hierarchy.Hierarchy();
stringAppender = new StringAppender();
@@ -51,14 +53,16 @@ namespace log4net.Tests.Appender
}
[TearDown]
- public void ResetRepository() {
+ public void ResetRepository()
+ {
hierarchy.ResetConfiguration();
hierarchy.Shutdown();
hierarchy.Clear();
}
[Test]
- public void ShouldLogSingleEvent() {
+ public void ShouldLogSingleEvent()
+ {
ILogger logger = hierarchy.GetLogger("test");
logger.Log(GetType(), Level.Warn, "foo", null);
string log = WaitSomeTimeAndReturnLogWithLineFeedsStripped();
@@ -66,7 +70,8 @@ namespace log4net.Tests.Appender
}
[Test]
- public void ShouldMaintainOrderOfEvents() {
+ public void ShouldMaintainOrderOfEvents()
+ {
ILogger logger = hierarchy.GetLogger("test");
logger.Log(GetType(), Level.Warn, "foo", null);
logger.Log(GetType(), Level.Warn, "bar", null);
@@ -77,7 +82,8 @@ namespace log4net.Tests.Appender
}
[Test]
- public void ShouldForwardBulkOfEvents() {
+ public void ShouldForwardBulkOfEvents()
+ {
LoggingEvent[] events = new LoggingEvent[] {
new LoggingEvent(GetType(), hierarchy, "test", Level.Warn,
"foo", null),
new LoggingEvent(GetType(), hierarchy, "test", Level.Warn,
"bar", null),
@@ -90,7 +96,8 @@ namespace log4net.Tests.Appender
}
[Test]
- public void ShouldNotLogAfterClose() {
+ public void ShouldNotLogAfterClose()
+ {
ILogger logger = hierarchy.GetLogger("test");
logger.Log(GetType(), Level.Warn, "foo", null);
Thread.Sleep(200);
@@ -100,7 +107,8 @@ namespace log4net.Tests.Appender
Assert.AreEqual("WARN - foo", log);
}
- private string WaitSomeTimeAndReturnLogWithLineFeedsStripped() {
+ private string WaitSomeTimeAndReturnLogWithLineFeedsStripped()
+ {
Thread.Sleep(200);
return stringAppender.GetString().Replace(Environment.NewLine,
string.Empty);
}
Modified: logging/log4net/trunk/src/log4net/Appender/AsyncAppender.cs
URL:
http://svn.apache.org/viewvc/logging/log4net/trunk/src/log4net/Appender/AsyncAppender.cs?rev=1671382&r1=1671381&r2=1671382&view=diff
==============================================================================
--- logging/log4net/trunk/src/log4net/Appender/AsyncAppender.cs (original)
+++ logging/log4net/trunk/src/log4net/Appender/AsyncAppender.cs Sun Apr 5
10:11:47 2015
@@ -30,193 +30,193 @@ using log4net.Util;
namespace log4net.Appender
{
- /// <summary>
- /// Appender that forwards LoggingEvents asynchronously
- /// </summary>
- /// <remarks>
- /// This appender forwards LoggingEvents to a list of attached
appenders.
- /// The events are forwarded asynchronously using the ThreadPool.
- /// This allows the calling thread to be released quickly, however it
does
- /// not guarantee the ordering of events delivered to the attached
appenders.
- /// </remarks>
- public sealed class AsyncAppender : ForwardingAppender
- {
- /// <summary>
- /// Creates a new AsyncAppender.
- /// </summary>
- public AsyncAppender()
- {
+ /// <summary>
+ /// Appender that forwards LoggingEvents asynchronously
+ /// </summary>
+ /// <remarks>
+ /// This appender forwards LoggingEvents to a list of attached appenders.
+ /// The events are forwarded asynchronously using the ThreadPool.
+ /// This allows the calling thread to be released quickly, however it does
+ /// not guarantee the ordering of events delivered to the attached
appenders.
+ /// </remarks>
+ public sealed class AsyncAppender : ForwardingAppender
+ {
+ /// <summary>
+ /// Creates a new AsyncAppender.
+ /// </summary>
+ public AsyncAppender()
+ {
#if FRAMEWORK_4_0_OR_ABOVE
- logTask = new Task(() => { });
- logTask.Start();
+ logTask = new Task(() => { });
+ logTask.Start();
#endif
- }
+ }
- /// <summary>
- /// Gets or sets a the fields that will be fixed in the event
- /// </summary>
- /// <value>
- /// The event fields that will be fixed before the event is
forwarded
- /// </value>
- /// <remarks>
- /// <para>
- /// The logging event needs to have certain thread specific
values
- /// captured before it can be forwarded to a different thread.
- /// See <see cref="LoggingEvent.Fix"/> for details.
- /// </para>
- /// </remarks>
- /// <seealso cref="LoggingEvent.Fix"/>
- public FixFlags Fix
- {
- get { return m_fixFlags; }
- set { m_fixFlags = value; }
- }
-
- /// <summary>
- /// Forward the logging event to the attached appenders on a
ThreadPool thread
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Delivers the logging event to all the attached appenders on
a ThreadPool thread.
- /// </para>
- /// </remarks>
- override protected void Append(LoggingEvent loggingEvent)
- {
- loggingEvent.Fix = m_fixFlags;
- lock (lockObject)
- {
- if (closed)
- {
- return;
- }
- events.Add(loggingEvent);
- }
+ /// <summary>
+ /// Gets or sets a the fields that will be fixed in the event
+ /// </summary>
+ /// <value>
+ /// The event fields that will be fixed before the event is forwarded
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The logging event needs to have certain thread specific values
+ /// captured before it can be forwarded to a different thread.
+ /// See <see cref="LoggingEvent.Fix"/> for details.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="LoggingEvent.Fix"/>
+ public FixFlags Fix
+ {
+ get { return m_fixFlags; }
+ set { m_fixFlags = value; }
+ }
+
+ /// <summary>
+ /// Forward the logging event to the attached appenders on a
ThreadPool thread
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Delivers the logging event to all the attached appenders on a
ThreadPool thread.
+ /// </para>
+ /// </remarks>
+ override protected void Append(LoggingEvent loggingEvent)
+ {
+ loggingEvent.Fix = m_fixFlags;
+ lock (lockObject)
+ {
+ if (closed)
+ {
+ return;
+ }
+ events.Add(loggingEvent);
+ }
#if FRAMEWORK_4_0_OR_ABOVE
- logTask.ContinueWith(AsyncAppend);
+ logTask.ContinueWith(AsyncAppend);
#else
- ThreadPool.QueueUserWorkItem(AsyncAppend, null);
+ ThreadPool.QueueUserWorkItem(AsyncAppend, null);
#endif
- }
+ }
- /// <summary>
- /// Forward the logging events to the attached appenders on a
ThreadPool thread
- /// </summary>
- /// <param name="loggingEvents">The array of events to
log.</param>
- /// <remarks>
- /// <para>
- /// Delivers the logging events to all the attached appenders
on a ThreadPool thread.
- /// </para>
- /// </remarks>
- override protected void Append(LoggingEvent[] loggingEvents)
- {
- foreach(LoggingEvent loggingEvent in loggingEvents)
- {
- loggingEvent.Fix = m_fixFlags;
- }
- lock (lockObject)
- {
- if (closed)
- {
- return;
- }
- events.AddRange(loggingEvents);
- }
+ /// <summary>
+ /// Forward the logging events to the attached appenders on a
ThreadPool thread
+ /// </summary>
+ /// <param name="loggingEvents">The array of events to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Delivers the logging events to all the attached appenders on a
ThreadPool thread.
+ /// </para>
+ /// </remarks>
+ override protected void Append(LoggingEvent[] loggingEvents)
+ {
+ foreach (LoggingEvent loggingEvent in loggingEvents)
+ {
+ loggingEvent.Fix = m_fixFlags;
+ }
+ lock (lockObject)
+ {
+ if (closed)
+ {
+ return;
+ }
+ events.AddRange(loggingEvents);
+ }
#if FRAMEWORK_4_0_OR_ABOVE
- logTask.ContinueWith(AsyncAppend);
+ logTask.ContinueWith(AsyncAppend);
#else
- ThreadPool.QueueUserWorkItem(AsyncAppend, null);
+ ThreadPool.QueueUserWorkItem(AsyncAppend, null);
#endif
- }
+ }
- /// <summary>
- /// Closes the appender and releases resources.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Releases any resources allocated within the appender such
as file handles,
- /// network connections, etc.
- /// </para>
- /// <para>
- /// It is a programming error to append to a closed appender.
- /// </para>
- /// </remarks>
- override protected void OnClose()
- {
- lock (lockObject)
- {
+ /// <summary>
+ /// Closes the appender and releases resources.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Releases any resources allocated within the appender such as file
handles,
+ /// network connections, etc.
+ /// </para>
+ /// <para>
+ /// It is a programming error to append to a closed appender.
+ /// </para>
+ /// </remarks>
+ override protected void OnClose()
+ {
+ lock (lockObject)
+ {
#if FRAMEWORK_4_0_OR_ABOVE
- if (!closed)
- {
- logTask.Wait();
- }
-#endif
- closed = true;
- }
- base.OnClose();
- }
+ if (!closed)
+ {
+ logTask.Wait();
+ }
+#endif
+ closed = true;
+ }
+ base.OnClose();
+ }
- private void AsyncAppend(object _ignored)
- {
+ private void AsyncAppend(object _ignored)
+ {
#if FRAMEWORK_4_0_OR_ABOVE // ContinueWith already ensures there is only one
thread executing this method at a time
- ForwardEvents();
+ ForwardEvents();
#else
- lock (lockObject)
- {
- if (inLoggingLoop)
- {
- return;
- }
- inLoggingLoop = true;
- }
- try
- {
- while (true)
- {
- if (!ForwardEvents())
- {
- break;
- }
- }
- }
- finally
- {
- lock (lockObject)
- {
- inLoggingLoop = false;
- }
- }
-#endif
- }
-
- /// <summary>
- /// Forwards the queued events to the nested appenders.
- /// </summary>
- /// <returns>whether there have been any events to
forward.</returns>
- private bool ForwardEvents()
- {
- LoggingEvent[] loggingEvents = null;
- lock (lockObject)
- {
- loggingEvents = events.ToArray();
- events.Clear();
- }
- if (loggingEvents.Length == 0)
- {
- return false;
- }
- base.Append(loggingEvents);
- return true;
- }
-
- private FixFlags m_fixFlags = FixFlags.All;
- private readonly object lockObject = new object();
- private readonly List<LoggingEvent> events = new
List<LoggingEvent>();
- private bool closed = false;
+ lock (lockObject)
+ {
+ if (inLoggingLoop)
+ {
+ return;
+ }
+ inLoggingLoop = true;
+ }
+ try
+ {
+ while (true)
+ {
+ if (!ForwardEvents())
+ {
+ break;
+ }
+ }
+ }
+ finally
+ {
+ lock (lockObject)
+ {
+ inLoggingLoop = false;
+ }
+ }
+#endif
+ }
+
+ /// <summary>
+ /// Forwards the queued events to the nested appenders.
+ /// </summary>
+ /// <returns>whether there have been any events to forward.</returns>
+ private bool ForwardEvents()
+ {
+ LoggingEvent[] loggingEvents = null;
+ lock (lockObject)
+ {
+ loggingEvents = events.ToArray();
+ events.Clear();
+ }
+ if (loggingEvents.Length == 0)
+ {
+ return false;
+ }
+ base.Append(loggingEvents);
+ return true;
+ }
+
+ private FixFlags m_fixFlags = FixFlags.All;
+ private readonly object lockObject = new object();
+ private readonly List<LoggingEvent> events = new List<LoggingEvent>();
+ private bool closed = false;
#if FRAMEWORK_4_0_OR_ABOVE
- private readonly Task logTask;
+ private readonly Task logTask;
#else
- private bool inLoggingLoop = false;
+ private bool inLoggingLoop = false;
#endif
- }
+ }
}