logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject cvs commit: logging-log4net/src/ObjectRenderer RendererMap.cs
Date Sun, 19 Dec 2004 19:23:48 GMT
nicko       2004/12/19 11:23:48

  Modified:    src/ObjectRenderer RendererMap.cs
  Log:
  Updates suggested by FxCop.
  Minor naming changes to internal types.
  Perf improvements to type check + type cast code.
  
  Revision  Changes    Path
  1.7       +31 -21    logging-log4net/src/ObjectRenderer/RendererMap.cs
  
  Index: RendererMap.cs
  ===================================================================
  RCS file: /home/cvs/logging-log4net/src/ObjectRenderer/RendererMap.cs,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RendererMap.cs	6 Dec 2004 02:26:04 -0000	1.6
  +++ RendererMap.cs	19 Dec 2004 19:23:48 -0000	1.7
  @@ -104,39 +104,49 @@
   			}
   			else 
   			{
  -				try
  +				// Optimisation for strings
  +				string str = obj as string;
  +				if (str != null)
   				{
  -					Get(obj.GetType()).RenderObject(this, obj, writer);
  +					writer.Write(str);
   				}
  -				catch(Exception ex)
  +				else
   				{
  -					// Exception rendering the object
  -					log4net.Util.LogLog.Error("RendererMap: Exception while rendering object of type ["+obj.GetType().FullName+"]",
ex);
  -
  -					// return default message
  -					string objectTypeName = "";
  -					if (obj != null && obj.GetType() != null)
  +					// Lookup the renderer for the specific type
  +					try
   					{
  -						objectTypeName = obj.GetType().FullName;
  +						Get(obj.GetType()).RenderObject(this, obj, writer);
   					}
  -
  -					writer.Write("<log4net.Error>Exception rendering object type ["+objectTypeName+"]");
  -					if (ex != null)
  +					catch(Exception ex)
   					{
  -						string exceptionText = null;
  +						// Exception rendering the object
  +						log4net.Util.LogLog.Error("RendererMap: Exception while rendering object of type
["+obj.GetType().FullName+"]", ex);
   
  -						try
  +						// return default message
  +						string objectTypeName = "";
  +						if (obj != null && obj.GetType() != null)
   						{
  -							exceptionText = ex.ToString();
  +							objectTypeName = obj.GetType().FullName;
   						}
  -						catch
  +
  +						writer.Write("<log4net.Error>Exception rendering object type ["+objectTypeName+"]");
  +						if (ex != null)
   						{
  -							// Ignore exception
  -						}
  +							string exceptionText = null;
  +
  +							try
  +							{
  +								exceptionText = ex.ToString();
  +							}
  +							catch
  +							{
  +								// Ignore exception
  +							}
   
  -						writer.Write("<stackTrace>" + exceptionText + "</stackTrace>");
  +							writer.Write("<stackTrace>" + exceptionText + "</stackTrace>");
  +						}
  +						writer.Write("</log4net.Error>");
   					}
  -					writer.Write("</log4net.Error>");
   				}
   			}
   		}
  
  
  

Mime
View raw message