forked from Code52/DownmarkerWPF
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced internal NLogAdapter with Caliburn.Micro.Logging & Caliburn.…
…Micro.Logging.NLog
- Loading branch information
unknown
authored and
unknown
committed
Jan 11, 2012
1 parent
dadddaa
commit ce34aaf
Showing
5 changed files
with
135 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
using System.Diagnostics; | ||
|
||
namespace Caliburn.Micro.Logging | ||
{ | ||
/// <summary> | ||
/// Implementation of the ILog and ILogExtended interfaces using | ||
/// <see cref="Debug"/>. | ||
/// </summary> | ||
public class DebugLogger : ILog, ILogExtended | ||
{ | ||
#region Constants | ||
private const string ErrorText = "ERROR"; | ||
private const string WarnText = "WARN"; | ||
private const string InfoText = "INFO"; | ||
#endregion | ||
|
||
#region Fields | ||
private readonly Type _type; | ||
#endregion | ||
|
||
#region Constructors | ||
public DebugLogger(Type type) | ||
{ | ||
_type = type; | ||
} | ||
#endregion | ||
|
||
#region Helper Methods | ||
private string CreateLogMessage(string format, params object[] args) | ||
{ | ||
return string.Format("[{0}] {1}", DateTime.Now.ToString("o"), string.Format(format, args)); | ||
} | ||
#endregion | ||
|
||
#region ILog Members | ||
/// <summary> | ||
/// Logs the exception. | ||
/// </summary> | ||
/// <param name="exception">The exception.</param> | ||
public void Error(Exception exception) | ||
{ | ||
Debug.WriteLine(CreateLogMessage(exception.ToString()), ErrorText); | ||
} | ||
/// <summary> | ||
/// Logs the message as info. | ||
/// </summary> | ||
/// <param name="format">A formatted message.</param><param name="args">Parameters to be injected into the formatted message.</param> | ||
public void Info(string format, params object[] args) | ||
{ | ||
Debug.WriteLine(CreateLogMessage(format, args), InfoText); | ||
} | ||
/// <summary> | ||
/// Logs the message as a warning. | ||
/// </summary> | ||
/// <param name="format">A formatted message.</param><param name="args">Parameters to be injected into the formatted message.</param> | ||
public void Warn(string format, params object[] args) | ||
{ | ||
Debug.WriteLine(CreateLogMessage(format, args), WarnText); | ||
} | ||
#endregion | ||
|
||
#region Implementation of ILogExtended | ||
/// <summary> | ||
/// Logs the message as error. | ||
/// </summary> | ||
/// <param name="format">A formatted message.</param> | ||
/// <param name="args">Parameters to be injected into the formatted message.</param> | ||
public void Error(string format, params object[] args) | ||
{ | ||
Debug.WriteLine(CreateLogMessage(format, args), ErrorText); | ||
} | ||
/// <summary> | ||
/// Logs the exception. | ||
/// </summary> | ||
/// <param name="exception">The exception.</param> | ||
/// <param name="format">A formatted message.</param> | ||
/// <param name="args">Parameters to be injected into the formatted message.</param> | ||
public void Error(Exception exception, string format, params object[] args) | ||
{ | ||
Debug.WriteLine(CreateLogMessage(format + " - Exception = " + exception.ToString(), args), ErrorText); | ||
} | ||
#endregion | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters