Restructured logging in tools.

This commit is contained in:
2020-07-04 18:57:59 -05:00
parent b744ae653c
commit 7d418a75ff
6 changed files with 50 additions and 24 deletions

View File

@@ -0,0 +1,28 @@
using System;
using SlatedGameToolkit.Framework.Logging;
using SlatedGameToolkit.Tools.CommandSystem.Interaction;
namespace SlatedGameToolkit.Tools.Utilities.Playground
{
public class ConsoleLogListener : ILogListener
{
public bool Debug { get; set; }
public LogLevel Level => Debug ? LogLevel.DEBUG : LogLevel.INFO;
private ConsoleInteraction interaction;
public ConsoleLogListener(ConsoleInteraction interaction = null) {
this.interaction = interaction;
}
public void LogMesesage(string message, DateTime time, LogLevel level)
{
Console.SetCursorPosition(0, Console.CursorTop);
Console.WriteLine(string.Format("Playground [{0}] [{1}]: {2}", level, time.ToString("H:mm:ss"), message));
if (interaction != null && interaction.Listening) {
Console.SetCursorPosition(0, Console.CursorTop);
Console.Write(interaction.Prefix + "> ");
}
}
}
}