Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 29dfddf

Browse files
author
rahulgarg1985
committed
Added Falat Methods
1 parent 2c47f0a commit 29dfddf

File tree

3 files changed

+55
-15
lines changed

3 files changed

+55
-15
lines changed

CodeNode.Logging/CodeNode.Logging.csproj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@
3232
<ErrorReport>prompt</ErrorReport>
3333
<WarningLevel>4</WarningLevel>
3434
<Prefer32Bit>false</Prefer32Bit>
35+
<DocumentationFile>bin\Release\CodeNode.Logging.XML</DocumentationFile>
36+
</PropertyGroup>
37+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Net40|AnyCPU' ">
38+
<Optimize>true</Optimize>
39+
<OutputPath>bin\Net40\Release</OutputPath>
40+
<DefineConstants>TRACE</DefineConstants>
41+
<ErrorReport>prompt</ErrorReport>
42+
<WarningLevel>4</WarningLevel>
43+
<Prefer32Bit>false</Prefer32Bit>
44+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
3545
</PropertyGroup>
3646
<ItemGroup>
3747
<Reference Include="log4net">
@@ -51,7 +61,6 @@
5161
<Compile Include="Properties\AssemblyInfo.cs" />
5262
</ItemGroup>
5363
<ItemGroup>
54-
<None Include="Configurations\web.config.transform" />
5564
<None Include="Configurations\log4net.config" />
5665
<None Include="packages.config" />
5766
</ItemGroup>

CodeNode.Logging/ILogger.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@ public interface ILogger
1313
void Error(object message, Exception exception);
1414
void Info(object message);
1515
void Warning(object message);
16+
void Fatal(string message);
17+
void Fatal(Exception exceptionToLog);
18+
void Fatal(object message,Exception exceptionToLog);
1619
}
1720
}

CodeNode.Logging/Logger.cs

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static Logger Instance
5454
/// <param name="ex">The ex.</param>
5555
/// <param name="exceptionString">The exception string.</param>
5656
/// <returns></returns>
57-
private static string GetFormattedMessageFromExceptipon(Exception ex, string exceptionString)
57+
private static string GeDetailFromExceptipon(Exception ex, string exceptionString)
5858
{
5959
var mesgAndStackTrace = string.Format(ExceptionMessageWithoutInnerException, Environment.NewLine,
6060
exceptionString, Environment.NewLine, ex.Message, Environment.NewLine, ex.StackTrace);
@@ -63,7 +63,7 @@ private static string GetFormattedMessageFromExceptipon(Exception ex, string exc
6363
{
6464
mesgAndStackTrace = string.Format(ExceptionMessageWithInnerException, mesgAndStackTrace,
6565
Environment.NewLine,
66-
GetFormattedMessageFromExceptipon(ex.InnerException, InnerExceptionName));
66+
GeDetailFromExceptipon(ex.InnerException, InnerExceptionName));
6767
}
6868

6969
return mesgAndStackTrace + Environment.NewLine;
@@ -74,7 +74,7 @@ private static string GetFormattedMessageFromExceptipon(Exception ex, string exc
7474
#region Public Methods
7575

7676
/// <summary>
77-
/// The debug information.
77+
/// Log a message object with the log4net.Core.Level.Debug level.
7878
/// </summary>
7979
/// <param name="message">The message.</param>
8080
public void Debug(object message)
@@ -83,7 +83,25 @@ public void Debug(object message)
8383
}
8484

8585
/// <summary>
86-
/// The error message.
86+
/// Logs a message object with the log4net.Core.Level.Info level.
87+
/// </summary>
88+
/// <param name="message">The message.</param>
89+
public void Info(object message)
90+
{
91+
LoggerObject.Info(message);
92+
}
93+
94+
/// <summary>
95+
/// Logs a message object with the log4net.Core.Level.Info Warning.
96+
/// </summary>
97+
/// <param name="message">The message.</param>
98+
public void Warning(object message)
99+
{
100+
LoggerObject.Warn(message);
101+
}
102+
103+
/// <summary>
104+
/// Logs a message object with the log4net.Core.Level.Error level.
87105
/// </summary>
88106
/// <param name="message">The message.</param>
89107
public void Error(string message)
@@ -92,16 +110,16 @@ public void Error(string message)
92110
}
93111

94112
/// <summary>
95-
/// Errors the specified ex.
113+
/// Log a exception with the log4net.Core.Level.Fatal level.
96114
/// </summary>
97115
/// <param name="ex">The ex.</param>
98116
public void Error(Exception ex)
99117
{
100-
LoggerObject.Error(GetFormattedMessageFromExceptipon(ex, ExceptionName));
118+
LoggerObject.Error(GeDetailFromExceptipon(ex, ExceptionName));
101119
}
102120

103121
/// <summary>
104-
/// The error message.
122+
/// Log a message object with the log4net.Core.Level.Error level including the
105123
/// </summary>
106124
/// <param name="message">The message.</param>
107125
/// <param name="exception">The exception.</param>
@@ -111,23 +129,33 @@ public void Error(object message, Exception exception)
111129
}
112130

113131
/// <summary>
114-
/// The information method.
132+
/// Log a message object with the log4net.Core.Level.Fatal level.
115133
/// </summary>
116134
/// <param name="message">The message.</param>
117-
public void Info(object message)
135+
public void Fatal(string message)
118136
{
119-
LoggerObject.Info(message);
137+
LoggerObject.Fatal(message);
120138
}
121139

122140
/// <summary>
123-
/// The Warning method.
141+
/// Log a exception with the log4net.Core.Level.Fatal level.
124142
/// </summary>
125-
/// <param name="message">The message.</param>
126-
public void Warning(object message)
143+
/// <param name="ex">The ex.</param>
144+
public void Fatal(Exception ex)
127145
{
128-
LoggerObject.Warn(message);
146+
LoggerObject.Fatal(GeDetailFromExceptipon(ex, ExceptionName));
129147
}
130148

149+
/// <summary>
150+
/// Log a message object with the log4net.Core.Level.Fatal level including the
151+
// stack trace of the System.Exception passed as a parameter.
152+
/// </summary>
153+
/// <param name="message">The message.</param>
154+
/// <param name="exception">The exception.</param>
155+
public void Fatal(object message, Exception exception)
156+
{
157+
LoggerObject.Fatal(message, exception);
158+
}
131159
#endregion
132160
}
133161
}

0 commit comments

Comments
 (0)