You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by ni...@apache.org on 2004/09/10 21:40:24 UTC
cvs commit: logging-log4net/src/Layout ExceptionLayout.cs LayoutSkeleton.cs PatternLayout.cs SimpleLayout.cs XMLLayoutBase.cs
nicko 2004/09/10 12:40:24
Modified: src/Layout ExceptionLayout.cs LayoutSkeleton.cs
PatternLayout.cs SimpleLayout.cs XMLLayoutBase.cs
Log:
Made LayoutSkeleton.IgnoresException a settable property. The user can now force a layout to ignore the exception in the event.
Revision Changes Path
1.5 +1 -14 logging-log4net/src/Layout/ExceptionLayout.cs
Index: ExceptionLayout.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Layout/ExceptionLayout.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ExceptionLayout.cs 30 May 2004 11:10:31 -0000 1.4
+++ ExceptionLayout.cs 10 Sep 2004 19:40:23 -0000 1.5
@@ -46,6 +46,7 @@
/// </remarks>
public ExceptionLayout()
{
+ this.IgnoresException = false;
}
#endregion
@@ -63,20 +64,6 @@
#endregion
#region Override implementation of LayoutSkeleton
-
- /// <summary>
- /// The ExceptionLayout only handles the exception. Thus, it returns <c>false</c>.
- /// </summary>
- /// <value>
- /// The ExceptionLayout only handles the exception. Thus, it returns <c>false</c>.
- /// </value>
- /// <remarks>
- /// The ExceptionLayout only handles the exception. Thus, it returns <c>false</c>.
- /// </remarks>
- override public bool IgnoresException
- {
- get { return false; }
- }
/// <summary>
/// Gets the exception text from the logging event
1.4 +32 -5 logging-log4net/src/Layout/LayoutSkeleton.cs
Index: LayoutSkeleton.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Layout/LayoutSkeleton.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LayoutSkeleton.cs 30 May 2004 11:23:01 -0000 1.3
+++ LayoutSkeleton.cs 10 Sep 2004 19:40:23 -0000 1.4
@@ -31,6 +31,18 @@
/// <para>This is the base implementation of the <see cref="ILayout"/>
/// interface. Most layout objects should extend this class.</para>
/// </remarks>
+ /// <remarks>
+ /// <note type="inheritinfo">
+ /// <para>
+ /// Subclasses must implement the <see cref="Format(TextWriter,LoggingEvent)"/>
+ /// method.
+ /// </para>
+ /// <para>
+ /// Subclasses should set the <see cref="IgnoresException"/> in their default
+ /// constructor.
+ /// </para>
+ /// </note>
+ /// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
public abstract class LayoutSkeleton : ILayout, IOptionHandler
@@ -53,6 +65,14 @@
/// </remarks>
private string m_footer = null;
+ /// <summary>
+ /// Flag indicating if this layout handles exceptions
+ /// </summary>
+ /// <remarks>
+ /// <c>false</c> if this layout handles exceptions
+ /// </remarks>
+ private bool m_ignoresException = true;
+
#endregion
#region Constructors
@@ -174,14 +194,21 @@
/// </summary>
/// <value><c>false</c> if this layout handles exceptions</value>
/// <remarks>
- /// <para>If this layout handles the exception object contained within
+ /// <para>
+ /// If this layout handles the exception object contained within
/// <see cref="LoggingEvent"/>, then the layout should return
/// <c>false</c>. Otherwise, if the layout ignores the exception
- /// object, then the layout should return <c>true</c>.</para>
- ///
- /// <para>This method must be implemented by the subclass.</para>
+ /// object, then the layout should return <c>true</c>.
+ /// </para>
+ /// <para>
+ /// Set this value to override a this default setting.
+ /// </para>
/// </remarks>
- abstract public bool IgnoresException { get; }
+ virtual public bool IgnoresException
+ {
+ get { return m_ignoresException; }
+ set { m_ignoresException = value; }
+ }
#endregion
}
1.11 +2 -75 logging-log4net/src/Layout/PatternLayout.cs
Index: PatternLayout.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Layout/PatternLayout.cs,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- PatternLayout.cs 9 Sep 2004 21:53:13 -0000 1.10
+++ PatternLayout.cs 10 Sep 2004 19:40:23 -0000 1.11
@@ -634,7 +634,7 @@
/// <author>Gert Driesen</author>
/// <author>Douglas de la Torre</author>
/// <author>Daniel Cazzulino</author>
- public class PatternLayout : PatternLayoutShim
+ public class PatternLayout : LayoutSkeleton
{
#region Constants
@@ -797,7 +797,7 @@
public PatternLayout(string pattern)
{
// By default we do not process the exception
- SetIgnoresException(true);
+ IgnoresException = true;
m_pattern = pattern;
@@ -871,18 +871,6 @@
#endregion
- /// <summary>
- /// The <see cref="LayoutSkeleton.IgnoresException"/> value for this layout
- /// </summary>
- /// <remarks>
- /// The default value is <c>true</c>, i.e. that this layout ignores the exception
- /// </remarks>
- new public bool IgnoresException
- {
- get { return base.IgnoresException; }
- set { base.SetIgnoresException(value); }
- }
-
#region Override implementation of LayoutSkeleton
/// <summary>
@@ -971,67 +959,6 @@
get { return m_type; }
set { m_type = value; }
}
- }
- }
-
- /// <summary>
- /// Implementation shim class used by the PatternLayout
- /// </summary>
- /// <remarks>
- /// <para>
- /// This class is used to allow the <see cref="PatternLayout"/> to
- /// provide a new implementation of the <see cref="PatternLayout.IgnoresException"/>
- /// property that has a setter as well as the getter. This class
- /// is needed because there muse be an implementation of the
- /// <see cref="LayoutSkeleton.IgnoresException"/> property before
- /// it can be hidden by a new property.
- /// </para>
- /// <para>
- /// This class stores the value and overrides the base class required property.
- /// </para>
- /// </remarks>
- /// <exclude/>
- public abstract class PatternLayoutShim : LayoutSkeleton
- {
- #region Member Variables
-
- /// <summary>
- /// Store IgnoresException state
- /// </summary>
- private bool m_ignoresException;
-
- #endregion
-
- #region Constructors
-
- /// <summary>
- /// Default protected constructor
- /// </summary>
- protected PatternLayoutShim()
- {
- }
-
- #endregion
-
- #region Override implementation of LayoutSkeleton
-
- /// <summary>
- /// The <see cref="LayoutSkeleton.IgnoresException"/> value
- /// </summary>
- override public bool IgnoresException
- {
- get { return m_ignoresException; }
- }
-
- #endregion
-
- /// <summary>
- /// Set the <see cref="IgnoresException"/> value
- /// </summary>
- /// <param name="value">the value to set</param>
- protected void SetIgnoresException(bool value)
- {
- m_ignoresException = value;
}
}
}
1.5 +1 -9 logging-log4net/src/Layout/SimpleLayout.cs
Index: SimpleLayout.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Layout/SimpleLayout.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- SimpleLayout.cs 30 May 2004 11:23:01 -0000 1.4
+++ SimpleLayout.cs 10 Sep 2004 19:40:23 -0000 1.5
@@ -48,6 +48,7 @@
/// </remarks>
public SimpleLayout()
{
+ IgnoresException = true;
}
#endregion
@@ -78,15 +79,6 @@
#endregion
#region Override implementation of LayoutSkeleton
-
- /// <summary>
- /// The SimpleLayout does not handle the exception contained within
- /// LoggingEvents. Thus, it returns <c>true</c>.
- /// </summary>
- override public bool IgnoresException
- {
- get { return true; }
- }
/// <summary>
/// Produces a formatted string.
1.4 +2 -9 logging-log4net/src/Layout/XMLLayoutBase.cs
Index: XMLLayoutBase.cs
===================================================================
RCS file: /home/cvs/logging-log4net/src/Layout/XMLLayoutBase.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XMLLayoutBase.cs 30 May 2004 11:10:07 -0000 1.3
+++ XMLLayoutBase.cs 10 Sep 2004 19:40:24 -0000 1.4
@@ -50,6 +50,7 @@
/// </summary>
protected XmlLayoutBase() : this(false)
{
+ IgnoresException = false;
}
/// <summary>
@@ -71,6 +72,7 @@
/// </remarks>
protected XmlLayoutBase(bool locationInfo)
{
+ IgnoresException = false;
m_locationInfo = locationInfo;
}
@@ -140,15 +142,6 @@
override public string ContentType
{
get { return "text/xml"; }
- }
-
- /// <summary>
- /// The XMLLayout does handle the exception contained within
- /// LoggingEvents. Thus, it returns <c>false</c>.
- /// </summary>
- override public bool IgnoresException
- {
- get { return false; }
}
/// <summary>