Phase 0 completion: NT8 SDK core framework with risk management and position sizing
Some checks failed
Build and Test / build (push) Has been cancelled
Some checks failed
Build and Test / build (push) Has been cancelled
This commit is contained in:
51
src/NT8.Core/Logging/BasicLogger.cs
Normal file
51
src/NT8.Core/Logging/BasicLogger.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
|
||||
namespace NT8.Core.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Basic console logger implementation for .NET Framework 4.8
|
||||
/// </summary>
|
||||
public class BasicLogger : ILogger
|
||||
{
|
||||
private readonly string _categoryName;
|
||||
|
||||
public BasicLogger(string categoryName = "")
|
||||
{
|
||||
_categoryName = categoryName;
|
||||
}
|
||||
|
||||
public void LogDebug(string message, params object[] args)
|
||||
{
|
||||
WriteLog("DEBUG", message, args);
|
||||
}
|
||||
|
||||
public void LogInformation(string message, params object[] args)
|
||||
{
|
||||
WriteLog("INFO", message, args);
|
||||
}
|
||||
|
||||
public void LogWarning(string message, params object[] args)
|
||||
{
|
||||
WriteLog("WARN", message, args);
|
||||
}
|
||||
|
||||
public void LogError(string message, params object[] args)
|
||||
{
|
||||
WriteLog("ERROR", message, args);
|
||||
}
|
||||
|
||||
public void LogCritical(string message, params object[] args)
|
||||
{
|
||||
WriteLog("CRITICAL", message, args);
|
||||
}
|
||||
|
||||
private void WriteLog(string level, string message, params object[] args)
|
||||
{
|
||||
var timestamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.fff");
|
||||
var formattedMessage = args.Length > 0 ? String.Format(message, args) : message;
|
||||
var category = !String.IsNullOrEmpty(_categoryName) ? String.Format("[{0}] ", _categoryName) : "";
|
||||
|
||||
Console.WriteLine(String.Format("{0} [{1}] {2}{3}", timestamp, level, category, formattedMessage));
|
||||
}
|
||||
}
|
||||
}
|
||||
16
src/NT8.Core/Logging/ILogger.cs
Normal file
16
src/NT8.Core/Logging/ILogger.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace NT8.Core.Logging
|
||||
{
|
||||
/// <summary>
|
||||
/// Basic logging interface for .NET Framework 4.8 compatibility
|
||||
/// </summary>
|
||||
public interface ILogger
|
||||
{
|
||||
void LogDebug(string message, params object[] args);
|
||||
void LogInformation(string message, params object[] args);
|
||||
void LogWarning(string message, params object[] args);
|
||||
void LogError(string message, params object[] args);
|
||||
void LogCritical(string message, params object[] args);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user