mirror of
https://github.com/EnderIce2/SDR-RPC.git
synced 2025-07-11 22:49:13 +00:00
First commit
This commit is contained in:
38
LogWriter.cs
Normal file
38
LogWriter.cs
Normal file
@ -0,0 +1,38 @@
|
||||
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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user