Files
Sharpbin/SharpbinV2.Server/Logging.cs
T
whoswhip 73743399f1 Split code into classes to make the codebase look cleaner
Added a new favicon/icon
Add more checks before uploading a paste, changed alert to use the showNotification function
Added password modal for private pastes instead of using alert
Fix a paste page navigation in dashboard
Improve auth css
2025-05-23 18:54:29 -04:00

31 lines
1.1 KiB
C#

namespace SharpbinV2.Server
{
public class Logging
{
public Logging()
{
if (!Directory.Exists("logs"))
Directory.CreateDirectory("logs");
}
public void LogInfo(string message)
{
Console.WriteLine($"[{DateTime.Now} INFO] {message}");
File.AppendAllText($"logs/{DateTime.Now.ToString("yyyy-MM-dd")}.log", $"[{DateTime.Now} INFO] {message}\n");
}
public void LogWarning(string message)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine($"[{DateTime.Now} WARNING] {message}");
File.AppendAllText($"logs/{DateTime.Now.ToString("yyyy-MM-dd")}.log", $"[{DateTime.Now} WARNING] {message}\n");
Console.ResetColor();
}
public void LogError(string message)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"[{DateTime.Now} ERROR] {message}");
File.AppendAllText($"logs/{DateTime.Now.ToString("yyyy-MM-dd")}.log", $"[{DateTime.Now} ERROR] {message}\n");
Console.ResetColor();
}
}
}