47 lines
No EOL
1.5 KiB
C#
47 lines
No EOL
1.5 KiB
C#
|
|
|
|
using System;
|
|
using lib;
|
|
|
|
namespace server;
|
|
|
|
/// Printing and helper class for logging stuff on the server, this is not static so we dont have to keep on adding the id and client at every call
|
|
public class Log(int id, string? client)
|
|
{
|
|
public int Id { set; get; } = id;
|
|
public string? Client { set; get; } = client;
|
|
|
|
public void Encrypted(string message, byte[] payload)
|
|
{
|
|
Console.ForegroundColor = Utils.C_ENC;
|
|
Console.WriteLine($"[{DateTime.Now:HH:mm:ss}] {Id} [{Client ?? "unknown"}] - {message}: {Convert.ToBase64String(payload)}");
|
|
Console.ResetColor();
|
|
}
|
|
|
|
public void Decrypted(string message, byte[] payload)
|
|
{
|
|
Console.ForegroundColor = Utils.C_DEC;
|
|
Console.WriteLine($"[{DateTime.Now:HH:mm:ss}] {Id} [{Client ?? "unknown"}] - {message}: {Convert.ToBase64String(payload)}");
|
|
Console.ResetColor();
|
|
}
|
|
|
|
public void Decrypted(string message)
|
|
{
|
|
Console.ForegroundColor = Utils.C_DEC;
|
|
Console.WriteLine($"[{DateTime.Now:HH:mm:ss}] {Id} [{Client ?? "unknown"}] - {message}");
|
|
Console.ResetColor();
|
|
|
|
}
|
|
|
|
public void System(string message)
|
|
{
|
|
Console.ForegroundColor = Utils.C_SYS;
|
|
Console.WriteLine($"[{DateTime.Now:HH:mm:ss}] {Id} [{Client ?? "unknown"}] - {message}");
|
|
Console.ResetColor();
|
|
}
|
|
|
|
public void Message(string message)
|
|
{
|
|
Console.WriteLine($"[{DateTime.Now:HH:mm:ss}] {Id} [{Client ?? "unknown"}] - {message}");
|
|
}
|
|
} |