mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Log directory should be implicit, not explicit
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using RombaSharp.Features;
|
||||
using SabreTools.Core;
|
||||
using SabreTools.Help;
|
||||
using SabreTools.IO;
|
||||
using SabreTools.Logging;
|
||||
|
||||
namespace RombaSharp
|
||||
@@ -38,7 +40,7 @@ namespace RombaSharp
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// Perform initial setup and verification
|
||||
LoggerImpl.SetFilename("romba.log", true);
|
||||
LoggerImpl.SetFilename(Path.Combine(PathTool.GetRuntimeDirectory(), "logs", "romba.log"), true);
|
||||
LoggerImpl.AppendPrefix = true;
|
||||
LoggerImpl.LowestLogLevel = LogLevel.VERBOSE;
|
||||
LoggerImpl.ThrowOnError = false;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace SabreTools.Logging
|
||||
/// <summary>
|
||||
/// Optional output filename for logs
|
||||
/// </summary>
|
||||
public static string Filename { get; set; } = null;
|
||||
public static string Filename { get; private set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Determines if we're logging to file or not
|
||||
@@ -26,8 +26,7 @@ namespace SabreTools.Logging
|
||||
/// <summary>
|
||||
/// Optional output log directory
|
||||
/// </summary>
|
||||
/// TODO: Make this either passed in or optional
|
||||
public static string LogDirectory { get; set; } = Path.Combine(PathTool.GetRuntimeDirectory(), "logs") + Path.DirectorySeparatorChar;
|
||||
public static string LogDirectory { get; private set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Determines the lowest log level to output
|
||||
@@ -84,11 +83,17 @@ namespace SabreTools.Logging
|
||||
/// <param name="addDate">True to append a date to the filename, false otherwise</param>
|
||||
public static void SetFilename(string filename, bool addDate = true)
|
||||
{
|
||||
// Set and create the output
|
||||
// Get the full log path
|
||||
string fullPath = Path.GetFullPath(filename);
|
||||
|
||||
// Set the log directory
|
||||
LogDirectory = Path.GetDirectoryName(fullPath);
|
||||
|
||||
// Set the
|
||||
if (addDate)
|
||||
Filename = $"{Path.GetFileNameWithoutExtension(filename)} ({DateTime.Now:yyyy-MM-dd HH-mm-ss}).{filename.GetNormalizedExtension()}";
|
||||
Filename = $"{Path.GetFileNameWithoutExtension(fullPath)} ({DateTime.Now:yyyy-MM-dd HH-mm-ss}).{fullPath.GetNormalizedExtension()}";
|
||||
else
|
||||
Filename = filename;
|
||||
Filename = Path.GetFileName(fullPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using SabreTools.Features;
|
||||
using SabreTools.Core;
|
||||
using SabreTools.Help;
|
||||
using SabreTools.IO;
|
||||
using SabreTools.Logging;
|
||||
|
||||
namespace SabreTools
|
||||
@@ -31,7 +33,7 @@ namespace SabreTools
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// Perform initial setup and verification
|
||||
LoggerImpl.SetFilename("sabretools.log", true);
|
||||
LoggerImpl.SetFilename(Path.Combine(PathTool.GetRuntimeDirectory(), "logs", "sabretools.log"), true);
|
||||
LoggerImpl.AppendPrefix = true;
|
||||
LoggerImpl.LowestLogLevel = LogLevel.VERBOSE;
|
||||
LoggerImpl.ThrowOnError = false;
|
||||
|
||||
Reference in New Issue
Block a user