svn commit: r778073 - in /logging/log4net/trunk/src: Core/LocationInfo.cs Layout/PatternLayout.cs log4net.vs2005.csproj

View: New views
1 Messages — Rating Filter:   Alert me  

svn commit: r778073 - in /logging/log4net/trunk/src: Core/LocationInfo.cs Layout/PatternLayout.cs log4net.vs2005.csproj

by rgrabowski :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Author: rgrabowski
Date: Sun May 24 00:21:04 2009
New Revision: 778073

URL: http://svn.apache.org/viewvc?rev=778073&view=rev
Log:
Fix for LOG4NET-154. Added StackTracePatternConverter that outputs the methods called before the log message.

Modified:
    logging/log4net/trunk/src/Core/LocationInfo.cs
    logging/log4net/trunk/src/Layout/PatternLayout.cs
    logging/log4net/trunk/src/log4net.vs2005.csproj

Modified: logging/log4net/trunk/src/Core/LocationInfo.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/Core/LocationInfo.cs?rev=778073&r1=778072&r2=778073&view=diff
==============================================================================
--- logging/log4net/trunk/src/Core/LocationInfo.cs (original)
+++ logging/log4net/trunk/src/Core/LocationInfo.cs Sun May 24 00:21:04 2009
@@ -18,6 +18,7 @@
 #endregion
 
 using System;
+using System.Collections;
 using System.Diagnostics;
 
 using log4net.Util;
@@ -89,7 +90,7 @@
  {
  StackTrace st = new StackTrace(true);
  int frameIndex = 0;
-
+
  // skip frames not from fqnOfCallingClass
  while (frameIndex < st.FrameCount)
  {
@@ -114,6 +115,17 @@
 
  if (frameIndex < st.FrameCount)
  {
+ // take into account the frames we skip above
+ int adjustedFrameCount = st.FrameCount - frameIndex;
+                        ArrayList stackFramesList = new ArrayList(adjustedFrameCount);
+ m_stackFrames = new StackFrame[adjustedFrameCount];
+ for (int i=frameIndex; i < st.FrameCount; i++)
+ {
+ stackFramesList.Add(st.GetFrame(i));
+ }
+
+ stackFramesList.CopyTo(m_stackFrames, 0);
+
  // now frameIndex is the first 'user' caller frame
  StackFrame locationFrame = st.GetFrame(frameIndex);
 
@@ -258,6 +270,14 @@
  {
  get { return m_fullInfo; }
  }
+
+ /// <summary>
+ /// Gets the stack frames from the stack trace of the caller making the log request
+ /// </summary>
+ public StackFrame[] StackFrames
+ {
+ get { return m_stackFrames; }
+ }
 
  #endregion Public Instance Properties
 
@@ -268,6 +288,7 @@
  private readonly string m_lineNumber;
  private readonly string m_methodName;
  private readonly string m_fullInfo;
+ private readonly StackFrame[] m_stackFrames;
 
  #endregion Private Instance Fields
 

Modified: logging/log4net/trunk/src/Layout/PatternLayout.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/Layout/PatternLayout.cs?rev=778073&r1=778072&r2=778073&view=diff
==============================================================================
--- logging/log4net/trunk/src/Layout/PatternLayout.cs (original)
+++ logging/log4net/trunk/src/Layout/PatternLayout.cs Sun May 24 00:21:04 2009
@@ -437,6 +437,17 @@
  ///         <term>r</term>
  ///         <description>Equivalent to <b>timestamp</b></description>
  ///     </item>
+ /// <item>
+ /// <term>stacktrace</term>
+ /// <description>
+ /// <para>
+ /// Used to output the stack trace of the logging event
+ /// The stack trace level specifier may be enclosed
+ /// between braces. For example, <b>%stacktrace{level}</b>.  
+ /// If no stack trace level specifier is given then 1 is assumed
+ /// </para>
+ /// </description>
+ /// </item>
  ///     <item>
  ///         <term>t</term>
  ///         <description>Equivalent to <b>thread</b></description>
@@ -848,7 +859,9 @@
 
  s_globalRulesRegistry.Add("r", typeof(RelativeTimePatternConverter));
  s_globalRulesRegistry.Add("timestamp", typeof(RelativeTimePatternConverter));
-
+
+ s_globalRulesRegistry.Add("stacktrace", typeof(StackTracePatternConverter));
+
  s_globalRulesRegistry.Add("t", typeof(ThreadPatternConverter));
  s_globalRulesRegistry.Add("thread", typeof(ThreadPatternConverter));
 

Modified: logging/log4net/trunk/src/log4net.vs2005.csproj
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/log4net.vs2005.csproj?rev=778073&r1=778072&r2=778073&view=diff
==============================================================================
--- logging/log4net/trunk/src/log4net.vs2005.csproj (original)
+++ logging/log4net/trunk/src/log4net.vs2005.csproj Sun May 24 00:21:04 2009
@@ -27,7 +27,7 @@
     </UpgradeBackupLocation>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <OutputPath>..\build\bin\net\1.0\debug\</OutputPath>
+    <OutputPath>..\build\bin\net\2.0\debug\</OutputPath>
     <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
     <BaseAddress>285212672</BaseAddress>
     <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow>
@@ -420,6 +420,7 @@
     <Compile Include="Layout\Pattern\RelativeTimePatternConverter.cs">
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="Layout\Pattern\StackTracePatternConverter.cs" />
     <Compile Include="Layout\Pattern\ThreadPatternConverter.cs">
       <SubType>Code</SubType>
     </Compile>