Logger Sawmill Cleanup (#2413)

# Description
Cleaned up Logger obsolete compiler warnings in non robust code.
Should probably be changed to a ISawmill reference in classes to avoid
repeated lookups in heavy logging logic.
---

# Changelog

🆑

- tweak: Logger to Logger.GetSawmill("name");

---------

Co-authored-by: ilmenwe <no@mail.com>

(cherry picked from commit 2e8ffd971716d38dc6d5a520bebdf88b743045a3)
This commit is contained in:
ilmenwe
2025-05-09 01:26:14 +03:00
committed by Spatison
parent 9d79a60c23
commit 432042e945
53 changed files with 130 additions and 93 deletions

View File

@@ -25,7 +25,7 @@ public sealed partial class AccessLevelControl : GridContainer
{
if (!prototypeManager.TryIndex(access, out var accessLevel))
{
Logger.Error($"Unable to find accesslevel for {access}");
Logger.GetSawmill("accesslevelcontrol.ui").Error($"Unable to find accesslevel for {access}");
continue;
}

View File

@@ -1,4 +1,4 @@
using Content.Client.Stylesheets;
using Content.Client.Stylesheets;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
@@ -77,9 +77,14 @@ namespace Content.Client.Actions.UI
MaxWidth = TooltipTextMaxWidth,
StyleClasses = {StyleNano.StyleClassTooltipActionRequirements}
};
requiresLabel.SetMessage(FormattedMessage.FromMarkup("[color=#635c5c]" +
requires +
"[/color]"));
try
{
requiresLabel.SetMessage(FormattedMessage.FromMarkupOrThrow("[color=#635c5c]" + requires + "[/color]"));
}
catch(Exception e)
{
requiresLabel.SetMessage(e.Message);
}
vbox.AddChild(requiresLabel);
}
}
@@ -97,8 +102,16 @@ namespace Content.Client.Actions.UI
if (timeLeft > TimeSpan.Zero)
{
var duration = Cooldown.Value.End - Cooldown.Value.Start;
_cooldownLabel.SetMessage(FormattedMessage.FromMarkup(
$"[color=#a10505]{(int) duration.TotalSeconds} sec cooldown ({(int) timeLeft.TotalSeconds + 1} sec remaining)[/color]"));
try
{
_cooldownLabel.SetMessage(FormattedMessage.FromMarkupOrThrow(
$"[color=#a10505]{(int) duration.TotalSeconds} sec cooldown ({(int) timeLeft.TotalSeconds + 1} sec remaining)[/color]"));
}
catch(Exception e)
{
_cooldownLabel.SetMessage(e.Message);
}
_cooldownLabel.Visible = true;
}
else

View File

@@ -1,4 +1,4 @@
using Content.Shared.Administration.Notes;
using Content.Shared.Administration.Notes;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
@@ -12,12 +12,19 @@ public sealed partial class AdminMessagePopupMessage : Control
public AdminMessagePopupMessage(AdminMessageEuiState.Message message)
{
RobustXamlLoader.Load(this);
try
{
Admin.SetMessage(FormattedMessage.FromMarkup(Loc.GetString(
"admin-notes-message-admin",
("admin", message.AdminName),
("date", message.AddedOn.ToLocalTime()))));
Admin.SetMessage(FormattedMessage.FromMarkupOrThrow(Loc.GetString(
"admin-notes-message-admin",
("admin", message.AdminName),
("date", message.AddedOn.ToLocalTime()))));
Message.SetMessage(message.Text);
Message.SetMessage(message.Text);
}
catch(Exception e)
{
Message.SetMessage(e.Message);
}
}
}

View File

@@ -49,7 +49,14 @@ public sealed partial class AdminMessagePopupWindow : Control
MessageContainer.AddChild(new AdminMessagePopupMessage(message));
}
Description.SetMessage(FormattedMessage.FromMarkup(Loc.GetString("admin-notes-message-desc", ("count", state.Messages.Length))));
try
{
Description.SetMessage(FormattedMessage.FromMarkupOrThrow(Loc.GetString("admin-notes-message-desc", ("count", state.Messages.Length))));
}
catch (Exception e)
{
Description.SetMessage(e.Message);
}
}
private void OnDismissButtonPressed(BaseButton.ButtonEventArgs obj)

View File

