From 432042e945abcc4f4d08f8f91a093b030a67aa19 Mon Sep 17 00:00:00 2001 From: ilmenwe <6985194+ilmenwe@users.noreply.github.com> Date: Fri, 9 May 2025 01:26:14 +0300 Subject: [PATCH] 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 :cl: - tweak: Logger to Logger.GetSawmill("name"); --------- Co-authored-by: ilmenwe (cherry picked from commit 2e8ffd971716d38dc6d5a520bebdf88b743045a3) --- .../Access/UI/AccessLevelControl.xaml.cs | 2 +- .../Actions/UI/ActionAlertTooltip.cs | 25 ++++++++++++++----- .../AdminMessagePopupMessage.xaml.cs | 19 +++++++++----- .../AdminMessagePopupWindow.xaml.cs | 9 ++++++- .../UI/CustomControls/CommandButton.cs | 2 +- .../UI/Notes/AdminNotesLine.xaml.cs | 2 +- .../ContextMenu/UI/ContextMenuUIController.cs | 4 +-- .../ContextMenu/UI/EntityMenuUIController.cs | 2 +- .../Controls/GuideEntityEmbed.xaml.cs | 2 +- .../Controls/GuideReagentEmbed.xaml.cs | 4 +-- .../Controls/GuideReagentGroupEmbed.xaml.cs | 2 +- .../Controls/GuideTechDisciplineEmbed.xaml.cs | 2 +- .../Controls/GuideTechnologyEmbed.xaml.cs | 4 +-- .../Controls/GuidebookWindow.xaml.cs | 4 +-- .../Guidebook/DocumentParsingManager.cs | 4 +-- Content.Client/Guidebook/Richtext/Table.cs | 2 +- .../Guidebook/Richtext/TextLinkTag.cs | 4 +-- Content.Client/LateJoin/LateJoinGui.cs | 4 +-- Content.Client/Launcher/LauncherConnecting.cs | 4 +-- .../Lobby/UI/HumanoidProfileEditor.xaml.cs | 4 +-- Content.Client/MainMenu/MainMenu.cs | 2 +- .../Data/GeneratedParallaxTextureSource.cs | 4 +-- Content.Client/Screenshot/ScreenshotHook.cs | 8 +++--- .../UserInterface/Controls/SlotControl.cs | 2 +- .../Systems/Actions/ActionUIController.cs | 2 +- .../Systems/Alerts/Widgets/AlertsUI.xaml.cs | 4 +-- .../Systems/Bwoink/AHelpUIController.cs | 2 +- .../Systems/Chat/Widgets/ChatBox.xaml.cs | 2 +- .../Guidebook/GuidebookUIController.cs | 4 +-- .../Inventory/Controls/InventoryDisplay.cs | 4 +-- .../Inventory/Controls/ItemSlotUIContainer.cs | 4 +-- .../Inventory/InventoryUIController.cs | 2 +- .../Systems/Viewport/ViewportUIController.cs | 2 +- Content.Replay/Menu/ReplayMainMenu.cs | 2 +- .../Commands/DepartmentBanCommand.cs | 2 +- .../Administration/Commands/RoleBanCommand.cs | 4 +-- .../Administration/Notes/UserNotesEui.cs | 4 +-- .../TileAtmosCollectionSerializer.cs | 7 +++--- Content.Server/Chat/Managers/ChatManager.cs | 5 +++- .../Construction/Completions/BuildMech.cs | 8 +++--- Content.Server/Database/ServerDbManager.cs | 6 ++--- .../Unit/EntitySystems/DisposableSystem.cs | 2 +- Content.Server/EUI/EuiManager.cs | 2 +- .../GameTicking/Commands/JoinGameCommand.cs | 2 +- Content.Server/MoMMI/MoMMILink.cs | 7 ++++-- .../ReverseEngineeringSystem.cs | 4 ++- .../Power/EntitySystems/CableSystem.cs | 3 +-- .../Managers/ServerPreferencesManager.cs | 2 +- .../Shuttles/Systems/ThrusterSystem.cs | 4 +-- .../Mobs/Hierophant/HierophantSystem.cs | 4 +-- .../Antags/Abductor/AbductorSystem.Actions.cs | 3 ++- .../Explosion/ExplosionPrototype.cs | 2 +- .../Systems/ClothingGrantingSystem.cs | 3 ++- 53 files changed, 130 insertions(+), 93 deletions(-) diff --git a/Content.Client/Access/UI/AccessLevelControl.xaml.cs b/Content.Client/Access/UI/AccessLevelControl.xaml.cs index 34db80b7af..5cc9842fc6 100644 --- a/Content.Client/Access/UI/AccessLevelControl.xaml.cs +++ b/Content.Client/Access/UI/AccessLevelControl.xaml.cs @@ -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; } diff --git a/Content.Client/Actions/UI/ActionAlertTooltip.cs b/Content.Client/Actions/UI/ActionAlertTooltip.cs index ddc498b6e9..c126c27ce7 100644 --- a/Content.Client/Actions/UI/ActionAlertTooltip.cs +++ b/Content.Client/Actions/UI/ActionAlertTooltip.cs @@ -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 diff --git a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs index 7bb425f618..27399817f9 100644 --- a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs +++ b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupMessage.xaml.cs @@ -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); + } } } diff --git a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs index bf2ca9bec4..7b6e6cee2f 100644 --- a/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs +++ b/Content.Client/Administration/UI/AdminRemarks/AdminMessagePopupWindow.xaml.cs @@ -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) diff --git a/Content.Client/Administration/UI/CustomControls/CommandButton.cs b/Content.Client/Administration/UI/CustomControls/CommandButton.cs index 3084767563..16b7015150 100644 --- a/Content.Client/Administration/UI/CustomControls/CommandButton.cs +++ b/Content.Client/Administration/UI/CustomControls/CommandButton.cs @@ -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; } diff --git a/Content.Client/Administration/UI/Notes/AdminNotesLine.xaml.cs b/Content.Client/Administration/UI/Notes/AdminNotesLine.xaml.cs index ead1d8b00e..3ecb79bab6 100644 --- a/Content.Client/Administration/UI/Notes/AdminNotesLine.xaml.cs +++ b/Content.Client/Administration/UI/Notes/AdminNotesLine.xaml.cs @@ -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 { diff --git a/Content.Client/ContextMenu/UI/ContextMenuUIController.cs b/Content.Client/ContextMenu/UI/ContextMenuUIController.cs index 2d94034bb9..5e4fcd22a7 100644 --- a/Content.Client/ContextMenu/UI/ContextMenuUIController.cs +++ b/Content.Client/ContextMenu/UI/ContextMenuUIController.cs @@ -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; } diff --git a/Content.Client/ContextMenu/UI/EntityMenuUIController.cs b/Content.Client/ContextMenu/UI/EntityMenuUIController.cs index b6f4dc1be2..1288b3288a 100644 --- a/Content.Client/ContextMenu/UI/EntityMenuUIController.cs +++ b/Content.Client/ContextMenu/UI/EntityMenuUIController.cs @@ -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(entity).EntityName} ({entity})"); + Logger.GetSawmill("entitymenucontroller.ui").Error($"Attempted to remove unknown entity from the entity menu: {_entityManager.GetComponent(entity).EntityName} ({entity})"); return; } diff --git a/Content.Client/Guidebook/Controls/GuideEntityEmbed.xaml.cs b/Content.Client/Guidebook/Controls/GuideEntityEmbed.xaml.cs index d0b39abb37..9e45349c6a 100644 --- a/Content.Client/Guidebook/Controls/GuideEntityEmbed.xaml.cs +++ b/Content.Client/Guidebook/Controls/GuideEntityEmbed.xaml.cs @@ -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; } diff --git a/Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs b/Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs index 537494933b..61fafba8bf 100644 --- a/Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs +++ b/Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs @@ -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(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; } diff --git a/Content.Client/Guidebook/Controls/GuideReagentGroupEmbed.xaml.cs b/Content.Client/Guidebook/Controls/GuideReagentGroupEmbed.xaml.cs index 0c9356eccb..3bb7cc0988 100644 --- a/Content.Client/Guidebook/Controls/GuideReagentGroupEmbed.xaml.cs +++ b/Content.Client/Guidebook/Controls/GuideReagentGroupEmbed.xaml.cs @@ -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; } diff --git a/Content.Client/Guidebook/Controls/GuideTechDisciplineEmbed.xaml.cs b/Content.Client/Guidebook/Controls/GuideTechDisciplineEmbed.xaml.cs index 88d264cb05..7be39e183d 100644 --- a/Content.Client/Guidebook/Controls/GuideTechDisciplineEmbed.xaml.cs +++ b/Content.Client/Guidebook/Controls/GuideTechDisciplineEmbed.xaml.cs @@ -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; } diff --git a/Content.Client/Guidebook/Controls/GuideTechnologyEmbed.xaml.cs b/Content.Client/Guidebook/Controls/GuideTechnologyEmbed.xaml.cs index d61cc2d961..2842638984 100644 --- a/Content.Client/Guidebook/Controls/GuideTechnologyEmbed.xaml.cs +++ b/Content.Client/Guidebook/Controls/GuideTechnologyEmbed.xaml.cs @@ -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(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; } diff --git a/Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs b/Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs index 3a67dca89d..51a59417ec 100644 --- a/Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs +++ b/Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs @@ -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; } diff --git a/Content.Client/Guidebook/DocumentParsingManager.cs b/Content.Client/Guidebook/DocumentParsingManager.cs index e8a0743b9e..7df7a49f95 100644 --- a/Content.Client/Guidebook/DocumentParsingManager.cs +++ b/Content.Client/Guidebook/DocumentParsingManager.cs @@ -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(); } diff --git a/Content.Client/Guidebook/Richtext/Table.cs b/Content.Client/Guidebook/Richtext/Table.cs index b6923c3698..374b36e0a6 100644 --- a/Content.Client/Guidebook/Richtext/Table.cs +++ b/Content.Client/Guidebook/Richtext/Table.cs @@ -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; } diff --git a/Content.Client/Guidebook/Richtext/TextLinkTag.cs b/Content.Client/Guidebook/Richtext/TextLinkTag.cs index b1e8460bb8..f09e3d9a47 100644 --- a/Content.Client/Guidebook/Richtext/TextLinkTag.cs +++ b/Content.Client/Guidebook/Richtext/TextLinkTag.cs @@ -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."); } } diff --git a/Content.Client/LateJoin/LateJoinGui.cs b/Content.Client/LateJoin/LateJoinGui.cs index 31c09ef1a3..b7bc49d8b7 100644 --- a/Content.Client/LateJoin/LateJoinGui.cs +++ b/Content.Client/LateJoin/LateJoinGui.cs @@ -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) { diff --git a/Content.Client/Launcher/LauncherConnecting.cs b/Content.Client/Launcher/LauncherConnecting.cs index 9625f9e31c..c0919389ea 100644 --- a/Content.Client/Launcher/LauncherConnecting.cs +++ b/Content.Client/Launcher/LauncherConnecting.cs @@ -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; } diff --git a/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs b/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs index ce235d2e00..d022bedb28 100644 --- a/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs +++ b/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs @@ -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 { diff --git a/Content.Client/MainMenu/MainMenu.cs b/Content.Client/MainMenu/MainMenu.cs index 58d94adf22..52959f2925 100644 --- a/Content.Client/MainMenu/MainMenu.cs +++ b/Content.Client/MainMenu/MainMenu.cs @@ -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); } diff --git a/Content.Client/Parallax/Data/GeneratedParallaxTextureSource.cs b/Content.Client/Parallax/Data/GeneratedParallaxTextureSource.cs index 2e69a5a562..7150c5fac6 100644 --- a/Content.Client/Parallax/Data/GeneratedParallaxTextureSource.cs +++ b/Content.Client/Parallax/Data/GeneratedParallaxTextureSource.cs @@ -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 { diff --git a/Content.Client/Screenshot/ScreenshotHook.cs b/Content.Client/Screenshot/ScreenshotHook.cs index 753691a58e..ce026e77f4 100644 --- a/Content.Client/Screenshot/ScreenshotHook.cs +++ b/Content.Client/Screenshot/ScreenshotHook.cs @@ -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."); } } diff --git a/Content.Client/UserInterface/Controls/SlotControl.cs b/Content.Client/UserInterface/Controls/SlotControl.cs index a684bb05ef..3f9c586c29 100644 --- a/Content.Client/UserInterface/Controls/SlotControl.cs +++ b/Content.Client/UserInterface/Controls/SlotControl.cs @@ -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; diff --git a/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs b/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs index bf31882b13..ff93af99ee 100644 --- a/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs +++ b/Content.Client/UserInterface/Systems/Actions/ActionUIController.cs @@ -193,7 +193,7 @@ public sealed class ActionUIController : UIController, IOnStateChanged : 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; diff --git a/Content.Client/UserInterface/Systems/Inventory/InventoryUIController.cs b/Content.Client/UserInterface/Systems/Inventory/InventoryUIController.cs index d3f68b1a81..7ddbe41c2f 100644 --- a/Content.Client/UserInterface/Systems/Inventory/InventoryUIController.cs +++ b/Content.Client/UserInterface/Systems/Inventory/InventoryUIController.cs @@ -242,7 +242,7 @@ public sealed class InventoryUIController : UIController, IOnStateEntered, MappingDataNode>, ITypeCopier> { + 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 /// The maximum length a player-sent message can be sent /// @@ -57,6 +59,7 @@ namespace Content.Server.Chat.Managers public void Initialize() { + _sawmill = Logger.GetSawmill("SERVER"); _netManager.RegisterNetMessage(); _netManager.RegisterNetMessage(); @@ -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}"); } diff --git a/Content.Server/Construction/Completions/BuildMech.cs b/Content.Server/Construction/Completions/BuildMech.cs index e11c79d851..6acea143b0 100644 --- a/Content.Server/Construction/Completions/BuildMech.cs +++ b/Content.Server/Construction/Completions/BuildMech.cs @@ -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(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; } diff --git a/Content.Server/Database/ServerDbManager.cs b/Content.Server/Database/ServerDbManager.cs index c614e231cc..01b2daea86 100644 --- a/Content.Server/Database/ServerDbManager.cs +++ b/Content.Server/Database/ServerDbManager.cs @@ -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. diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs index bcf240df53..da58194f68 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs @@ -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) diff --git a/Content.Server/EUI/EuiManager.cs b/Content.Server/EUI/EuiManager.cs index b789c9c8f8..0f0c9db096 100644 --- a/Content.Server/EUI/EuiManager.cs +++ b/Content.Server/EUI/EuiManager.cs @@ -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; } diff --git a/Content.Server/GameTicking/Commands/JoinGameCommand.cs b/Content.Server/GameTicking/Commands/JoinGameCommand.cs index 3276b91200..503bcc3064 100644 --- a/Content.Server/GameTicking/Commands/JoinGameCommand.cs +++ b/Content.Server/GameTicking/Commands/JoinGameCommand.cs @@ -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; } diff --git a/Content.Server/MoMMI/MoMMILink.cs b/Content.Server/MoMMI/MoMMILink.cs index eff4d3e3f7..adda83f1fc 100644 --- a/Content.Server/MoMMI/MoMMILink.cs +++ b/Content.Server/MoMMI/MoMMILink.cs @@ -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; } diff --git a/Content.Server/Nyanotrasen/ReverseEngineering/ReverseEngineeringSystem.cs b/Content.Server/Nyanotrasen/ReverseEngineering/ReverseEngineeringSystem.cs index 15df39eed8..a1a0ff22eb 100644 --- a/Content.Server/Nyanotrasen/ReverseEngineering/ReverseEngineeringSystem.cs +++ b/Content.Server/Nyanotrasen/ReverseEngineering/ReverseEngineeringSystem.cs @@ -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(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; } diff --git a/Content.Server/Power/EntitySystems/CableSystem.cs b/Content.Server/Power/EntitySystems/CableSystem.cs index dfa73783de..db44323007 100644 --- a/Content.Server/Power/EntitySystems/CableSystem.cs +++ b/Content.Server/Power/EntitySystems/CableSystem.cs @@ -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); diff --git a/Content.Server/Preferences/Managers/ServerPreferencesManager.cs b/Content.Server/Preferences/Managers/ServerPreferencesManager.cs index 929586d735..ac280dac0a 100644 --- a/Content.Server/Preferences/Managers/ServerPreferencesManager.cs +++ b/Content.Server/Preferences/Managers/ServerPreferencesManager.cs @@ -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; } diff --git a/Content.Server/Shuttles/Systems/ThrusterSystem.cs b/Content.Server/Shuttles/Systems/ThrusterSystem.cs index b142680213..30c6cf6e37 100644 --- a/Content.Server/Shuttles/Systems/ThrusterSystem.cs +++ b/Content.Server/Shuttles/Systems/ThrusterSystem.cs @@ -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) { diff --git a/Content.Server/_Lavaland/Mobs/Hierophant/HierophantSystem.cs b/Content.Server/_Lavaland/Mobs/Hierophant/HierophantSystem.cs index 9f2fd0d6e7..9288a951fa 100644 --- a/Content.Server/_Lavaland/Mobs/Hierophant/HierophantSystem.cs +++ b/Content.Server/_Lavaland/Mobs/Hierophant/HierophantSystem.cs @@ -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); } diff --git a/Content.Server/_Shitmed/Antags/Abductor/AbductorSystem.Actions.cs b/Content.Server/_Shitmed/Antags/Abductor/AbductorSystem.Actions.cs index f460a3c898..584a66d98f 100644 --- a/Content.Server/_Shitmed/Antags/Abductor/AbductorSystem.Actions.cs +++ b/Content.Server/_Shitmed/Antags/Abductor/AbductorSystem.Actions.cs @@ -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 SendYourself = "ActionSendYourself"; private static readonly EntProtoId 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(effect, out var _); diff --git a/Content.Shared/Explosion/ExplosionPrototype.cs b/Content.Shared/Explosion/ExplosionPrototype.cs index df2fb18360..016e53ce48 100644 --- a/Content.Shared/Explosion/ExplosionPrototype.cs +++ b/Content.Shared/Explosion/ExplosionPrototype.cs @@ -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; } diff --git a/Content.Shared/SimpleStation14/Clothing/Systems/ClothingGrantingSystem.cs b/Content.Shared/SimpleStation14/Clothing/Systems/ClothingGrantingSystem.cs index c5fa8ea4eb..d00de38533 100644 --- a/Content.Shared/SimpleStation14/Clothing/Systems/ClothingGrantingSystem.cs +++ b/Content.Shared/SimpleStation14/Clothing/Systems/ClothingGrantingSystem.cs @@ -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; }