mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
Refactor for async operations and add new features
Updated Compression.cs to support asynchronous operations, including new methods for decompressing byte arrays and checking compression status. Enhanced Logging.cs with asynchronous logging methods. Refactored Program.cs to replace synchronous calls with asynchronous ones, added a new endpoint for editing pastes, and implemented rate limiting. Removed outdated logging configuration.
This commit is contained in:
+26
-2
@@ -1,8 +1,9 @@
|
||||
namespace Sharpbin
|
||||
using Org.BouncyCastle.Asn1.Cms;
|
||||
|
||||
namespace Sharpbin
|
||||
{
|
||||
public class Logging
|
||||
{
|
||||
public static string Api_CreateMessage = "";
|
||||
public static async Task<Log> LogRequestAsync(HttpContext context)
|
||||
{
|
||||
Log log = new Log();
|
||||
@@ -14,6 +15,29 @@
|
||||
log.IP = context.Request.Headers["X-Forwarded-For"].ToString() ?? context.Connection.RemoteIpAddress.ToString();
|
||||
return log;
|
||||
}
|
||||
public static async Task LogError(string message)
|
||||
{
|
||||
Console.BackgroundColor = ConsoleColor.Red;
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
Console.WriteLine($"[ERROR - {DateTime.Now}] {message}");
|
||||
await File.AppendAllTextAsync("logs.log", $"[ERROR - {DateTime.Now}] {message}\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
public static async Task LogInfo(string message)
|
||||
{
|
||||
Console.WriteLine($"[INFO - {DateTime.Now}] {message}");
|
||||
await File.AppendAllTextAsync("logs.log", $"[INFO - {DateTime.Now}] {message}\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
public static async Task LogWarning(string message)
|
||||
{
|
||||
Console.BackgroundColor = ConsoleColor.Yellow;
|
||||
Console.ForegroundColor = ConsoleColor.Black;
|
||||
Console.WriteLine($"[WARNING - {DateTime.Now}] {message}");
|
||||
await File.AppendAllTextAsync("logs.log", $"[WARNING - {DateTime.Now}] {message}\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
}
|
||||
public class Log
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user