@@ -41,7 +41,7 @@ namespace Content.Client.Administration.UI.CustomControls
{
if (args.Count != 2 || !args.TryGetValue("Text", out var text) || !args.TryGetValue("Command", out var command))
{
Logger.Error($"Invalid arguments passed to {nameof(CommandButton)}");
Logger.GetSawmill("commandbutton.ui").Error($"Invalid arguments passed to {nameof(CommandButton)}");
control = null;
return false;
}

View File

@@ -61,7 +61,7 @@ public sealed partial class AdminNotesLine : BoxContainer
if (iconPath is null)
{
SeverityRect.Visible = false;
Logger.WarningS("admin.notes", $"Could not find an icon for note ID {Note.Id}");
Logger.GetSawmill("admin.notes").Warning($"Could not find an icon for note ID {Note.Id}");
}
else
{

View File

@@ -131,7 +131,7 @@ namespace Content.Client.ContextMenu.UI
{
if (!Menus.TryPeek(out var topMenu))
{
Logger.Error("Context Menu: Mouse entered menu without any open menus?");
Logger.GetSawmill("contextmenu.ui").Error("Context Menu: Mouse entered menu without any open menus?");
return;
}
@@ -181,7 +181,7 @@ namespace Content.Client.ContextMenu.UI
{
if (!Menus.TryPeek(out var topMenu))
{
Logger.Error("Context Menu: Attempting to open sub menu without any open menus?");
Logger.GetSawmill("contextmenu.ui").Error("Context Menu: Attempting to open sub menu without any open menus?");
return;
}

View File

@@ -306,7 +306,7 @@ namespace Content.Client.ContextMenu.UI
// find the element associated with this entity
if (!Elements.TryGetValue(entity, out var element))
{
Logger.Error($"Attempted to remove unknown entity from the entity menu: {_entityManager.GetComponent<MetaDataComponent>(entity).EntityName} ({entity})");
Logger.GetSawmill("entitymenucontroller.ui").Error($"Attempted to remove unknown entity from the entity menu: {_entityManager.GetComponent<MetaDataComponent>(entity).EntityName} ({entity})");
return;
}

View File

@@ -135,7 +135,7 @@ public sealed partial class GuideEntityEmbed : BoxContainer, IDocumentTag
{
if (!args.TryGetValue("Entity", out var proto))
{
Logger.Error("Entity embed tag is missing entity prototype argument");
Logger.GetSawmill("guide.entity.embed").Error("Entity embed tag is missing entity prototype argument");
control = null;
return false;
}

View File

@@ -62,13 +62,13 @@ public sealed partial class GuideReagentEmbed : BoxContainer, IDocumentTag, ISea
control = null;
if (!args.TryGetValue("Reagent", out var id))
{
Logger.Error("Reagent embed tag is missing reagent prototype argument");
Logger.GetSawmill("guide.regent.embed").Error("Reagent embed tag is missing reagent prototype argument");
return false;
}
if (!_prototype.TryIndex<ReagentPrototype>(id, out var reagent))
{
Logger.Error($"Specified reagent prototype \"{id}\" is not a valid reagent prototype");
Logger.GetSawmill("guideregent.embed").Error($"Specified reagent prototype \"{id}\" is not a valid reagent prototype");
return false;
}

View File

@@ -42,7 +42,7 @@ public sealed partial class GuideReagentGroupEmbed : BoxContainer, IDocumentTag
control = null;
if (!args.TryGetValue("Group", out var group))
{
Logger.Error("Reagent group embed tag is missing group argument");
Logger.GetSawmill("guide.regentgroup.embed").Error("Reagent group embed tag is missing group argument");
return false;
}

View File

@@ -42,7 +42,7 @@ public sealed partial class GuideTechDisciplineEmbed : BoxContainer, IDocumentTa
control = null;
if (!args.TryGetValue("Discipline", out var group))
{
Logger.Error("Technology discipline embed tag is missing discipline argument");
Logger.GetSawmill("guide.techdisciplin.embed").Error("Technology discipline embed tag is missing discipline argument");
return false;
}

View File

@@ -61,13 +61,13 @@ public sealed partial class GuideTechnologyEmbed : BoxContainer, IDocumentTag, I
control = null;
if (!args.TryGetValue("Technology", out var id))
{
Logger.Error("Technology embed tag is missing technology prototype argument");
Logger.GetSawmill("guidetechnology.embed").Error("Technology embed tag is missing technology prototype argument");
return false;
}
if (!_prototype.TryIndex<TechnologyPrototype>(id, out var technology))
{
Logger.Error($"Specified technology prototype \"{id}\" is not a valid technology prototype");
Logger.GetSawmill("guidetechnology.embed").Error($"Specified technology prototype \"{id}\" is not a valid technology prototype");
return false;
}

View File

@@ -63,7 +63,7 @@ public sealed partial class GuidebookWindow : FancyWindow, ILinkClickHandler
if (!_parsingMan.TryAddMarkup(EntryContainer, file.ReadToEnd()))
{
EntryContainer.AddChild(new Label() { Text = "ERROR: Failed to parse document." });
Logger.Error($"Failed to parse contents of guide document {entry.Id}.");
Logger.GetSawmill("guidebook.window").Error($"Failed to parse contents of guide document {entry.Id}.");
}
}
@@ -149,7 +149,7 @@ public sealed partial class GuidebookWindow : FancyWindow, ILinkClickHandler
{
// TODO GUIDEBOOK Maybe allow duplicate entries?
// E.g., for adding medicine under both chemicals & the chemist job
Logger.Error($"Adding duplicate guide entry: {id}");
Logger.GetSawmill("guidebook.window").Error($"Adding duplicate guide entry: {id}");
return null;
}

View File

@@ -69,7 +69,7 @@ public sealed partial class DocumentParsingManager
catch (Exception e)
{
if (log)
Logger.Error($"Encountered error while generating markup controls: {e}");
Logger.GetSawmill("document.parsing.addmarkup").Error($"Encountered error while generating markup controls: {e}");
return false;
}
@@ -82,7 +82,7 @@ public sealed partial class DocumentParsingManager
var tag = (IDocumentTag) sandbox.CreateInstance(tagType);
if (!tag.TryParseTag(args, out var control))
{
Logger.Error($"Failed to parse {tagId} args");
Logger.GetSawmill("document.parsing").Error($"Failed to parse {tagId} args");
return new Control();
}

View File

@@ -15,7 +15,7 @@ public sealed class Table : TableContainer, IDocumentTag
if (!args.TryGetValue("Columns", out var columns) || !int.TryParse(columns, out var columnsCount))
{
Logger.Error("Guidebook tag \"Table\" does not specify required property \"Columns.\"");
Logger.GetSawmill("richtext.table").Error("Guidebook tag \"Table\" does not specify required property \"Columns.\"");
control = null;
return false;
}

View File

@@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using JetBrains.Annotations;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
@@ -60,7 +60,7 @@ public sealed class TextLinkTag : IMarkupTag
handler.HandleClick(link);
return;
}
Logger.Warning($"Warning! No valid ILinkClickHandler found.");
Logger.GetSawmill("tilelink.clickhandler").Warning($"Warning! No valid ILinkClickHandler found.");
}
}

View File

@@ -70,7 +70,7 @@ namespace Content.Client.LateJoin
SelectedId += x =>
{
var (station, jobId) = x;
Logger.InfoS("latejoin", $"Late joining as ID: {jobId}");
Logger.GetSawmill("latejoin").Info($"Late joining as ID: {jobId}");
_consoleHost.ExecuteCommand($"joingame {CommandParsing.Escape(jobId)} {station}");
Close();
};
@@ -86,7 +86,7 @@ namespace Content.Client.LateJoin
_jobCategories.Clear();
if (!_gameTicker.DisallowedLateJoin && _gameTicker.StationNames.Count == 0)
Logger.Warning("No stations exist, nothing to display in late-join GUI");
Logger.GetSawmill("latejoin.ui").Warning("No stations exist, nothing to display in late-join GUI");
foreach (var (id, name) in _gameTicker.StationNames)
{

View File

@@ -112,12 +112,12 @@ namespace Content.Client.Launcher
}
else
{
Logger.InfoS("launcher-ui", $"Redial not possible, no Ss14Address");
Logger.GetSawmill("launcher-ui").Info($"Redial not possible, no Ss14Address");
}
}
catch (Exception ex)
{
Logger.ErrorS("launcher-ui", $"Redial exception: {ex}");
Logger.GetSawmill("launcher-ui").Error($"Redial exception: {ex}");
}
return false;
}

