mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-06-04 15:12:28 +00:00
25 lines
No EOL
918 B
C#
25 lines
No EOL
918 B
C#
using System;
|
|
using System.IO;
|
|
using Kettu;
|
|
using LBPUnion.ProjectLighthouse.Helpers;
|
|
|
|
namespace LBPUnion.ProjectLighthouse.Logging
|
|
{
|
|
public class LighthouseFileLogger : LoggerBase
|
|
{
|
|
private static readonly string logsDirectory = Path.Combine(Environment.CurrentDirectory, "logs");
|
|
|
|
public override void Send(LoggerLine line)
|
|
{
|
|
FileHelper.EnsureDirectoryCreated(logsDirectory);
|
|
|
|
string channel = string.IsNullOrEmpty(line.LoggerLevel.Channel) ? "" : $"[{line.LoggerLevel.Channel}] ";
|
|
|
|
string contentFile = $"{channel}{line.LineData}\n";
|
|
string contentAll = $"[{$"{line.LoggerLevel.Name} {channel}".TrimEnd()}] {line.LineData}\n";
|
|
|
|
File.AppendAllText(Path.Combine(logsDirectory, line.LoggerLevel.Name + ".log"), contentFile);
|
|
File.AppendAllText(Path.Combine(logsDirectory, "all.log"), contentAll);
|
|
}
|
|
}
|
|
} |