]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
add more info to entity json in logs (#18672)
authorChief-Engineer <119664036+Chief-Engineer@users.noreply.github.com>
Tue, 2 Jul 2024 09:09:24 +0000 (04:09 -0500)
committerGitHub <noreply@github.com>
Tue, 2 Jul 2024 09:09:24 +0000 (11:09 +0200)
* 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

Content.Server/Administration/Logs/Converters/EntityStringRepresentationConverter.cs

index 32551e5a7d691539a274c8bcffa78ea873be0d38..39d34e5f1833ae82f67ae38035150e6d6e36e1d8 100644 (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();