View File

@@ -1924,7 +1924,7 @@ namespace Content.Client.Lobby.UI
}
catch (Exception exc)
{
Logger.Error($"Error when importing profile\n{exc.StackTrace}");
Logger.GetSawmill("humanoidprofile.editor").Error($"Error when importing profile\n{exc.StackTrace}");
}
finally
{
@@ -1954,7 +1954,7 @@ namespace Content.Client.Lobby.UI
}
catch (Exception exc)
{
Logger.Error($"Error when exporting profile: {exc.Message}\n{exc.StackTrace}");
Logger.GetSawmill("humanoidprofile.editor").Error($"Error when exporting profile: {exc.Message}\n{exc.StackTrace}");
}
finally
{

View File

@@ -137,7 +137,7 @@ namespace Content.Client.MainMenu
catch (ArgumentException e)
{
_userInterfaceManager.Popup($"Unable to connect: {e.Message}", "Connection error.");
Logger.Warning(e.ToString());
Logger.GetSawmill("connection").Warning(e.ToString());
_netManager.ConnectFailed -= _onConnectFailed;
_setConnectingState(false);
}

View File

@@ -51,7 +51,7 @@ public sealed partial class GeneratedParallaxTextureSource : IParallaxTextureSou
var parallaxConfig = GetParallaxConfig();
if (parallaxConfig == null)
{
Logger.ErrorS("parallax", $"Parallax config not found or unreadable: {ParallaxConfigPath}");
Logger.GetSawmill("parallax.generator").Error("parallax", $"Parallax config not found or unreadable: {ParallaxConfigPath}");
// The show must go on.
return Texture.Transparent;
}
@@ -77,7 +77,7 @@ public sealed partial class GeneratedParallaxTextureSource : IParallaxTextureSou
}
catch (Exception ex)
{
Logger.ErrorS("parallax", $"Couldn't retrieve parallax cached texture: {ex}");
Logger.GetSawmill("parallax.generator").Error("parallax", $"Couldn't retrieve parallax cached texture: {ex}");
try
{

View File

@@ -40,7 +40,7 @@ namespace Content.Client.Screenshot
}
else
{
Logger.InfoS("screenshot", "Can't take no-UI screenshot: current state is not GameScreen");
Logger.GetSawmill("screenshot").Info("Can't take no-UI screenshot: current state is not GameScreen");
}
}));
}
@@ -74,16 +74,16 @@ namespace Content.Client.Screenshot
screenshot.SaveAsPng(file);
});
Logger.InfoS("screenshot", "Screenshot taken as {0}.png", filename);
Logger.GetSawmill("screenshot.hook").Info("screenshot", "Screenshot taken as {0}.png", filename);
return;
}
catch (IOException e)
{
Logger.WarningS("screenshot", "Failed to save screenshot, retrying?:\n{0}", e);
Logger.GetSawmill("screenshot.hook").Warning("screenshot", "Failed to save screenshot, retrying?:\n{0}", e);
}
}
Logger.ErrorS("screenshot", "Unable to save screenshot.");
Logger.GetSawmill("screenshot.hook").Error("screenshot", "Unable to save screenshot.");
}
}

