Files
SabreTools/SabreTools.Logging/LogEventArgs.cs

64 lines
1.8 KiB
C#
Raw Normal View History

2020-10-07 13:16:53 -07:00
using System;
2021-02-03 10:09:40 -08:00
using SabreTools.Core;
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 LogLevel LogLevel { get; set; } = LogLevel.VERBOSE;
/// <summary>
/// Log statement to be printed
/// </summary>
2024-02-28 19:19:50 -05:00
public string? Statement { get; set; } = null;
2020-10-07 13:16:53 -07:00
/// <summary>
/// Exception to be passed along to the event handler
/// </summary>
2024-02-28 19:19:50 -05:00
public Exception? Exception { get; set; } = null;
2020-10-07 13:16:53 -07:00
/// <summary>
/// Total count for progress log events
/// </summary>
public long? TotalCount { get; set; } = null;
/// <summary>
/// Current count for progress log events
/// </summary>
public long? CurrentCount { get; set; } = null;
/// <summary>
/// Statement and exception constructor
/// </summary>
2024-02-28 19:19:50 -05:00
public LogEventArgs(LogLevel logLevel = LogLevel.VERBOSE, string? statement = null, Exception? exception = null)
2020-10-07 13:16:53 -07:00
{
this.LogLevel = logLevel;
this.Statement = statement;
this.Exception = exception;
}
/// <summary>
/// Progress constructor
/// </summary>
2024-02-28 19:19:50 -05:00
public LogEventArgs(long total, long current, LogLevel logLevel = LogLevel.VERBOSE, string? statement = null)
2020-10-07 13:16:53 -07:00
{
this.LogLevel = logLevel;
this.Statement = statement;
this.TotalCount = total;
this.CurrentCount = current;
}
}
}