add more info to entity json in logs (#18672)

* add more info to entity json in logs

* replace TryGetSessionById

* remove unused dependency

* get admin status from the entity

* group values by component

* alphabetize

* I've discovered that my original plans may be bad for performance
This commit is contained in:
Chief-Engineer
2024-07-02 04:09:24 -05:00
committed by GitHub
parent cab2ea757d
commit 763a25e934

View File

@@ -1,10 +1,14 @@
using System.Text.Json;
using Content.Server.Administration.Managers;
using Robust.Server.Player;
namespace Content.Server.Administration.Logs.Converters;
[AdminLogConverter]
public sealed class EntityStringRepresentationConverter : AdminLogConverter<EntityStringRepresentation>
{
[Dependency] private readonly IAdminManager _adminManager = default!;
public override void Write(Utf8JsonWriter writer, EntityStringRepresentation value, JsonSerializerOptions options)
{
writer.WriteStartObject();
@@ -19,6 +23,21 @@ public sealed class EntityStringRepresentationConverter : AdminLogConverter<Enti
if (value.Session != null)
{
writer.WriteString("player", value.Session.UserId.UserId);
if (_adminManager.IsAdmin(value.Uid))
{
writer.WriteBoolean("admin", true);
}
}
if (value.Prototype != null)
{
writer.WriteString("prototype", value.Prototype);
}
if (value.Deleted)
{
writer.WriteBoolean("deleted", true);
}
writer.WriteEndObject();