Permalink
Browse files

Refactoring.

  • Loading branch information...
1 parent 6906734 commit 23b2e7099bed358d639eb07389503d4c64271741 @ah01 committed May 2, 2012
Showing with 33 additions and 15 deletions.
  1. +31 −13 NFireLogger.Log4net/FireLoggerAppender.cs
  2. +2 −2 NFireLogger.Log4net/Properties/AssemblyInfo.cs
@@ -1,19 +1,24 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using log4net.Appender;
+using log4net.Appender;
using log4net.Core;
+using L4N = log4net.Core;
namespace NFireLogger.Log4net
{
+ /// <summary>
+ /// Log4Net Appender for FireLogger
+ /// </summary>
class FireLoggerAppender : AppenderSkeleton
{
-
+ /// <summary>
+ /// FireLogger for current HttpContext
+ /// </summary>
private FireLogger Logger { get { return FLog.Current; } }
-
+ /// <summary>
+ /// Append log message to FireLogger
+ /// </summary>
+ /// <param name="loggingEvent">log4net event</param>
protected override void Append(LoggingEvent loggingEvent)
{
var msg = new LogMessage()
@@ -29,38 +34,51 @@ protected override void Append(LoggingEvent loggingEvent)
Logger.Log(msg);
}
+
+ /// <summary>
+ /// Add file and line of event to log message
+ /// </summary>
+ /// <param name="msg">log message to add info to</param>
+ /// <param name="loggingEvent">log. event from log4net</param>
private void PopulateFileInfo(LogMessage msg, LoggingEvent loggingEvent)
{
msg.PathName = loggingEvent.LocationInformation.FileName;
msg.LineNo = ParseLineNumber(loggingEvent.LocationInformation.LineNumber);
}
+
+ /// <summary>
+ /// Convert line number to long number (log4net retur string)
+ /// </summary>
private long ParseLineNumber(string lineNumber)
{
long n;
return long.TryParse(lineNumber, out n) ? n : 0;
}
- private static Level ConvertLog4NetLevels(log4net.Core.Level level)
+ /// <summary>
+ /// Convert Level from log4net to FireLogger level
+ /// </summary>
+ private static Level ConvertLog4NetLevels(L4N.Level level)
{
- if (level >= log4net.Core.Level.Fatal)
+ if (level >= L4N.Level.Fatal)
{
return Level.Critical;
}
- else if (level == log4net.Core.Level.Error)
+ else if (level == L4N.Level.Error)
{
return Level.Error;
}
- else if (level == log4net.Core.Level.Warn)
+ else if (level == L4N.Level.Warn)
{
return Level.Warning;
}
- else if (level == log4net.Core.Level.Info)
+ else if (level == L4N.Level.Info)
{
return Level.Info;
}
- else if (level >= log4net.Core.Level.Debug)
+ else if (level >= L4N.Level.Debug)
{
return Level.Debug;
}
@@ -6,11 +6,11 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("NFireLogger.Log4net")]
-[assembly: AssemblyDescription("")]
+[assembly: AssemblyDescription("Log4net appender for FireLogger")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NFireLogger.Log4net")]
-[assembly: AssemblyCopyright("Copyright © 2012")]
+[assembly: AssemblyCopyright("Copyright © Adam Horcica 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

0 comments on commit 23b2e70

Please sign in to comment.