View File

@@ -34,7 +34,7 @@ namespace Content.Client.UserInterface.Controls
//this auto registers the button with it's parent container when it's set
if (_slotNameSet)
{
Logger.Warning("Tried to set slotName after init for:" + Name);
Logger.GetSawmill("slot.control").Warning("Tried to set slotName after init for:" + Name);
return;
}
_slotNameSet = true;

View File

@@ -193,7 +193,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged<GameplayS
return TryTargetEntityWorld(args, actionId, entMapTarget, user, comp) || !entMapTarget.InteractOnMiss;
default:
Logger.Error($"Unknown targeting action: {actionId.GetType()}");
Logger.GetSawmill("action.ui.control").Error($"Unknown targeting action: {actionId.GetType()}");
return false;
}
}

View File

@@ -79,7 +79,7 @@ public sealed partial class AlertsUI : UIWidget
{
if (!alertKey.AlertType.HasValue)
{
Logger.WarningS("alert", "found alertkey without alerttype," +
Logger.GetSawmill("alert").Warning("found alertkey without alerttype," +
" alert keys should never be stored without an alerttype set: {0}", alertKey);
continue;
}
@@ -87,7 +87,7 @@ public sealed partial class AlertsUI : UIWidget
var alertType = alertKey.AlertType.Value;
if (!alertsSystem.TryGet(alertType, out var newAlert))
{
Logger.ErrorS("alert", "Unrecognized alertType {0}", alertType);
Logger.GetSawmill("alert").Error("Unrecognized alertType {0}", alertType);
continue;
}

View File

@@ -123,7 +123,7 @@ public sealed class AHelpUIController : UIController, IOnSystemChanged<BwoinkSys
private void ReceivedBwoink(object? sender, SharedBwoinkSystem.BwoinkTextMessage message)
{
Logger.InfoS("c.s.go.es.bwoink", $"@{message.UserId}: {message.Text}");
Logger.GetSawmill("c.s.go.es.bwoink").Info($"@{message.UserId}: {message.Text}");
var localPlayer = _playerManager.LocalSession;
if (localPlayer == null)
return;

View File

@@ -81,7 +81,7 @@ public partial class ChatBox : UIWidget
private void OnMessageAdded(ChatMessage msg)
{
Logger.DebugS("chat", $"{msg.Channel}: {msg.Message}");
Logger.GetSawmill("chat").Debug($"{msg.Channel}: {msg.Message}");
if (!ChatInput.FilterButton.Popup.IsActive(msg.Channel))
{
return;

View File

@@ -195,7 +195,7 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered<LobbyS
{
if (!_prototypeManager.TryIndex(guideId, out var guide))
{
Logger.Error($"Encountered unknown guide prototype: {guideId}");
Logger.GetSawmill("guidebook").Error($"Encountered unknown guide prototype: {guideId}");
continue;
}
guides.Add(guideId, guide);
@@ -225,7 +225,7 @@ public sealed class GuidebookUIController : UIController, IOnStateEntered<LobbyS
if (!_prototypeManager.TryIndex(childId, out var child))
{
Logger.Error($"Encountered unknown guide prototype: {childId} as a child of {guide.Id}. If the child is not a prototype, it must be directly provided.");
Logger.GetSawmill("guide.ui.control").Error($"Encountered unknown guide prototype: {childId} as a child of {guide.Id}. If the child is not a prototype, it must be directly provided.");
continue;
}

View File

@@ -1,4 +1,4 @@
using System.Numerics;
using System.Numerics;
using Content.Client.UserInterface.Controls;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
@@ -29,7 +29,7 @@ public sealed class InventoryDisplay : LayoutContainer
VerticalExpand = true;
InheritChildMeasure = true;
if (!_buttons.TryAdd(newButton.SlotName, (newButton, buttonOffset)))
Logger.Warning("Tried to add button without a slot!");
Logger.GetSawmill("inventory.display").Warning("Tried to add button without a slot!");
SetPosition(newButton, buttonOffset * ButtonSize + new Vector2(ButtonSpacing, ButtonSpacing));
UpdateSizeData(buttonOffset);
return newButton;

View File

@@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Content.Client.UserInterface.Controls;
using Robust.Client.UserInterface.Controls;
@@ -84,7 +84,7 @@ public abstract class ItemSlotUIContainer<T> : GridContainer, IItemslotUIContain
{
if (newButton.SlotName == "")
{
Logger.Warning("Could not add button " + newButton.Name + "No slotname");
Logger.GetSawmill("itemslot.ui.container").Warning("Could not add button " + newButton.Name + "No slotname");
}
return !Buttons.TryAdd(newButton.SlotName, newButton) ? null : newButton;

View File

@@ -242,7 +242,7 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
{
if (_inventoryHotbar == null)
{
Logger.Warning("Tried to toggle inventory bar when none are assigned");
Logger.GetSawmill("inventory.ui.control").Warning("Tried to toggle inventory bar when none are assigned");
return;
}

View File

@@ -99,6 +99,6 @@ public sealed class ViewportUIController : UIController
// Currently, this shouldn't happen. This likely happened because the main eye was set to null. When this
// does happen it can create hard to troubleshoot bugs, so lets print some helpful warnings:
Logger.Warning($"Main viewport's eye is in nullspace (main eye is null?). Attached entity: {_entMan.ToPrettyString(ent.Value)}. Entity has eye comp: {eye != null}");
Logger.GetSawmill("viewport.ui.control").Warning($"Main viewport's eye is in nullspace (main eye is null?). Attached entity: {_entMan.ToPrettyString(ent.Value)}. Entity has eye comp: {eye != null}");
}
}

View File

@@ -260,7 +260,7 @@ public sealed class ReplayMainScreen : State
}
catch (Exception ex)
{
Logger.Error($"Failed to load replay info. Exception: {ex}");
Logger.GetSawmill("replay.mainmenu").Error($"Failed to load replay info. Exception: {ex}");
SelectReplay(null);
return;
}

View File

@@ -29,7 +29,7 @@ public sealed class DepartmentBanCommand : IConsoleCommand
uint minutes;
if (!Enum.TryParse(_cfg.GetCVar(CCVars.DepartmentBanDefaultSeverity), out NoteSeverity severity))
{
Logger.WarningS("admin.department_ban", "Department ban severity could not be parsed from config! Defaulting to medium.");
Logger.GetSawmill("admin.department_ban").Warning("Department ban severity could not be parsed from config! Defaulting to medium.");
severity = NoteSeverity.Medium;
}

View File

@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using System.Text;
using Content.Server.Administration.Managers;
using Content.Shared.Administration;
@@ -28,7 +28,7 @@ public sealed class RoleBanCommand : IConsoleCommand
uint minutes;
if (!Enum.TryParse(_cfg.GetCVar(CCVars.RoleBanDefaultSeverity), out NoteSeverity severity))
{
Logger.WarningS("admin.role_ban", "Role ban severity could not be parsed from config! Defaulting to medium.");
Logger.GetSawmill("admin.role_ban").Warning("Role ban severity could not be parsed from config! Defaulting to medium.");
severity = NoteSeverity.Medium;
}

View File

@@ -22,7 +22,7 @@ public sealed class UserNotesEui : BaseEui
if (!_seeOwnNotes)
{
Logger.WarningS("admin.notes", "User notes initialized when see_own_notes set to false");
Logger.GetSawmill("admin.notes").Warning("User notes initialized when see_own_notes set to false");
}
}
@@ -39,7 +39,7 @@ public sealed class UserNotesEui : BaseEui
{
if (!_seeOwnNotes)
{
Logger.WarningS("admin.notes", $"User {Player.Name} with ID {Player.UserId} tried to update their own user notes when see_own_notes was set to false");
Logger.GetSawmill("admin.notes").Warning($"User {Player.Name} with ID {Player.UserId} tried to update their own user notes when see_own_notes was set to false");
return;
}

View File

@@ -1,4 +1,4 @@
using System.Globalization;
using System.Globalization;
using Content.Shared.Atmos;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager;
@@ -14,6 +14,7 @@ namespace Content.Server.Atmos.Serialization;
public sealed partial class TileAtmosCollectionSerializer : ITypeSerializer<Dictionary<Vector2i, TileAtmosphere>, MappingDataNode>, ITypeCopier<Dictionary<Vector2i, TileAtmosphere>>
{
private static ISawmill _sawmill = Logger.GetSawmill(nameof(TileAtmosCollectionSerializer));
public ValidationNode Validate(ISerializationManager serializationManager, MappingDataNode node,
IDependencyCollection dependencies, ISerializationContext? context = null)
{
@@ -48,7 +49,7 @@ public sealed partial class TileAtmosCollectionSerializer : ITypeSerializer<Dict
}
catch (ArgumentOutOfRangeException)
{
Logger.Error(
_sawmill.Error(
$"Error during atmos serialization! Tile at {indices} points to an unique mix ({mix}) out of range!");
}
}
@@ -91,7 +92,7 @@ public sealed partial class TileAtmosCollectionSerializer : ITypeSerializer<Dict
}
catch (ArgumentOutOfRangeException)
{
Logger.Error(
_sawmill.Error(
$"Error during atmos serialization! Tile at {indices} points to an unique mix ({mix}) out of range!");
}
}

View File

@@ -45,6 +45,8 @@ namespace Content.Server.Chat.Managers
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly PlayerRateLimitManager _rateLimitManager = default!;
private ISawmill _sawmill = default!;
/// <summary>
/// The maximum length a player-sent message can be sent
/// </summary>
@@ -57,6 +59,7 @@ namespace Content.Server.Chat.Managers
public void Initialize()
{
_sawmill = Logger.GetSawmill("SERVER");
_netManager.RegisterNetMessage<MsgChatMessage>();
_netManager.RegisterNetMessage<MsgDeleteChatMessagesBy>();
@@ -110,7 +113,7 @@ namespace Content.Server.Chat.Managers
{
var wrappedMessage = Loc.GetString("chat-manager-server-wrap-message", ("message", FormattedMessage.EscapeText(message)));
ChatMessageToAll(ChatChannel.Server, message, wrappedMessage, EntityUid.Invalid, hideChat: false, recordReplay: true, colorOverride: colorOverride);
Logger.InfoS("SERVER", message);
_sawmill.Info(message);
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Server announcement: {message}");
}

View File

@@ -28,7 +28,7 @@ public sealed partial class BuildMech : IGraphAction
{
if (!entityManager.TryGetComponent(uid, out ContainerManagerComponent? containerManager))
{
Logger.Warning($"Mech construct entity {uid} did not have a container manager! Aborting build mech action.");
Logger.GetSawmill("buildmech.action").Warning($"Mech construct entity {uid} did not have a container manager! Aborting build mech action.");
return;
}
@@ -37,20 +37,20 @@ public sealed partial class BuildMech : IGraphAction
if (!containerSystem.TryGetContainer(uid, Container, out var container, containerManager))
{
Logger.Warning($"Mech construct entity {uid} did not have the specified '{Container}' container! Aborting build mech action.");
Logger.GetSawmill("buildmech.action").Warning($"Mech construct entity {uid} did not have the specified '{Container}' container! Aborting build mech action.");
return;
}
if (container.ContainedEntities.Count != 1)
{
Logger.Warning($"Mech construct entity {uid} did not have exactly one item in the specified '{Container}' container! Aborting build mech action.");
Logger.GetSawmill("buildmech.action").Warning($"Mech construct entity {uid} did not have exactly one item in the specified '{Container}' container! Aborting build mech action.");
}
var cell = container.ContainedEntities[0];
if (!entityManager.TryGetComponent<BatteryComponent>(cell, out var batteryComponent))
{
Logger.Warning($"Mech construct entity {uid} had an invalid entity in container \"{Container}\"! Aborting build mech action.");
Logger.GetSawmill("buildmech.action").Warning($"Mech construct entity {uid} had an invalid entity in container \"{Container}\"! Aborting build mech action.");
return;
}

View File

@@ -1088,7 +1088,7 @@ namespace Content.Server.Database
Password = pass
}.ConnectionString;
Logger.DebugS("db.manager", $"Using Postgres \"{host}:{port}/{db}\"");
Logger.GetSawmill("db.manager").Debug($"Using Postgres \"{host}:{port}/{db}\"");
builder.UseNpgsql(connectionString);
SetupLogging(builder);
@@ -1111,12 +1111,12 @@ namespace Content.Server.Database
if (!inMemory)
{
var finalPreferencesDbPath = Path.Combine(_res.UserData.RootDir!, configPreferencesDbPath);
Logger.DebugS("db.manager", $"Using SQLite DB \"{finalPreferencesDbPath}\"");
Logger.GetSawmill("db.manager").Debug($"Using SQLite DB \"{finalPreferencesDbPath}\"");
getConnection = () => new SqliteConnection($"Data Source={finalPreferencesDbPath}");
}
else
{
Logger.DebugS("db.manager", "Using in-memory SQLite DB");
Logger.GetSawmill("db.manager").Debug("Using in-memory SQLite DB");
_sqliteInMemoryConnection = new SqliteConnection("Data Source=:memory:");
// When using an in-memory DB we have to open it manually
// so EFCore doesn't open, close and wipe it every operation.

View File

@@ -205,7 +205,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
holder.CurrentDirection = ev.Next;
holder.StartingTime = 0.1f;
holder.TimeLeft = 0.1f;
// Logger.InfoS("c.s.disposal.holder", $"Disposals dir {holder.CurrentDirection}");
// Logger.GetSawmill("c.s.disposal.holder").Info($"Disposals dir {holder.CurrentDirection}");
// Invalid direction = exit now!
if (holder.CurrentDirection == Direction.Invalid)

View File

@@ -99,7 +99,7 @@ namespace Content.Server.EUI
if (!dat.OpenUIs.TryGetValue(message.Id, out var eui))
{
Logger.WarningS("eui", $"Got EUI message from player {ply} for non-existing UI {message.Id}");
Logger.GetSawmill("eui").Warning($"Got EUI message from player {ply} for non-existing UI {message.Id}");
return;
}

View File

@@ -41,7 +41,7 @@ namespace Content.Server.GameTicking.Commands
if (ticker.PlayerGameStatuses.TryGetValue(player.UserId, out var status) && status == PlayerGameStatus.JoinedGame)
{
Logger.InfoS("security", $"{player.Name} ({player.UserId}) attempted to latejoin while in-game.");
Logger.GetSawmill("security").Info($"{player.Name} ({player.UserId}) attempted to latejoin while in-game.");
shell.WriteError($"{player.Name} is not in the lobby. This incident will be reported.");
return;
}

View File

@@ -18,11 +18,14 @@ namespace Content.Server.MoMMI
[Dependency] private readonly IStatusHost _statusHost = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly ITaskManager _taskManager = default!;
private ISawmill _sawmill = default!;
private readonly HttpClient _httpClient = new();
void IPostInjectInit.PostInject()
{
_sawmill = Logger.GetSawmill("mommi");
_statusHost.AddHandler(HandleChatPost);
}
@@ -48,7 +51,7 @@ namespace Content.Server.MoMMI
if (string.IsNullOrWhiteSpace(password))
{
Logger.WarningS("mommi", "MoMMI URL specified but not password!");
_sawmill.Warning("MoMMI URL specified but not password!");
return;
}

View File

@@ -32,6 +32,8 @@ public sealed class ReverseEngineeringSystem : EntitySystem
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
private readonly ISawmill _sawmill = Logger.GetSawmill("reverseengineering");
private const string TargetSlot = "target_slot";
public override void Initialize()
{
@@ -235,7 +237,7 @@ public sealed class ReverseEngineeringSystem : EntitySystem
if (!TryComp<ReverseEngineeringComponent>(component.CurrentItem, out var rev))
{
Logger.Error("We somehow scanned a " + component.CurrentItem + " for reverse engineering...");
_sawmill.Error("We somehow scanned a " + component.CurrentItem + " for reverse engineering...");
return;
}

View File

@@ -17,7 +17,6 @@ public sealed partial class CableSystem : EntitySystem
[Dependency] private readonly SharedToolSystem _toolSystem = default!;
[Dependency] private readonly StackSystem _stack = default!;
[Dependency] private readonly ElectrocutionSystem _electrocutionSystem = default!;
[Dependency] private readonly IAdminLogManager _adminLogs = default!;
public override void Initialize()
{
@@ -54,7 +53,7 @@ public sealed partial class CableSystem : EntitySystem
if (_electrocutionSystem.TryDoElectrifiedAct(uid, args.User))
return;
_adminLogs.Add(LogType.CableCut, LogImpact.Medium, $"The {ToPrettyString(uid)} at {xform.Coordinates} was cut by {ToPrettyString(args.User)}.");
_adminLogger.Add(LogType.CableCut, LogImpact.Medium, $"The {ToPrettyString(uid)} at {xform.Coordinates} was cut by {ToPrettyString(args.User)}.");
Spawn(cable.CableDroppedOnCutPrototype, xform.Coordinates);
QueueDel(uid);

View File

@@ -124,7 +124,7 @@ namespace Content.Server.Preferences.Managers
if (!_cachedPlayerPrefs.TryGetValue(userId, out var prefsData) || !prefsData.PrefsLoaded)
{
Logger.WarningS("prefs", $"User {userId} tried to modify preferences before they loaded.");
_sawmill.Warning($"User {userId} tried to modify preferences before they loaded.");
return;
}

View File

@@ -280,7 +280,7 @@ public sealed class ThrusterSystem : EntitySystem
if (!EntityManager.TryGetComponent(xform.GridUid, out ShuttleComponent? shuttleComponent))
return;
// Logger.DebugS("thruster", $"Enabled thruster {uid}");
// Logger.GetSawmill("thruster").Debug($"Enabled thruster {uid}");
switch (component.Type)
{
@@ -377,7 +377,7 @@ public sealed class ThrusterSystem : EntitySystem
if (!EntityManager.TryGetComponent(gridId, out ShuttleComponent? shuttleComponent))
return;
// Logger.DebugS("thruster", $"Disabled thruster {uid}");
// Logger.GetSawmill("thruster").Debug($"Disabled thruster {uid}");
switch (component.Type)
{

View File

@@ -439,8 +439,8 @@ public sealed class HierophantSystem : EntitySystem
for (var i = 1; i < playerCount; i++)
scalingMultiplier *= HealthScalingFactor;
Logger.Info($"Setting threshold for {uid} to {_baseHierophantHp * scalingMultiplier}");
if (_threshold.TryGetDeadThreshold(uid, out var deadThreshold, thresholds)
Logger.GetSawmill("hierophant").Info($"Setting threshold for {uid} to {_baseHierophantHp * scalingMultiplier}");
if (_threshold.TryGetDeadThreshold(uid, out var deadThreshold, thresholds)
&& deadThreshold < _baseHierophantHp * scalingMultiplier)
_threshold.SetMobStateThreshold(uid, _baseHierophantHp * scalingMultiplier, MobState.Dead, thresholds);
}

View File

@@ -16,6 +16,7 @@ public sealed partial class AbductorSystem : SharedAbductorSystem
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
[Dependency] private readonly SharedColorFlashEffectSystem _color = default!;
[Dependency] private readonly PullingSystem _pullingSystem = default!;
private static readonly ISawmill _sawmill = Logger.GetSawmill("abductor");
private static readonly EntProtoId<InstantActionComponent> SendYourself = "ActionSendYourself";
private static readonly EntProtoId<InstantActionComponent> ExitAction = "ActionExitConsole";
@@ -72,7 +73,7 @@ public sealed partial class AbductorSystem : SharedAbductorSystem
private void OnSendYourself(SendYourselfEvent ev)
{
Logger.Debug($"{ToPrettyString(ev.Performer)}");
_sawmill.Debug($"{ToPrettyString(ev.Performer)}");
AddTeleportationEffect(ev.Performer, 5.0f, TeleportationEffectEntity, out var effectEnt, true, false);
var effect = _entityManager.SpawnEntity(TeleportationEffect, ev.Target);
EnsureComp<TimedDespawnComponent>(effect, out var _);

View File

@@ -117,7 +117,7 @@ public sealed partial class ExplosionPrototype : IPrototype
{
if (_tileBreakChance.Length == 0 || _tileBreakChance.Length != _tileBreakIntensity.Length)
{
Logger.Error($"Malformed tile break chance definitions for explosion prototype: {ID}");
Logger.GetSawmill("explosion").Error($"Malformed tile break chance definitions for explosion prototype: {ID}");
return 0;
}

View File

@@ -10,6 +10,7 @@ public sealed class ClothingGrantingSystem : EntitySystem
[Dependency] private readonly IComponentFactory _componentFactory = default!;
[Dependency] private readonly ISerializationManager _serializationManager = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
private static readonly ISawmill _sawmill = Logger.GetSawmill(nameof(ClothingGrantingSystem));
public override void Initialize()
{
@@ -30,7 +31,7 @@ public sealed class ClothingGrantingSystem : EntitySystem
if (component.Components.Count > 8) // WD EDIT
{
Logger.Error("Although a component registry supports multiple components, we cannot bookkeep more than 8 component for ClothingGrantComponent at this time."); // WD EDIT
_sawmill.Error("Although a component registry supports multiple components, we cannot bookkeep more than 8 component for ClothingGrantComponent at this time."); // WD EDIT
return;
}