32 lines
776 B
C#
32 lines
776 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SLZ_4
|
|
{
|
|
public enum LogLevel
|
|
{
|
|
DEBUG,
|
|
INFO,
|
|
WARNING,
|
|
ERROR
|
|
}
|
|
class FileLogger
|
|
{
|
|
private static readonly string LogPath = Path.Combine(
|
|
AppDomain.CurrentDomain.BaseDirectory,
|
|
"logs",
|
|
$"{DateTime.Now:yyyyMMdd}.log");
|
|
|
|
public static void Log(string message, LogLevel level = LogLevel.INFO)
|
|
{
|
|
Directory.CreateDirectory(Path.GetDirectoryName(LogPath));
|
|
File.AppendAllText(LogPath,
|
|
$"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] [{level}] {message}{Environment.NewLine}");
|
|
}
|
|
}
|
|
}
|