Initial commit
This commit is contained in:
commit
137cb2ce13
215 changed files with 659023 additions and 0 deletions
25
src/GameCult.Logging/FileLogger.cs
Normal file
25
src/GameCult.Logging/FileLogger.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace GameCult.Logging
|
||||
{
|
||||
public class FileLogger : ILogger
|
||||
{
|
||||
private readonly string _logPath;
|
||||
|
||||
public FileLogger(string logPath = "server.log")
|
||||
{
|
||||
_logPath = logPath;
|
||||
}
|
||||
|
||||
private void Append(string level, string message)
|
||||
{
|
||||
File.AppendAllText(_logPath, $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] [{level}] {message}\n");
|
||||
}
|
||||
|
||||
public void LogInfo(string message) => Append("INFO", message);
|
||||
public void LogWarning(string message) => Append("WARN", message);
|
||||
public void LogError(string message) => Append("ERROR", message);
|
||||
public void LogDebug(string message) => Append("DEBUG", message);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue