Files
SabreTools/SabreTools.Logging/Logger.cs

157 lines
5.8 KiB
C#
Raw Normal View History

2016-03-28 17:54:24 -07:00
using System;
2020-12-07 14:29:45 -08:00
namespace SabreTools.Logging
2016-03-28 17:54:24 -07:00
{
2019-02-08 21:03:28 -08:00
/// <summary>
/// Per-class logging
2019-02-08 21:03:28 -08:00
/// </summary>
public class Logger
{
2020-10-07 13:16:53 -07:00
/// <summary>
/// Instance associated with this logger
2020-10-07 13:16:53 -07:00
/// </summary>
/// TODO: Derive class name for this object, if possible
2024-02-28 19:19:50 -05:00
private readonly object? instance;
2019-02-08 21:03:28 -08:00
/// <summary>
/// Constructor
2019-02-08 21:03:28 -08:00
/// </summary>
2024-02-28 19:19:50 -05:00
public Logger(object? instance = null)
2019-02-08 21:03:28 -08:00
{
this.instance = instance;
2019-02-08 21:03:28 -08:00
}
2020-10-07 13:16:53 -07:00
#region Log Event Triggers
2019-02-08 21:03:28 -08:00
2020-09-15 17:09:35 -07:00
/// <summary>
/// Write the given exception as a verbose message to the log output
/// </summary>
/// <param name="ex">Exception to be written log</param>
/// <param name="output">String to be written log</param>
/// <returns>True if the output could be written, false otherwise</returns>
2024-02-28 19:19:50 -05:00
public void Verbose(Exception ex, string? output = null)
2020-09-15 17:09:35 -07:00
{
LoggerImpl.Verbose(this.instance, ex, output);
2020-09-15 17:09:35 -07:00
}
2019-02-08 21:03:28 -08:00
/// <summary>
/// Write the given string as a verbose message to the log output
/// </summary>
/// <param name="output">String to be written log</param>
/// <returns>True if the output could be written, false otherwise</returns>
2020-10-07 13:16:53 -07:00
public void Verbose(string output)
2019-02-08 21:03:28 -08:00
{
LoggerImpl.Verbose(this.instance, output);
2019-02-08 21:03:28 -08:00
}
2020-10-12 11:11:14 -07:00
/// <summary>
/// Write the given verbose progress message to the log output
/// </summary>
/// <param name="total">Total count for progress</param>
/// <param name="current">Current count for progres</param>
/// <param name="output">String to be written log</param>
2024-02-28 19:19:50 -05:00
public void Verbose(long total, long current, string? output = null)
2020-10-12 11:11:14 -07:00
{
LoggerImpl.Verbose(instance, total, current, output);
}
2020-09-15 17:09:35 -07:00
/// <summary>
/// Write the given exception as a user message to the log output
/// </summary>
/// <param name="ex">Exception to be written log</param>
/// <param name="output">String to be written log</param>
/// <returns>True if the output could be written, false otherwise</returns>
2024-02-28 19:19:50 -05:00
public void User(Exception ex, string? output = null)
2020-09-15 17:09:35 -07:00
{
LoggerImpl.User(this.instance, ex, output);
2020-09-15 17:09:35 -07:00
}
2019-02-08 21:03:28 -08:00
/// <summary>
/// Write the given string as a user message to the log output
/// </summary>
/// <param name="output">String to be written log</param>
/// <returns>True if the output could be written, false otherwise</returns>
2020-10-07 13:16:53 -07:00
public void User(string output)
2019-02-08 21:03:28 -08:00
{
LoggerImpl.User(this.instance, output);
2019-02-08 21:03:28 -08:00
}
2020-10-12 11:11:14 -07:00
/// <summary>
/// Write the given user progress message to the log output
/// </summary>
/// <param name="total">Total count for progress</param>
/// <param name="current">Current count for progres</param>
/// <param name="output">String to be written log</param>
2024-02-28 19:19:50 -05:00
public void User(long total, long current, string? output = null)
2020-10-12 11:11:14 -07:00
{
LoggerImpl.User(instance, total, current, output);
}
2020-09-15 14:38:37 -07:00
/// <summary>
/// Write the given exception as a warning to the log output
/// </summary>
/// <param name="ex">Exception to be written log</param>
/// <param name="output">String to be written log</param>
/// <returns>True if the output could be written, false otherwise</returns>
2024-02-28 19:19:50 -05:00
public void Warning(Exception ex, string? output = null)
2020-09-15 14:38:37 -07:00
{
LoggerImpl.Warning(this.instance, ex, output);
2020-09-15 14:38:37 -07:00
}
2019-02-08 21:03:28 -08:00
/// <summary>
/// Write the given string as a warning to the log output
/// </summary>
/// <param name="output">String to be written log</param>
/// <returns>True if the output could be written, false otherwise</returns>
2020-10-07 13:16:53 -07:00
public void Warning(string output)
2019-02-08 21:03:28 -08:00
{
LoggerImpl.Warning(this.instance, output);
2019-02-08 21:03:28 -08:00
}
2020-10-12 11:11:14 -07:00
/// <summary>
/// Write the given warning progress message to the log output
/// </summary>
/// <param name="total">Total count for progress</param>
/// <param name="current">Current count for progres</param>
/// <param name="output">String to be written log</param>
2024-02-28 19:19:50 -05:00
public void Warning(long total, long current, string? output = null)
2020-10-12 11:11:14 -07:00
{
LoggerImpl.Warning(instance, total, current, output);
}
2020-09-15 14:38:37 -07:00
/// <summary>
/// Writes the given exception as an error in the log
/// </summary>
/// <param name="ex">Exception to be written log</param>
/// <param name="output">String to be written log</param>
/// <returns>True if the output could be written, false otherwise</returns>
2024-02-28 19:19:50 -05:00
public void Error(Exception ex, string? output = null)
2020-09-15 14:38:37 -07:00
{
LoggerImpl.Error(this.instance, ex, output);
2020-09-15 14:38:37 -07:00
}
2019-02-08 21:03:28 -08:00
/// <summary>
/// Writes the given string as an error in the log
/// </summary>
/// <param name="output">String to be written log</param>
/// <returns>True if the output could be written, false otherwise</returns>
2020-10-07 13:16:53 -07:00
public void Error(string output)
2019-02-08 21:03:28 -08:00
{
LoggerImpl.Error(this.instance, output);
2019-02-08 21:03:28 -08:00
}
2020-10-12 11:11:14 -07:00
/// <summary>
/// Write the given error progress message to the log output
/// </summary>
/// <param name="total">Total count for progress</param>
/// <param name="current">Current count for progres</param>
/// <param name="output">String to be written log</param>
2024-02-28 19:19:50 -05:00
public void Error(long total, long current, string? output = null)
2020-10-12 11:11:14 -07:00
{
LoggerImpl.Error(instance, total, current, output);
}
2020-10-07 13:16:53 -07:00
#endregion
2019-02-08 21:03:28 -08:00
}
2016-03-28 17:54:24 -07:00
}