mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] Massive code cleanup and reorganization
This commit is contained in:
@@ -13,6 +13,17 @@ namespace SabreTools.Helper
|
||||
/// </remarks>
|
||||
public class Logger
|
||||
{
|
||||
/// <summary>
|
||||
/// Severity of the logging statement
|
||||
/// </summary>
|
||||
private enum LogLevel
|
||||
{
|
||||
VERBOSE = 0,
|
||||
USER,
|
||||
WARNING,
|
||||
ERROR,
|
||||
}
|
||||
|
||||
// Private instance variables
|
||||
private bool _tofile;
|
||||
private bool _warnings;
|
||||
@@ -24,6 +35,19 @@ namespace SabreTools.Helper
|
||||
// Private required variables
|
||||
private string _basepath = "logs" + Path.DirectorySeparatorChar;
|
||||
|
||||
/// <summary>
|
||||
/// Initialize a console-only logger object
|
||||
/// </summary>
|
||||
public Logger()
|
||||
{
|
||||
_tofile = false;
|
||||
_warnings = false;
|
||||
_errors = false;
|
||||
_filename = null;
|
||||
|
||||
Start();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize a Logger object with the given information
|
||||
/// </summary>
|
||||
@@ -33,6 +57,7 @@ namespace SabreTools.Helper
|
||||
{
|
||||
_tofile = tofile;
|
||||
_warnings = false;
|
||||
_errors = false;
|
||||
_filename = Path.GetFileNameWithoutExtension(filename) + " (" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ")" + Path.GetExtension(filename);
|
||||
|
||||
if (!Directory.Exists(_basepath))
|
||||
@@ -77,17 +102,17 @@ namespace SabreTools.Helper
|
||||
/// <returns>True if the logging was ended correctly, false otherwise</returns>
|
||||
public bool Close(bool suppress = false)
|
||||
{
|
||||
if (_warnings)
|
||||
{
|
||||
Console.WriteLine("There were warnings in the last run! Check the log for more details");
|
||||
}
|
||||
if (_errors)
|
||||
{
|
||||
Console.WriteLine("There were errors in the last run! Check the log for more details");
|
||||
}
|
||||
|
||||
if (!suppress)
|
||||
{
|
||||
if (_warnings)
|
||||
{
|
||||
Console.WriteLine("There were warnings in the last run! Check the log for more details");
|
||||
}
|
||||
if (_errors)
|
||||
{
|
||||
Console.WriteLine("There were errors in the last run! Check the log for more details");
|
||||
}
|
||||
|
||||
TimeSpan span = DateTime.Now.Subtract(_start);
|
||||
string total = span.ToString(@"hh\:mm\:ss\.fffff");
|
||||
if (!_tofile)
|
||||
|
||||
Reference in New Issue
Block a user