added logging convenience methods
This commit is contained in:
parent
ca0445bd87
commit
09ebd0e0f6
@ -31,6 +31,12 @@ namespace SimpleLog {
|
||||
}
|
||||
|
||||
#region ILogger members
|
||||
/// <summary>
|
||||
/// Logs a message to all registered handlers
|
||||
/// </summary>
|
||||
/// <param name="message">The message to log</param>
|
||||
/// <param name="level">The log level of the message</param>
|
||||
/// <returns>TRUE if all handlers successfully logged the message, FALSE otherwise</returns>
|
||||
public bool Log(object message, LogLevel level) {
|
||||
bool success = true;
|
||||
|
||||
@ -55,10 +61,19 @@ namespace SimpleLog {
|
||||
return success;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers a log handler
|
||||
/// </summary>
|
||||
public void RegisterLogHandler(ILogHandler handler) {
|
||||
this.LogHandlers.Add(handler);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unregisters all log handlers that are instances or
|
||||
/// derived instances of the specified class
|
||||
/// </summary>
|
||||
/// <param name="qualifiedClassName">The fully qualified class name (e.g. SimpleLog.ILogHandler</param>
|
||||
/// <returns>The number of log handlers that were removed</returns>
|
||||
public int UnregisterLogHandlerType(string qualifiedClassName) {
|
||||
return this.LogHandlers.RemoveAll(
|
||||
delegate(ILogHandler handler) {
|
||||
@ -68,6 +83,10 @@ namespace SimpleLog {
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unregisters all log handlers
|
||||
/// </summary>
|
||||
/// <returns>The number of log handlers that were removed</returns>
|
||||
public int UnregisterAllLogHandlers() {
|
||||
int count = this.LogHandlerCount;
|
||||
this.LogHandlers.RemoveRange(0, count);
|
||||
@ -121,5 +140,40 @@ namespace SimpleLog {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs a debug message
|
||||
/// </summary>
|
||||
public bool Debug(object message) {
|
||||
return this.Log(message, LogLevel.Debug);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs an info message
|
||||
/// </summary>
|
||||
public bool Info(object message) {
|
||||
return this.Log(message, LogLevel.Info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs a warning message
|
||||
/// </summary>
|
||||
public bool Warning(object message) {
|
||||
return this.Log(message, LogLevel.Warning);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs an error message
|
||||
/// </summary>
|
||||
public bool Error(object message) {
|
||||
return this.Log(message, LogLevel.Error);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs a critical message
|
||||
/// </summary>
|
||||
public bool Critical(object message) {
|
||||
return this.Log(message, LogLevel.Critical);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user