feat: initial development

This commit is contained in:
2023-07-27 01:47:59 +04:00
commit 85dc5981cd
30 changed files with 3075 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
using System;
using System.Threading;
namespace NaiveHttpServer
{
internal class DefaultLogger : ILogger
{
public void Error(string message, Exception? exception = null)
{
Write(nameof(Error), message, exception);
}
public void Warning(string message, Exception? exception = null)
{
Write(nameof(Warning), message, exception);
}
public void Info(string message, Exception? exception = null)
{
Write(nameof(Info), message, exception);
}
public void Debug(string message, Exception? exception = null)
{
Write(nameof(Debug), message, exception);
}
private static void Write(string level, string message, Exception? exception)
{
Thread thread = Thread.CurrentThread;
string threadName = string.IsNullOrEmpty(thread.Name) ? thread.ManagedThreadId.ToString() : thread.Name!;
string exceptionString = exception is null ? string.Empty : $"{Environment.NewLine}{exception.Message}{Environment.NewLine}{exception.StackTrace}{Environment.NewLine}";
System.Diagnostics.Debug.WriteLine($"{DateTime.Now:HH:mm:ss.fff} {level.ToUpperInvariant()} [{threadName}] {message}{exceptionString}");
}
}
}