Add air alarm admin logs (#33426)
This commit is contained in:
@@ -9,9 +9,11 @@ using Content.Server.NodeContainer.EntitySystems;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Atmos.Monitor;
|
||||
using Content.Shared.Atmos.Piping.Components;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.Tag;
|
||||
@@ -25,6 +27,7 @@ namespace Content.Server.Atmos.Monitor.Systems;
|
||||
// a danger), and atmos (which triggers based on set thresholds).
|
||||
public sealed class AtmosMonitorSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||
[Dependency] private readonly AtmosDeviceSystem _atmosDeviceSystem = default!;
|
||||
[Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!;
|
||||
@@ -393,21 +396,74 @@ public sealed class AtmosMonitorSystem : EntitySystem
|
||||
if (!Resolve(uid, ref monitor))
|
||||
return;
|
||||
|
||||
// Used for logging after the switch statement
|
||||
string logPrefix = "";
|
||||
string logValueSuffix = "";
|
||||
AtmosAlarmThreshold? logPreviousThreshold = null;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case AtmosMonitorThresholdType.Pressure:
|
||||
logPrefix = "pressure";
|
||||
logValueSuffix = "kPa";
|
||||
logPreviousThreshold = monitor.PressureThreshold;
|
||||
|
||||
monitor.PressureThreshold = threshold;
|
||||
break;
|
||||
case AtmosMonitorThresholdType.Temperature:
|
||||
logPrefix = "temperature";
|
||||
logValueSuffix = "K";
|
||||
logPreviousThreshold = monitor.TemperatureThreshold;
|
||||
|
||||
monitor.TemperatureThreshold = threshold;
|
||||
break;
|
||||
case AtmosMonitorThresholdType.Gas:
|
||||
if (gas == null || monitor.GasThresholds == null)
|
||||
return;
|
||||
|
||||
logPrefix = ((Gas) gas).ToString();
|
||||
logValueSuffix = "kPa";
|
||||
monitor.GasThresholds.TryGetValue((Gas) gas, out logPreviousThreshold);
|
||||
|
||||
monitor.GasThresholds[(Gas) gas] = threshold;
|
||||
break;
|
||||
}
|
||||
|
||||
// Admin log each change separately rather than logging the whole state
|
||||
if (logPreviousThreshold != null)
|
||||
{
|
||||
if (threshold.Ignore != logPreviousThreshold.Ignore)
|
||||
{
|
||||
string enabled = threshold.Ignore ? "disabled" : "enabled";
|
||||
_adminLogger.Add(
|
||||
LogType.AtmosDeviceSetting,
|
||||
LogImpact.Medium,
|
||||
$"{ToPrettyString(uid)} {logPrefix} thresholds {enabled}"
|
||||
);
|
||||
}
|
||||
|
||||
foreach (var change in threshold.GetChanges(logPreviousThreshold))
|
||||
{
|
||||
if (change.Current.Enabled != change.Previous?.Enabled)
|
||||
{
|
||||
string enabled = change.Current.Enabled ? "enabled" : "disabled";
|
||||
_adminLogger.Add(
|
||||
LogType.AtmosDeviceSetting,
|
||||
LogImpact.Medium,
|
||||
$"{ToPrettyString(uid)} {logPrefix} {change.Type} {enabled}"
|
||||
);
|
||||
}
|
||||
|
||||
if (change.Current.Value != change.Previous?.Value)
|
||||
{
|
||||
_adminLogger.Add(
|
||||
LogType.AtmosDeviceSetting,
|
||||
LogImpact.Medium,
|
||||
$"{ToPrettyString(uid)} {logPrefix} {change.Type} changed from {change.Previous?.Value} {logValueSuffix} to {change.Current.Value} {logValueSuffix}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user