mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-16 14:42:28 +00:00
23 lines
No EOL
762 B
C#
23 lines
No EOL
762 B
C#
using InfluxDB.Client;
|
|
using InfluxDB.Client.Writes;
|
|
using LBPUnion.ProjectLighthouse.Helpers;
|
|
using LBPUnion.ProjectLighthouse.Types.Settings;
|
|
|
|
namespace LBPUnion.ProjectLighthouse.Logging.Loggers;
|
|
|
|
public class InfluxLogger : ILogger
|
|
{
|
|
public void Log(LogLine line)
|
|
{
|
|
string channel = string.IsNullOrEmpty(line.Area) ? "" : $"[{line.Area}] ";
|
|
|
|
string level = $"{$"{channel} {line}".TrimEnd()}";
|
|
string content = line.Message;
|
|
|
|
using WriteApi writeApi = InfluxHelper.Client.GetWriteApi();
|
|
|
|
PointData point = PointData.Measurement("lighthouseLog").Field("level", level).Field("content", content);
|
|
|
|
writeApi.WritePoint(point, ServerSettings.Instance.InfluxBucket, ServerSettings.Instance.InfluxOrg);
|
|
}
|
|
} |