mirror of
https://github.com/EnderIce2/SDR-RPC.git
synced 2025-05-27 19:54:27 +00:00
39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace EnderIce2.SDRSharpPlugin
|
|
{
|
|
public static class LogWriter
|
|
{
|
|
public static void WriteToFile(string Message)
|
|
{
|
|
if (!SDRSharp.Radio.Utils.GetBooleanSetting("LogRPC", false))
|
|
return;
|
|
string path = AppDomain.CurrentDomain.BaseDirectory + "\\RPCLogs\\";
|
|
if (!Directory.Exists(path))
|
|
{
|
|
Directory.CreateDirectory(path);
|
|
}
|
|
string filepath = AppDomain.CurrentDomain.BaseDirectory + "\\RPCLogs\\DiscordRPCLog_" + DateTime.Now.Date.ToShortDateString().Replace('/', '_') + ".log";
|
|
if (!File.Exists(filepath))
|
|
{
|
|
using (StreamWriter sw = File.CreateText(filepath))
|
|
{
|
|
sw.WriteLine($"[{DateTime.Now}] {Message}");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
using (StreamWriter sw = File.AppendText(filepath))
|
|
{
|
|
sw.WriteLine($"[{DateTime.Now}] {Message}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|