Files
SabreTools/SabreTools.Logging/LogEventArgs.cs

80 lines
2.1 KiB
C#
Raw Normal View History

2020-10-07 13:16:53 -07:00
using System;
2020-12-07 14:29:45 -08:00
namespace SabreTools.Logging
2020-10-07 13:16:53 -07:00
{
/// <summary>
/// Generic delegate type for log events
/// </summary>
2024-02-28 19:19:50 -05:00
public delegate void LogEventHandler(object? sender, LogEventArgs args);
2020-10-07 13:16:53 -07:00
/// <summary>
/// Logging specific event arguments
/// </summary>
public class LogEventArgs : EventArgs
{
/// <summary>
/// LogLevel for the event
/// </summary>
public readonly LogLevel LogLevel;
2020-10-07 13:16:53 -07:00
/// <summary>
/// Log statement to be printed
/// </summary>
public readonly string? Statement = null;
2020-10-07 13:16:53 -07:00
/// <summary>
/// Exception to be passed along to the event handler
/// </summary>
public readonly Exception? Exception = null;
2020-10-07 13:16:53 -07:00
/// <summary>
/// Total count for progress log events
/// </summary>
public readonly long? TotalCount = null;
2020-10-07 13:16:53 -07:00
/// <summary>
/// Current count for progress log events
/// </summary>
public readonly long? CurrentCount = null;
/// <summary>
/// Statement constructor
/// </summary>
public LogEventArgs(LogLevel logLevel, string statement)
{
LogLevel = logLevel;
Statement = statement;
}
/// <summary>
/// Statement constructor
/// </summary>
public LogEventArgs(LogLevel logLevel, Exception exception)
{
LogLevel = logLevel;
Exception = exception;
}
2020-10-07 13:16:53 -07:00
/// <summary>
/// Statement and exception constructor
/// </summary>
public LogEventArgs(LogLevel logLevel, string statement, Exception exception)
2020-10-07 13:16:53 -07:00
{
2024-07-17 16:01:22 -04:00
LogLevel = logLevel;
Statement = statement;
Exception = exception;
2020-10-07 13:16:53 -07:00
}
/// <summary>
/// Progress constructor
/// </summary>
public LogEventArgs(long total, long current, LogLevel logLevel, string? statement = null)
2020-10-07 13:16:53 -07:00
{
2024-07-17 16:01:22 -04:00
LogLevel = logLevel;
Statement = statement;
TotalCount = total;
CurrentCount = current;
2020-10-07 13:16:53 -07:00
}
}
}