Admin logs (#5419)
* Add admin logging, models, migrations * Add logging damage changes * Add Log admin flag, LogFilter, Logs admin menu tab, message Refactor admin logging API * Change admin log get method names * Fix the name again * Minute amount of reorganization * Reset Postgres db snapshot * Reset Sqlite db snapshot * Make AdminLog have a composite primary key of round, id * Minute cleanup * Change admin system to do a type check instead of index check * Make admin logs use C# 10 interpolated string handlers * Implement UI on its own window Custom controls Searching Add admin log converters * Implement limits into the query * Change logs to be put into an OutputPanel instead for text wrapping * Add log <-> player m2m relationship back * UI improvements, make text wrap, add separators * Remove entity prefix from damaged log * Add explicit m2m model, fix any players filter * Add debug command to test bulk adding logs * Admin logs now just kinda go * Add histogram for database update time * Make admin log system update run every 5 seconds * Add a cap to the log queue and a metric for how many times it has been reached * Add metric for logs sent in a round * Make cvars out of admin logs queue send delay and cap * Merge fixes * Reset some changes * Add test for adding and getting a single log * Add tests for bulk adding logs * Add test for querying logs * Add CallerArgumentExpression to LogStringHandler methods and test * Improve UI, fix SQLite, add searching by round * Add entities to admin logs * Move distinct after orderby * Add migrations * ef core eat my ass * Add cvar for client logs batch size * Sort logs from newest to oldest by default * Merge fixes * Reorganize tests and add one for date ordering * Add note to log types to not change their numeric values * Add impacts to logs, better UI filtering * Make log add callable from shared for convenience * Get current round id directly from game ticker * Revert namespace change for DamageableSystem
This commit is contained in:
committed by
GitHub
parent
0f7e81b564
commit
319aec109d
64
Content.Server/Administration/Commands/AdminLogBulk.cs
Normal file
64
Content.Server/Administration/Commands/AdminLogBulk.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Administration.Commands;
|
||||
|
||||
#if DEBUG
|
||||
[AdminCommand(AdminFlags.Host)]
|
||||
public class AdminLogBulk : IConsoleCommand
|
||||
{
|
||||
public string Command => "adminlogbulk";
|
||||
public string Description => "Adds debug logs to the database.";
|
||||
public string Help => $"Usage: {Command} <amount> <parallel>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (shell.Player?.AttachedEntity is not { } entity)
|
||||
{
|
||||
shell.WriteError("This command can only be ran by a player with an attached entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
int amount;
|
||||
var parallel = false;
|
||||
|
||||
switch (args)
|
||||
{
|
||||
case {Length: 1} when int.TryParse(args[0], out amount):
|
||||
case {Length: 2} when int.TryParse(args[0], out amount) &&
|
||||
bool.TryParse(args[1], out parallel):
|
||||
break;
|
||||
default:
|
||||
shell.WriteError(Help);
|
||||
return;
|
||||
}
|
||||
|
||||
var logs = EntitySystem.Get<AdminLogSystem>();
|
||||
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
|
||||
if (parallel)
|
||||
{
|
||||
Parallel.For(0, amount, _ =>
|
||||
{
|
||||
logs.Add(LogType.Unknown, $"Debug log added by {entity:Player}");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var i = 0; i < amount; i++)
|
||||
{
|
||||
logs.Add(LogType.Unknown, $"Debug log added by {entity:Player}");
|
||||
}
|
||||
}
|
||||
|
||||
shell.WriteLine($"Added {amount} logs in {stopwatch.Elapsed.TotalMilliseconds} ms");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user