From eb18363bd2b6ee79bd22d0153f179c39120a2d30 Mon Sep 17 00:00:00 2001 From: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> Date: Thu, 15 Dec 2022 12:33:27 -0600 Subject: [PATCH] Add multiple logs (#12857) --- .../Cargo/Systems/CargoSystem.Orders.cs | 15 ++++++++++ .../FoamSolutionAreaEffectComponent.cs | 9 +++++- .../SmokeSolutionAreaEffectComponent.cs | 9 +++++- .../EntitySystems/ChemMasterSystem.cs | 29 +++++++++++++++++++ .../Construction/AnchorableSystem.cs | 6 ++++ .../GameTicking/GameTicker.RoundFlow.cs | 4 +++ .../Labels/Label/HandLabelerSystem.cs | 20 +++++++++++-- .../EntitySystems/SharedMobStateSystem.cs | 4 +++ 8 files changed, 92 insertions(+), 4 deletions(-) diff --git a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs index 15e157ca1a..0ae1c6765d 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs @@ -5,10 +5,12 @@ using Content.Server.MachineLinking.System; using Content.Server.Popups; using Content.Server.Station.Systems; using Content.Shared.Access.Systems; +using Content.Shared.Administration.Logs; using Content.Shared.Cargo; using Content.Shared.Cargo.BUI; using Content.Shared.Cargo.Events; using Content.Shared.Cargo.Prototypes; +using Content.Shared.Database; using Content.Shared.GameTicking; using Robust.Server.GameObjects; using Robust.Shared.Audio; @@ -35,6 +37,7 @@ namespace Content.Server.Cargo.Systems [Dependency] private readonly PopupSystem _popup = default!; [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; + [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; private void InitializeConsole() { @@ -160,6 +163,10 @@ namespace Content.Server.Cargo.Systems SoundSystem.Play(component.ConfirmSound.GetSound(), Filter.Pvs(uid, entityManager: EntityManager), uid); + // Log order approval + _adminLogger.Add(LogType.Action, LogImpact.Low, + $"{ToPrettyString(player):user} approved order [orderNum:{order.OrderNumber}, amount:{order.Amount}, product:{order.ProductId}, requester:{order.Requester}, reason:{order.Reason}] with balance at {bankAccount.Balance}"); + DeductFunds(bankAccount, cost); UpdateOrders(orderDatabase); } @@ -173,6 +180,9 @@ namespace Content.Server.Cargo.Systems private void OnAddOrderMessage(EntityUid uid, CargoOrderConsoleComponent component, CargoConsoleAddOrderMessage args) { + if (args.Session.AttachedEntity is not {Valid: true} player) + return; + if (args.Amount <= 0) return; @@ -188,6 +198,11 @@ namespace Content.Server.Cargo.Systems PlayDenySound(uid, component); return; } + + // Log order addition + _adminLogger.Add(LogType.Action, LogImpact.Low, + $"{ToPrettyString(player):user} added order [orderNum:{data.OrderNumber}, amount:{data.Amount}, product:{data.ProductId}, requester:{data.Requester}, reason:{data.Reason}]"); + } private void OnOrderUIOpened(EntityUid uid, CargoOrderConsoleComponent component, BoundUIOpenedEvent args) diff --git a/Content.Server/Chemistry/Components/FoamSolutionAreaEffectComponent.cs b/Content.Server/Chemistry/Components/FoamSolutionAreaEffectComponent.cs index 6404275104..0d37203f31 100644 --- a/Content.Server/Chemistry/Components/FoamSolutionAreaEffectComponent.cs +++ b/Content.Server/Chemistry/Components/FoamSolutionAreaEffectComponent.cs @@ -1,6 +1,8 @@ using Content.Server.Body.Components; using Content.Server.Body.Systems; using Content.Server.Chemistry.EntitySystems; +using Content.Shared.Administration.Logs; +using Content.Shared.Database; using Content.Shared.FixedPoint; using Content.Shared.Foam; using Content.Shared.Inventory; @@ -12,6 +14,7 @@ namespace Content.Server.Chemistry.Components public sealed class FoamSolutionAreaEffectComponent : SolutionAreaEffectComponent { [Dependency] private readonly IEntityManager _entMan = default!; + [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; public new const string SolutionName = "solutionArea"; @@ -61,7 +64,11 @@ namespace Content.Server.Chemistry.Components bloodstream.ChemicalSolution.AvailableVolume); var transferSolution = cloneSolution.SplitSolution(transferAmount); - bloodstreamSys.TryAddToChemicals(entity, transferSolution, bloodstream); + if (bloodstreamSys.TryAddToChemicals(entity, transferSolution, bloodstream)) + { + // Log solution addition by foam + _adminLogger.Add(LogType.ForceFeed, LogImpact.Medium, $"{_entMan.ToPrettyString(entity):target} was affected by foam {SolutionContainerSystem.ToPrettyString(transferSolution)}"); + } } protected override void OnKill() diff --git a/Content.Server/Chemistry/Components/SmokeSolutionAreaEffectComponent.cs b/Content.Server/Chemistry/Components/SmokeSolutionAreaEffectComponent.cs index 631de97ce5..9dc05769ca 100644 --- a/Content.Server/Chemistry/Components/SmokeSolutionAreaEffectComponent.cs +++ b/Content.Server/Chemistry/Components/SmokeSolutionAreaEffectComponent.cs @@ -1,8 +1,10 @@ using Content.Server.Body.Components; using Content.Server.Body.Systems; using Content.Server.Chemistry.EntitySystems; +using Content.Shared.Administration.Logs; using Content.Shared.Chemistry; using Content.Shared.Chemistry.Reagent; +using Content.Shared.Database; using Content.Shared.FixedPoint; using Content.Shared.Smoking; @@ -13,6 +15,7 @@ namespace Content.Server.Chemistry.Components public sealed class SmokeSolutionAreaEffectComponent : SolutionAreaEffectComponent { [Dependency] private readonly IEntityManager _entMan = default!; + [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; public new const string SolutionName = "solutionArea"; @@ -49,7 +52,11 @@ namespace Content.Server.Chemistry.Components } var bloodstreamSys = EntitySystem.Get(); - bloodstreamSys.TryAddToChemicals(entity, transferSolution, bloodstream); + if (bloodstreamSys.TryAddToChemicals(entity, transferSolution, bloodstream)) + { + // Log solution addition by smoke + _adminLogger.Add(LogType.ForceFeed, LogImpact.Medium, $"{_entMan.ToPrettyString(entity):target} was affected by smoke {SolutionContainerSystem.ToPrettyString(transferSolution)}"); + } } diff --git a/Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs b/Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs index 722c15f0e1..ed09346183 100644 --- a/Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/ChemMasterSystem.cs @@ -6,9 +6,11 @@ using Content.Server.Labels.Components; using Content.Server.Popups; using Content.Server.Storage.Components; using Content.Server.Storage.EntitySystems; +using Content.Shared.Administration.Logs; using Content.Shared.Chemistry; using Content.Shared.Chemistry.Components; using Content.Shared.Containers.ItemSlots; +using Content.Shared.Database; using Content.Shared.FixedPoint; using JetBrains.Annotations; using Robust.Server.GameObjects; @@ -35,6 +37,7 @@ namespace Content.Server.Chemistry.EntitySystems [Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!; [Dependency] private readonly StorageSystem _storageSystem = default!; [Dependency] private readonly LabelSystem _labelSystem = default!; + [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; private const string PillPrototypeId = "Pill"; @@ -209,6 +212,19 @@ namespace Content.Server.Chemistry.EntitySystems if (TryComp(item, out var spriteComp)) spriteComp.LayerSetState(0, "pill" + (chemMaster.PillType + 1)); + + if (user.HasValue) + { + // Log pill creation by a user + _adminLogger.Add(LogType.Action, LogImpact.Low, + $"{ToPrettyString(user.Value):user} printed {ToPrettyString(item):pill} {SolutionContainerSystem.ToPrettyString(itemSolution)}"); + } + else + { + // Log pill creation by magic? This should never happen... right? + _adminLogger.Add(LogType.Action, LogImpact.Low, + $"Unknown printed {ToPrettyString(item):pill} {SolutionContainerSystem.ToPrettyString(itemSolution)}"); + } } UpdateUiState(chemMaster); @@ -242,6 +258,19 @@ namespace Content.Server.Chemistry.EntitySystems _solutionContainerSystem.TryAddSolution( container, solution, withdrawal); + if (user.HasValue) + { + // Log bottle creation by a user + _adminLogger.Add(LogType.Action, LogImpact.Low, + $"{ToPrettyString(user.Value):user} bottled {ToPrettyString(container):bottle} {SolutionContainerSystem.ToPrettyString(solution)}"); + } + else + { + // Log bottle creation by magic? This should never happen... right? + _adminLogger.Add(LogType.Action, LogImpact.Low, + $"Unknown bottled {ToPrettyString(container):bottle} {SolutionContainerSystem.ToPrettyString(solution)}"); + } + UpdateUiState(chemMaster); ClickSound(chemMaster); } diff --git a/Content.Server/Construction/AnchorableSystem.cs b/Content.Server/Construction/AnchorableSystem.cs index 46822b1d70..3020bb12dd 100644 --- a/Content.Server/Construction/AnchorableSystem.cs +++ b/Content.Server/Construction/AnchorableSystem.cs @@ -238,10 +238,16 @@ namespace Content.Server.Construction if (transform.Anchored) { TryUnAnchor(uid, userUid, usingUid, anchorable, transform, usingTool); + + // Log unanchor attempt + _adminLogger.Add(LogType.Anchor, LogImpact.Low, $"{ToPrettyString(userUid):user} is trying to unanchor {ToPrettyString(uid):entity} from {transform.Coordinates:targetlocation}"); } else { TryAnchor(uid, userUid, usingUid, anchorable, transform, pullable, usingTool); + + // Log anchor attempt + _adminLogger.Add(LogType.Anchor, LogImpact.Low, $"{ToPrettyString(userUid):user} is trying to anchor {ToPrettyString(uid):entity} to {transform.Coordinates:targetlocation}"); } } diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index 95e7e3ebd4..a66fe109b1 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -19,6 +19,7 @@ using Robust.Shared.Random; using Robust.Shared.Utility; using System.Linq; using System.Threading.Tasks; +using Content.Shared.Database; using Robust.Shared.Asynchronous; namespace Content.Server.GameTicking @@ -295,6 +296,9 @@ namespace Content.Server.GameTicking public void ShowRoundEndScoreboard(string text = "") { + // Log end of round + _adminLogger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Round ended, showing summary"); + //Tell every client the round has ended. var gamemodeTitle = Preset != null ? Loc.GetString(Preset.ModeTitle) : string.Empty; diff --git a/Content.Server/Labels/Label/HandLabelerSystem.cs b/Content.Server/Labels/Label/HandLabelerSystem.cs index f3380b8b3f..ea8cd01071 100644 --- a/Content.Server/Labels/Label/HandLabelerSystem.cs +++ b/Content.Server/Labels/Label/HandLabelerSystem.cs @@ -1,6 +1,8 @@ using Content.Server.Labels.Components; using Content.Server.UserInterface; using Content.Server.Popups; +using Content.Shared.Administration.Logs; +using Content.Shared.Database; using Content.Shared.Interaction; using Content.Shared.Labels; using Content.Shared.Verbs; @@ -19,6 +21,7 @@ namespace Content.Server.Labels [Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!; [Dependency] private readonly PopupSystem _popupSystem = default!; [Dependency] private readonly LabelSystem _labelSystem = default!; + [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; public override void Initialize() { @@ -57,8 +60,13 @@ namespace Content.Server.Labels return; AddLabelTo(uid, handLabeler, target, out string? result); - if (result != null) - _popupSystem.PopupEntity(result, args.User, Filter.Entities(args.User)); + if (result == null) + return; + _popupSystem.PopupEntity(result, args.User, Filter.Entities(args.User)); + + // Log labeling + _adminLogger.Add(LogType.Action, LogImpact.Low, + $"{ToPrettyString(args.User):user} labeled {ToPrettyString(target):target} with {ToPrettyString(uid):labeler}"); } private void AddLabelTo(EntityUid uid, HandLabelerComponent? handLabeler, EntityUid target, out string? result) @@ -91,8 +99,16 @@ namespace Content.Server.Labels private void OnHandLabelerLabelChanged(EntityUid uid, HandLabelerComponent handLabeler, HandLabelerLabelChangedMessage args) { + if (args.Session.AttachedEntity is not {Valid: true} player) + return; + handLabeler.AssignedLabel = args.Label.Trim().Substring(0, Math.Min(handLabeler.MaxLabelChars, args.Label.Length)); DirtyUI(uid, handLabeler); + + // Log label change + _adminLogger.Add(LogType.Action, LogImpact.Low, + $"{ToPrettyString(player):user} set {ToPrettyString(uid):labeler} to apply label \"{handLabeler.AssignedLabel}\""); + } private void DirtyUI(EntityUid uid, diff --git a/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs b/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs index c853287fd6..1dd79375d1 100644 --- a/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs +++ b/Content.Shared/MobState/EntitySystems/SharedMobStateSystem.cs @@ -1,7 +1,9 @@ using System.Diagnostics.CodeAnalysis; using Content.Shared.ActionBlocker; +using Content.Shared.Administration.Logs; using Content.Shared.Alert; using Content.Shared.Damage; +using Content.Shared.Database; using Content.Shared.DragDrop; using Content.Shared.Emoting; using Content.Shared.FixedPoint; @@ -29,6 +31,7 @@ namespace Content.Shared.MobState.EntitySystems [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] protected readonly StatusEffectsSystem Status = default!; [Dependency] private readonly StandingStateSystem _standing = default!; + [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; public override void Initialize() { @@ -325,6 +328,7 @@ namespace Content.Shared.MobState.EntitySystems ExitState(component, old); component.CurrentState = state; + _adminLogger.Add(LogType.Damaged, state == DamageState.Alive ? LogImpact.Low : LogImpact.Medium, $"{ToPrettyString(component.Owner):user} state changed from {old} to {state}"); EnterState(component, state); UpdateState(component, state, threshold);