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:
@@ -1,10 +1,14 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using Content.Server.Administration.Managers;
|
||||||
|
using Robust.Server.Player;
|
||||||
|
|
||||||
namespace Content.Server.Administration.Logs.Converters;
|
namespace Content.Server.Administration.Logs.Converters;
|
||||||
|
|
||||||
[AdminLogConverter]
|
[AdminLogConverter]
|
||||||
public sealed class EntityStringRepresentationConverter : AdminLogConverter<EntityStringRepresentation>
|
public sealed class EntityStringRepresentationConverter : AdminLogConverter<EntityStringRepresentation>
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||||
|
|
||||||
public override void Write(Utf8JsonWriter writer, EntityStringRepresentation value, JsonSerializerOptions options)
|
public override void Write(Utf8JsonWriter writer, EntityStringRepresentation value, JsonSerializerOptions options)
|
||||||
{
|
{
|
||||||
writer.WriteStartObject();
|
writer.WriteStartObject();
|
||||||
@@ -19,6 +23,21 @@ public sealed class EntityStringRepresentationConverter : AdminLogConverter<Enti
|
|||||||
if (value.Session != null)
|
if (value.Session != null)
|
||||||
{
|
{
|
||||||
writer.WriteString("player", value.Session.UserId.UserId);
|
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();
|
writer.WriteEndObject();
|
||||||
|
|||||||
Reference in New Issue
Block a user