forked from kwsch/SysBot.NET
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fix ReturnPKMs issue (hopefully) - Add isMysteryMon bool to several functions - Fix records from all coming from SWSH to their correct games. - Update dependencies
- Loading branch information
Showing
12 changed files
with
52 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,29 @@ | ||
using NLog; | ||
using NLog.Config; | ||
using NLog.Targets; | ||
using System.IO; | ||
using System; | ||
|
||
namespace SysBot.Base; | ||
|
||
public static class RecordUtil<T> | ||
namespace SysBot.Base.Util | ||
{ | ||
// ReSharper disable once StaticMemberInGenericType | ||
private static readonly Logger Logger = new LogFactory { Configuration = GetConfig() }.GetCurrentClassLogger(); | ||
|
||
public static void Record(string message) => Logger.Log(LogLevel.Info, message); | ||
|
||
private static LoggingConfiguration GetConfig() | ||
public static class RecordUtil<T> | ||
{ | ||
var config = new LoggingConfiguration(); | ||
const string dir = "records"; | ||
Directory.CreateDirectory(dir); | ||
var name = typeof(T).Name; | ||
var record = new FileTarget("record") | ||
private static readonly string LogPath; | ||
|
||
static RecordUtil() | ||
{ | ||
FileName = Path.Combine(dir, $"{name}.txt"), | ||
ConcurrentWrites = true, | ||
const string dir = "records"; | ||
Directory.CreateDirectory(dir); | ||
LogPath = Path.Combine(dir, $"{typeof(T).Name}.txt"); | ||
} | ||
|
||
ArchiveEvery = FileArchivePeriod.None, | ||
ArchiveNumbering = ArchiveNumberingMode.Sequence, | ||
ArchiveFileName = Path.Combine(dir, $"{name}.{{#}}.txt"), | ||
ArchiveAboveSize = 104857600, // 100MB (never) | ||
MaxArchiveFiles = 14, | ||
}; | ||
config.AddRule(LogLevel.Debug, LogLevel.Fatal, record); | ||
return config; | ||
public static void Record(string message) | ||
{ | ||
try | ||
{ | ||
File.AppendAllText(LogPath, $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}\t{message}{Environment.NewLine}"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Console.WriteLine($"Failed to write to log: {ex.Message}"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters