AdminLog.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. using Content.Server.Administration.Logs;
  2. using Content.Shared.Construction;
  3. using Content.Shared.Database;
  4. using JetBrains.Annotations;
  5. namespace Content.Server.Construction.Completions;
  6. /// <summary>
  7. /// Generate an admin log upon reaching this node. Useful for dangerous construction (e.g., modular grenades)
  8. /// </summary>
  9. [UsedImplicitly]
  10. public sealed partial class AdminLog : IGraphAction
  11. {
  12. [DataField("logType")]
  13. public LogType LogType = LogType.Construction;
  14. [DataField("impact")]
  15. public LogImpact Impact = LogImpact.Medium;
  16. [DataField("message", required: true)]
  17. public string Message = string.Empty;
  18. public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
  19. {
  20. var logManager = IoCManager.Resolve<IAdminLogManager>();
  21. if (userUid.HasValue)
  22. logManager.Add(LogType, Impact, $"{Message} - Entity: {entityManager.ToPrettyString(uid):entity}, User: {entityManager.ToPrettyString(userUid.Value):user}");
  23. else
  24. logManager.Add(LogType, Impact, $"{Message} - Entity: {entityManager.ToPrettyString(uid):entity}");
  25. }
  26. }