mirror of
https://github.com/zs-yg/MCSJ.git
synced 2025-12-06 19:00:43 +08:00
添加日志系统和gitignore
This commit is contained in:
29
Tools/log_systeam/log_creator.cs
Normal file
29
Tools/log_systeam/log_creator.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MCSJ.Tools.LogSystem
|
||||
{
|
||||
public static class LogCreator
|
||||
{
|
||||
public static string GenerateLogFileName()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
return $"{now:yyyy-MM-dd-HH-mm-ss}.log";
|
||||
}
|
||||
|
||||
public static string GetLogDirectory()
|
||||
{
|
||||
string logDir = Path.Combine(Directory.GetCurrentDirectory(), "logs");
|
||||
if (!Directory.Exists(logDir))
|
||||
{
|
||||
Directory.CreateDirectory(logDir);
|
||||
}
|
||||
return logDir;
|
||||
}
|
||||
|
||||
public static string GetLogFilePath()
|
||||
{
|
||||
return Path.Combine(GetLogDirectory(), GenerateLogFileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user