mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* Renamed shared ICommand to IConsoleCommand. * Lots of refactoring into a shared context. * Removed ICommonSession from server concmd Execute. * Added argStr parameter to concmd execute. * The execute function of client concmds now returns void, use the new shell.RemoteExecuteCommand function to forward commands. # Conflicts: # Robust.Client/Console/Commands/Debug.cs * Finally move shells and commands into shared. * Console commands can now be registered directly without a class in a shared context. * Pulled up ConsoleHost and Console shell into a shared context. * Pulled up half the functions of ConsoleHost into a shared context. * Repair rebase damage. * Make LoadConsoleCommands function not remove any previously registered commands.
57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
using Robust.Client.Console;
|
|
using Robust.Shared.Interfaces.Log;
|
|
using Robust.Shared.Log;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Utility;
|
|
using Serilog.Events;
|
|
|
|
namespace Robust.Client.Log
|
|
{
|
|
/// <summary>
|
|
/// Writes logs to the in-game debug console.
|
|
/// </summary>
|
|
class DebugConsoleLogHandler : ILogHandler
|
|
{
|
|
readonly IClientConsoleHost Console;
|
|
|
|
public DebugConsoleLogHandler(IClientConsoleHost console)
|
|
{
|
|
Console = console;
|
|
}
|
|
|
|
public void Log(string sawmillName, LogEvent message)
|
|
{
|
|
var formatted = new FormattedMessage(8);
|
|
var robustLevel = message.Level.ToRobust();
|
|
formatted.PushColor(Color.DarkGray);
|
|
formatted.AddText("[");
|
|
formatted.PushColor(LogLevelToColor(robustLevel));
|
|
formatted.AddText(LogMessage.LogLevelToName(robustLevel));
|
|
formatted.Pop();
|
|
formatted.AddText($"] {sawmillName}: ");
|
|
formatted.Pop();
|
|
formatted.AddText(message.RenderMessage());
|
|
if (message.Exception != null)
|
|
{
|
|
formatted.AddText("\n");
|
|
formatted.AddText(message.Exception.ToString());
|
|
}
|
|
Console.AddFormattedLine(formatted);
|
|
}
|
|
|
|
private static Color LogLevelToColor(LogLevel level)
|
|
{
|
|
return level switch
|
|
{
|
|
LogLevel.Verbose => Color.Green,
|
|
LogLevel.Debug => Color.Blue,
|
|
LogLevel.Info => Color.Cyan,
|
|
LogLevel.Warning => Color.Yellow,
|
|
LogLevel.Error => Color.Red,
|
|
LogLevel.Fatal => Color.Red,
|
|
_ => Color.White
|
|
};
|
|
}
|
|
}
|
|
}
|