From 971bcc7ac3419e74adcb464139700cae17532a08 Mon Sep 17 00:00:00 2001 From: Robbie Lodico Date: Mon, 20 Jan 2025 01:47:42 +0100 Subject: [PATCH] chore: remove homebrew Intersect logging and replace with Serilog and Microsoft ILogger --- .../ManifestTest.cs | 1 - .../ExampleCommandLineOptions.cs | 2 - .../ExamplePluginConfiguration.cs | 1 - .../Manifest.cs | 2 - .../ExamplePluginServerPacketHandler.cs | 8 +- .../ExampleServerPluginEntry.cs | 1 - .../Manifest.cs | 2 - .../ExamplePluginClientPacketHandler.cs | 3 +- .../Hooks/ExamplePluginLoginPostHook.cs | 5 +- .../Client/ExamplePluginClientPacket.cs | 1 - .../Server/ExamplePluginServerPacket.cs | 1 - .../Collections/DatabaseObjectLookup.cs | 11 +- .../Config/DatabaseOptions.cs | 5 +- .../Config/LoggingOptions.cs | 7 +- .../Config/PaperdollOptions.cs | 1 - .../Config/Passability.cs | 1 - .../Configuration/ClientConfiguration.cs | 7 +- .../Configuration/ConfigurationHelper.cs | 38 ++- .../Core/ApplicationContext.cs | 6 + .../Core/IApplicationContext.cs | 7 +- .../Entities/ExperienceCurve.cs | 6 +- .../GameObjects/AnimationBase.cs | 2 - .../Annotations/EditorBooleanAttribute.cs | 1 - .../Annotations/EditorDictionaryAttribute.cs | 2 +- .../Annotations/EditorFormattedAttribute.cs | 3 +- .../Annotations/EditorReferenceAttribute.cs | 1 - .../GameObjects/ClassBase.cs | 2 - .../GameObjects/Conditions/ConditionList.cs | 1 - .../GameObjects/Crafting/CraftBase.cs | 2 - .../GameObjects/Crafting/CraftingTableBase.cs | 2 - .../GameObjects/Events/EventBase.cs | 1 - .../GameObjects/Events/EventPage.cs | 1 - .../GameObjects/Events/VariableMod.cs | 1 - .../GameObjects/ItemBase.cs | 2 - .../GameObjects/Maps/MapAttribute.cs | 1 - .../GameObjects/Maps/MapAutotiles.cs | 15 +- .../GameObjects/Maps/MapBase.cs | 1 - .../GameObjects/NpcBase.cs | 2 - .../GameObjects/ProjectileBase.cs | 1 - .../GameObjects/QuestBase.cs | 2 - .../GameObjects/ResourceBase.cs | 3 - .../GameObjects/ShopBase.cs | 2 - .../GameObjects/SpellBase.cs | 2 - .../GameObjects/TilesetBase.cs | 1 - .../GameObjects/TimeBase.cs | 1 - .../GameObjects/Variables/VariableValue.cs | 11 +- .../IO/Files/FileSystemHelper.cs | 10 +- .../Intersect.Framework.Core.csproj | 1 + .../Logging/Formatting/DefaultFormatter.cs | 133 --------- .../Logging/Formatting/ILogFormatter.cs | 16 -- .../Logging/ILogger.cs | 69 ----- .../Logging/LegacyLogging.cs | 6 - .../Logging/LogConfiguration.cs | 54 ---- .../Logging/LogLevel.cs | 29 -- .../Logging/Output/ILogOutput.cs | 33 --- .../Models/ObjectCacheData.cs | 2 + .../Models/ObjectDataDiskCache.cs | 11 +- .../Intersect.Framework.Core/Network/Ceras.cs | 12 +- .../Network/INetwork.cs | 1 - .../Network/IntersectPacket.cs | 4 +- .../Network/MessagePacker.cs | 5 +- .../Network/PacketHandlerRegistry.cs | 25 +- .../Network/PacketTypeRegistry.cs | 9 +- .../Plugins/IPluginBaseContext.cs | 1 - .../Plugins/Interfaces/CreateLoggerOptions.cs | 18 +- .../Plugins/Interfaces/ILoggingHelper.cs | 9 +- .../Plugins/Interfaces/IManifestHelper.cs | 1 - .../Plugins/Manifests/JsonManifest.cs | 2 - .../Plugins/Manifests/Types/Authors.cs | 1 - .../Reflection/ReflectionUtils.cs | 16 +- .../Serialization/SafeStringEnumConverter.cs | 42 +++ Intersect (Core)/Console.cs | 2 - Intersect (Core)/Core/ApplicationContext`2.cs | 41 ++- .../CommonExperiments.Core.cs | 257 ----------------- .../CommonExperiments.Flags.cs | 15 - .../CommonExperiments.Static.cs | 56 ---- .../ExperimentNamespace.cs | 8 - .../ExperimentalFeatures/ExperimentalFlag.cs | 84 ------ .../ExperimentalFlagAlias.cs | 77 ----- .../ExperimentalFlagAliasAttribute.cs | 20 -- .../ExperimentalFlagConverter.cs | 37 --- .../ExperimentalFeatures/IExperimentalFlag.cs | 20 -- .../ExperimentalFeatures/IFlagProvider.cs | 15 - .../Core/ServiceLifecycleFailureException.cs | 1 - Intersect (Core)/CustomColors.cs | 17 +- .../Extensions/LogLevelExtensions.cs | 36 --- Intersect (Core)/Factories/FactoryRegistry.cs | 14 +- Intersect (Core)/Intersect.Core.csproj | 2 +- .../Localization/LocaleArgument.cs | 1 - .../Localization/LocaleCommandNamespace.cs | 1 - .../Logging/Formatting/PrettyFormatter.cs | 35 --- Intersect (Core)/Logging/Log.cs | 239 ---------------- Intersect (Core)/Logging/Logger.cs | 264 ------------------ Intersect (Core)/Logging/MemoryDump.cs | 95 ------- .../Logging/Output/ConciseConsoleOutput.cs | 93 ------ .../Logging/Output/ConsoleOutput.cs | 77 ----- Intersect (Core)/Logging/Output/FileOutput.cs | 189 ------------- .../Network/AbstractConnection.cs | 9 +- Intersect (Core)/Network/AbstractNetwork.cs | 19 +- .../Network/AsymmetricEncryptedPacket.cs | 21 +- Intersect (Core)/Network/ConnectionPacket.cs | 19 +- Intersect (Core)/Network/NetworkThread.cs | 10 +- Intersect (Core)/Network/PacketQueue.cs | 14 +- .../Network/Packets/ApprovalPacket.cs | 21 +- .../Network/Packets/HailPacket.cs | 16 +- .../Contexts/PluginBootstrapContext.cs | 1 - .../Plugins/Contexts/PluginContext.cs | 1 - .../Plugins/Helpers/CommandLineHelper.cs | 16 +- .../Plugins/Helpers/LoggingHelper.cs | 48 ++-- .../Plugins/Loaders/ManifestLoader.cs | 15 +- .../Loaders/MissingPluginEntryException.cs | 2 - .../Plugins/Loaders/PluginLoader.Assembly.cs | 9 +- .../Loaders/PluginLoader.Configuration.cs | 8 +- .../Plugins/Loaders/PluginLoader.Discovery.cs | 5 +- Intersect (Core)/Plugins/PluginHelper.cs | 4 +- Intersect (Core)/Plugins/PluginInstance.cs | 1 - Intersect (Core)/Plugins/PluginService.cs | 5 +- .../Threading/ConcurrentInstance.cs | 16 +- Intersect (Core)/Updater/Updater.cs | 7 +- .../Utilities/AlphanumComparator.cs | 1 - Intersect (Core)/Utilities/Formula.cs | 24 +- .../Utilities/GameObjectTypeUtils.cs | 1 - Intersect (Core)/Utilities/Retry.cs | 16 +- Intersect.Client.Core/Core/Audio.cs | 5 +- Intersect.Client.Core/Core/Bootstrapper.cs | 54 +++- .../Core/ClientCommandLineOptions.cs | 1 - Intersect.Client.Core/Core/ClientContext.cs | 4 +- Intersect.Client.Core/Entities/Entity.cs | 13 +- .../Entities/Events/Event.cs | 7 +- Intersect.Client.Core/Entities/Player.cs | 21 +- .../Interface/Debugging/DebugWindow.cs | 1 - .../Interface/Game/AnnouncementWindow.cs | 1 - .../Components/RowContainerComponent.cs | 5 +- .../ItemDescriptionWindow.cs | 9 +- .../Interface/Game/EntityPanel/EntityBox.cs | 7 +- .../Interface/Game/PictureWindow.cs | 1 - .../Interface/Menu/CreateCharacterWindow.cs | 5 +- .../Interface/Menu/MainMenuWindow.cs | 5 +- .../Interface/Menu/ResetPasswordWindow.cs | 1 - Intersect.Client.Core/Localization/Strings.cs | 28 +- Intersect.Client.Core/Maps/MapInstance.cs | 10 +- .../MonoGame/Audio/MonoMusicInstance.cs | 1 - .../MonoGame/Audio/MonoMusicSource.cs | 7 +- .../MonoGame/Audio/MonoSoundInstance.cs | 5 +- .../MonoGame/Audio/MonoSoundSource.cs | 6 +- .../MonoGame/Database/MonoDatabase.cs | 14 +- .../File Management/MonoContentManager.cs | 8 +- .../MonoGame/Graphics/MonoFont.cs | 12 +- .../MonoGame/Graphics/MonoRenderTexture.cs | 1 - .../MonoGame/Graphics/MonoShader.cs | 1 - .../MonoGame/Graphics/MonoTexture.cs | 10 +- .../MonoGame/Graphics/MonoTileBuffer.cs | 17 +- .../MonoGame/Input/MonoInput.cs | 7 +- .../MonoGame/IntersectGame.cs | 17 +- .../MonoGame/Network/MonoSocket.cs | 13 +- Intersect.Client.Core/Networking/Network.cs | 9 +- .../Networking/PacketHandler.cs | 22 +- .../ServerStatusResponsePacketHandler.cs | 5 +- .../Plugins/Helpers/PluginPacketSender.cs | 7 +- Intersect.Client.Core/Program.cs | 12 +- Intersect.Client.Core/ThirdParty/Steam.cs | 8 +- .../Database/JsonDatabase.cs | 22 +- .../File Management/GameContentManager.cs | 20 +- .../Graphics/GameTexture.cs | 8 +- .../Gwen/Control/Base.cs | 12 +- .../Gwen/Control/Button.cs | 1 - .../Gwen/Control/CheckBox.cs | 1 - .../Gwen/Control/ComboBox.cs | 1 - .../Gwen/Control/ImagePanel.cs | 1 - .../Gwen/Control/Label.cs | 1 - .../Gwen/Control/LabeledCheckBox.cs | 1 - .../Gwen/Control/LabeledHorizontalSlider.cs | 1 - .../Gwen/Control/Layout/Table.cs | 1 - .../Gwen/Control/ListBox.cs | 2 - .../Gwen/Control/Menu.cs | 1 - .../Gwen/Control/ResizableControl.cs | 1 - .../Gwen/Control/RichLabel.cs | 1 - .../Gwen/Control/ScrollBar.cs | 1 - .../Gwen/Control/ScrollControl.cs | 1 - .../Gwen/Control/Slider.cs | 1 - .../Gwen/Control/TextBox.cs | 12 +- .../Gwen/Control/WindowControl.cs | 2 - .../Gwen/ControlInternal/Dragger.cs | 1 - .../Gwen/Input/InputHandler.cs | 1 - .../Gwen/Renderer/Base.cs | 2 +- .../Gwen/Renderer/IntersectRenderer.cs | 5 +- Intersect.Client.Framework/Gwen/Skin/Base.cs | 2 +- .../Gwen/Skin/TexturedBase.cs | 2 - Intersect.Client.Framework/Gwen/Util.cs | 1 - Intersect.Editor/Content/ContentManager.cs | 14 +- Intersect.Editor/Content/Texture.cs | 19 +- Intersect.Editor/Content/TexturePacker.cs | 1 - Intersect.Editor/Core/Graphics.cs | 10 +- Intersect.Editor/Core/Main.cs | 2 +- Intersect.Editor/Core/Preferences.cs | 1 - Intersect.Editor/Core/Program.cs | 17 +- Intersect.Editor/Entities/Animation.cs | 1 - .../Forms/Controls/LightEditorCtrl.cs | 1 - .../Controls/MapAttributeTooltip.Designer.cs | 1 - .../Forms/Controls/MapTreeList.cs | 5 +- .../Forms/Controls/SearchableDarkTreeView.cs | 1 - .../Forms/DockingElements/frmMapEditor.cs | 17 +- .../Forms/DockingElements/frmMapGrid.cs | 3 - .../Forms/DockingElements/frmMapLayers.cs | 2 - .../Forms/DockingElements/frmMapList.cs | 1 - .../Forms/DockingElements/frmMapProperties.cs | 1 - Intersect.Editor/Forms/Editors/EditorForm.cs | 4 +- .../Forms/Editors/Events/CommandPrinter.cs | 8 +- .../Event Commands/EventCommand_Warp.cs | 1 - .../Forms/Editors/Events/frmEvent.cs | 2 - .../Forms/Editors/Quest/Quest_TaskEditor.cs | 8 +- .../Forms/Editors/Quest/frmQuest.cs | 8 +- .../Forms/Editors/frmAnimation.cs | 3 - Intersect.Editor/Forms/Editors/frmClass.cs | 1 - .../Forms/Editors/frmCommonEvent.cs | 1 - Intersect.Editor/Forms/Editors/frmItem.cs | 1 - Intersect.Editor/Forms/Editors/frmNpc.cs | 2 - Intersect.Editor/Forms/Editors/frmResource.cs | 1 - Intersect.Editor/Forms/Editors/frmSpell.cs | 1 - Intersect.Editor/Forms/Editors/frmTime.cs | 2 - Intersect.Editor/Forms/Helpers/GridHelper.cs | 1 - Intersect.Editor/Forms/frmLogin.cs | 4 +- Intersect.Editor/Forms/frmMain.cs | 2 - Intersect.Editor/Forms/frmUpdate.cs | 4 +- Intersect.Editor/Localization/Localizer.cs | 9 +- Intersect.Editor/Localization/Strings.cs | 12 +- Intersect.Editor/Maps/MapGrid.cs | 3 - Intersect.Editor/Maps/MapInstance.cs | 1 - Intersect.Editor/Maps/MapProperties.cs | 2 - Intersect.Editor/Networking/Network.cs | 8 +- Intersect.Editor/Networking/PacketHandler.cs | 17 +- .../ServerStatusResponsePacketHandler.cs | 3 +- Intersect.Network/ClientNetwork.cs | 10 +- Intersect.Network/LiteNetLib/AesAlgorithm.cs | 12 +- .../LiteNetLib/AesGcmAlgorithm.cs | 23 +- .../LiteNetLib/LiteNetLibConnection.cs | 25 +- .../LiteNetLib/LiteNetLibInterface.cs | 87 +++--- .../LiteNetLib/LiteNetLibLogger.cs | 7 +- .../LiteNetLibUnconnectedPacketSender.cs | 5 +- .../LiteNetLib/NetLogLevelExtensions.cs | 8 +- Intersect.Server.Core/Core/Bootstrapper.cs | 32 ++- .../CommandParserErrorsNamespace.cs | 1 - .../CommandParserFormattingNamespace.cs | 1 - .../Core/ExperimentalFeatures/Experiments.cs | 36 --- .../Core/MapInstancing/InstanceProcessor.cs | 4 +- Intersect.Server.Core/Core/ServerContext.cs | 26 +- .../Core/ServerContextFactory.cs | 5 +- .../Sqlite/SqliteNetCoreGuidPatch.cs | 19 +- .../UserVariablePopulateNewColumnId.cs | 15 +- .../Database/DatabaseTypeMigrationService.cs | 31 +- Intersect.Server.Core/Database/DbInterface.cs | 141 +++++----- Intersect.Server.Core/Database/DbLogger.cs | 65 ----- .../Database/DbLoggerProvider.cs | 23 -- .../DbUpdateConcurrencyExceptionExtensions.cs | 6 +- .../Database/GameData/IGameContext.cs | 1 - .../GameData/Migrations/Beta6Migration.cs | 3 - .../FixQuestTaskCompletionEventsMigration.cs | 9 +- .../Database/IntersectDbContext.cs | 15 +- .../Database/IntersectLoggerFactory.cs | 46 ++- .../Database/Logging/ILoggingContext.cs | 1 - .../Database/Logging/LoggingContext.cs | 2 - .../Database/Logging/RequestLog.cs | 4 +- .../Database/Logging/Seed/SeedTrades.cs | 1 - .../Database/MigrationBuilderExtensions.cs | 1 - .../Database/MigrationScheduler.cs | 7 +- .../Database/PlayerData/Api/RefreshToken.cs | 58 ++-- .../Database/PlayerData/Ban.cs | 23 +- .../Database/PlayerData/IPlayerContext.cs | 1 - .../Migrations/GuildBankMaxSlotMigration.cs | 7 +- .../Database/PlayerData/Mute.cs | 41 +-- .../Database/PlayerData/Players/Bag.cs | 12 +- .../Database/PlayerData/Players/BankSlot.cs | 1 - .../Database/PlayerData/Players/Friend.cs | 2 - .../Database/PlayerData/Players/Guild.cs | 22 +- .../Database/PlayerData/Players/HotbarSlot.cs | 1 - .../PlayerData/Players/InventorySlot.cs | 1 - .../PlayerData/Players/PlayerVariable.cs | 1 - .../Database/PlayerData/Players/Quest.cs | 2 - .../Database/PlayerData/Players/SpellSlot.cs | 1 - .../Database/PlayerData/Players/Switch.cs | 2 - .../PlayerData/Security/UserRights.cs | 2 - .../Database/PlayerData/SeedData/SeedUsers.cs | 2 - .../Database/PlayerData/User.cs | 85 +++--- .../Database/SqliteNetCoreGuidPatch.cs | 18 +- .../Entities/BankInterface.cs | 41 +-- Intersect.Server.Core/Entities/Combat/Dash.cs | 14 +- Intersect.Server.Core/Entities/Entity.cs | 14 +- .../Entities/Events/Event.cs | 11 +- Intersect.Server.Core/Entities/Npc.cs | 7 +- .../Entities/Pathfinding/Pathfinder.cs | 10 +- .../Entities/Player.Database.cs | 45 +-- Intersect.Server.Core/Entities/Player.cs | 50 ++-- .../Extensions/QueryableExtensions.cs | 1 - Intersect.Server.Core/General/Formulas.cs | 2 - Intersect.Server.Core/General/Time.cs | 5 +- .../Localization/CommandsNamespace.cs | 8 - Intersect.Server.Core/Localization/Strings.cs | 7 +- Intersect.Server.Core/Maps/MapController.cs | 8 +- Intersect.Server.Core/Maps/MapGrid.cs | 1 - Intersect.Server.Core/Maps/MapInstance.cs | 7 +- Intersect.Server.Core/Maps/MapItemInstance.cs | 1 - Intersect.Server.Core/Metrics/Histogram.cs | 1 - Intersect.Server.Core/Metrics/MetricsRoot.cs | 1 - .../Game/20180905042857_Initial.Designer.cs | 1 - ...37_SpellUpgrades_OnHit_Shields.Designer.cs | 1 - .../20190306224847_BoundSpells.Designer.cs | 1 - ...55_ItemRarityAndSpellQuickCast.Designer.cs | 1 - ...00628_AddingCraftingQuantities.Designer.cs | 1 - ...819_CombiningSwitchesVariables.Designer.cs | 1 - ...038_AddingExpOveridesToClasses.Designer.cs | 1 - ...705_AddingFoldersToGameObjects.Designer.cs | 1 - ...14158_AddingFoldersToVaraibles.Designer.cs | 1 - ...ingAnimationSoundCompletionOpt.Designer.cs | 1 - ...SpellUpgrades_Percentage_Buffs.Designer.cs | 1 - ...pgrades_Percentage_Based_Stats.Designer.cs | 1 - ..._Effects_Event_Upgrades_Labels.Designer.cs | 1 - ..._MoreGraularAttackSpeedOptions.Designer.cs | 1 - ...emAndSpellCooldownImprovements.Designer.cs | 1 - ..._EnablingCerasVersionTolerance.Designer.cs | 1 - ...1016122614_AddItemAndNpcColors.Designer.cs | 1 - .../20201222164741_NpcResetRadius.Designer.cs | 1 - ...3_AddItemSpellIgnoreCdrOptions.Designer.cs | 1 - ...IndividualizedLootOptionToNpcs.Designer.cs | 1 - ...gQuestCategoriesAndOrderValues.Designer.cs | 1 - ...10512071349_BoundItemExtension.Designer.cs | 1 - ...0210513080440_AddItemStackCaps.Designer.cs | 1 - ...AddedCanGuildBankOptionToItems.Designer.cs | 1 - ...611154131_AddingGuildVariables.Designer.cs | 1 - ...ddingRequirementNotMetMessages.Designer.cs | 1 - ...630114724_CraftingCommonEvents.Designer.cs | 1 - ...3145618_AddingShopSoundEffects.Designer.cs | 1 - ...5153451_TickAnimationMigration.Designer.cs | 1 - ...026130945_NpcImmunityMigration.Designer.cs | 1 - ...5_FixQuestTaskCompletionEvents.Designer.cs | 1 - ...20220415212418_BlockProperties.Designer.cs | 1 - .../20220417193749_RandomCrafting.Designer.cs | 1 - ...AddingHideEquipmentMapProperty.Designer.cs | 1 - .../20220708174300_GrappleOptions.Designer.cs | 1 - ...1194419_AddedCraftRequirements.Designer.cs | 1 - ...0220925050711_CustomAnimations.Designer.cs | 1 - ...edConfigurableItemDespawnTimes.Designer.cs | 1 - ..._MultipleBonusEffectsMigration.Designer.cs | 1 - ...0221016173617_AddUserVariables.Designer.cs | 1 - .../20221017220000_DropColumns.designer.cs | 1 - .../20221018220000_PatchTables.Designer.cs | 1 - .../20191118024649_RequestLogs.Designer.cs | 1 - ...9230003_AddUserActivityHistory.Designer.cs | 1 - ...0210414222302_AddedChatLogging.Designer.cs | 1 - ...20210515114555_LogPlayerTrades.Designer.cs | 1 - ...095613_AddGuildActivityLogging.Designer.cs | 1 - ...20180927161502_InitialPlayerDb.Designer.cs | 1 - ...0190310001204_AddRefreshTokens.Designer.cs | 1 - ...0013418_StandardizeVocabulary1.Designer.cs | 1 - ...927_CombiningSwitchesVariables.Designer.cs | 1 - ...3420_Custom_Player_Name_Colors.Designer.cs | 1 - ...30214333_PlayerUpgrades_Labels.Designer.cs | 1 - ...126025000_RefactoringCooldowns.Designer.cs | 1 - ...FriendsForeignKeyContraintFail.Designer.cs | 1 - ...1145105_SavingPlayerLabelsInDb.Designer.cs | 1 - ...01017065035_AddColorToEntities.Designer.cs | 1 - ...414121435_TrackUserPlayerStats.Designer.cs | 1 - ...540_AddingGuildsWithGuildBanks.Designer.cs | 1 - ...TrackPlaytimeAsULongsInSeconds.Designer.cs | 1 - ...611184605_AddingGuildVariables.Designer.cs | 1 - ...427_GuildBankMaxSlotsMigration.Designer.cs | 1 - ...03141119_InstanceWarpMigration.Designer.cs | 1 - ...0221016173603_AddUserVariables.Designer.cs | 1 - .../20221017220000_DropColumns.Designer.cs | 1 - .../20221018220000_PatchTables.Designer.cs | 1 - .../20221119214350_ItemProperties.Designer.cs | 1 - Intersect.Server.Core/Networking/Client.cs | 25 +- .../Networking/PacketHandler.cs | 52 ++-- .../Networking/PacketSender.cs | 28 +- .../Core/CommandParsing/CommandParser.cs | 1 - .../Core/CommandParsing/Commands/Command.cs | 1 - .../Core/CommandParsing/Commands/ICommand.cs | 1 - .../Core/CommandParsing/Errors/ParserError.cs | 1 - .../Core/CommandParsing/ParserContext.cs | 1 - .../Core/Commands/ExperimentsCommand.cs | 66 ----- .../Core/Commands/PanicCommand.cs | 8 +- .../Core/ConsoleService.ConsoleThread.cs | 10 +- Intersect.Server/Core/FullServerContext.cs | 31 +- .../Game/20180905042857_Initial.Designer.cs | 1 - ...37_SpellUpgrades_OnHit_Shields.Designer.cs | 1 - .../20190306224847_BoundSpells.Designer.cs | 1 - ...55_ItemRarityAndSpellQuickCast.Designer.cs | 1 - ...00628_AddingCraftingQuantities.Designer.cs | 1 - ...819_CombiningSwitchesVariables.Designer.cs | 1 - ...038_AddingExpOveridesToClasses.Designer.cs | 1 - ...705_AddingFoldersToGameObjects.Designer.cs | 1 - ...14158_AddingFoldersToVaraibles.Designer.cs | 1 - ...ingAnimationSoundCompletionOpt.Designer.cs | 1 - ...SpellUpgrades_Percentage_Buffs.Designer.cs | 1 - ...pgrades_Percentage_Based_Stats.Designer.cs | 1 - ..._Effects_Event_Upgrades_Labels.Designer.cs | 1 - ..._MoreGraularAttackSpeedOptions.Designer.cs | 1 - ...emAndSpellCooldownImprovements.Designer.cs | 1 - ..._EnablingCerasVersionTolerance.Designer.cs | 1 - ...1016122614_AddItemAndNpcColors.Designer.cs | 1 - .../20201222164741_NpcResetRadius.Designer.cs | 1 - ...3_AddItemSpellIgnoreCdrOptions.Designer.cs | 1 - ...IndividualizedLootOptionToNpcs.Designer.cs | 1 - ...gQuestCategoriesAndOrderValues.Designer.cs | 1 - ...10512071349_BoundItemExtension.Designer.cs | 1 - ...0210513080440_AddItemStackCaps.Designer.cs | 1 - ...AddedCanGuildBankOptionToItems.Designer.cs | 1 - ...611154131_AddingGuildVariables.Designer.cs | 1 - ...ddingRequirementNotMetMessages.Designer.cs | 1 - ...630114724_CraftingCommonEvents.Designer.cs | 1 - ...3145618_AddingShopSoundEffects.Designer.cs | 1 - ...5153451_TickAnimationMigration.Designer.cs | 1 - ...026130945_NpcImmunityMigration.Designer.cs | 1 - ...5_FixQuestTaskCompletionEvents.Designer.cs | 1 - ...20220415212418_BlockProperties.Designer.cs | 1 - .../20220417193749_RandomCrafting.Designer.cs | 1 - ...AddingHideEquipmentMapProperty.Designer.cs | 1 - .../20220708174300_GrappleOptions.Designer.cs | 1 - ...1194419_AddedCraftRequirements.Designer.cs | 1 - ...0220925050711_CustomAnimations.Designer.cs | 1 - ...edConfigurableItemDespawnTimes.Designer.cs | 1 - ..._MultipleBonusEffectsMigration.Designer.cs | 1 - ...0221016173617_AddUserVariables.Designer.cs | 1 - .../20221017220000_DropColumns.designer.cs | 1 - .../20221018220000_PatchTables.Designer.cs | 1 - .../20191118024649_RequestLogs.Designer.cs | 1 - ...9230003_AddUserActivityHistory.Designer.cs | 1 - ...0210414222302_AddedChatLogging.Designer.cs | 1 - ...20210515114555_LogPlayerTrades.Designer.cs | 1 - ...095613_AddGuildActivityLogging.Designer.cs | 1 - ...20180927161502_InitialPlayerDb.Designer.cs | 1 - ...0190310001204_AddRefreshTokens.Designer.cs | 1 - ...0013418_StandardizeVocabulary1.Designer.cs | 1 - ...927_CombiningSwitchesVariables.Designer.cs | 1 - ...3420_Custom_Player_Name_Colors.Designer.cs | 1 - ...30214333_PlayerUpgrades_Labels.Designer.cs | 1 - ...126025000_RefactoringCooldowns.Designer.cs | 1 - ...FriendsForeignKeyContraintFail.Designer.cs | 1 - ...1145105_SavingPlayerLabelsInDb.Designer.cs | 1 - ...01017065035_AddColorToEntities.Designer.cs | 1 - ...414121435_TrackUserPlayerStats.Designer.cs | 1 - ...540_AddingGuildsWithGuildBanks.Designer.cs | 1 - ...TrackPlaytimeAsULongsInSeconds.Designer.cs | 1 - ...611184605_AddingGuildVariables.Designer.cs | 1 - ...427_GuildBankMaxSlotsMigration.Designer.cs | 1 - ...03141119_InstanceWarpMigration.Designer.cs | 1 - ...0221016173603_AddUserVariables.Designer.cs | 1 - .../20221017220000_DropColumns.Designer.cs | 1 - .../20221018220000_PatchTables.Designer.cs | 1 - .../20221119214350_ItemProperties.Designer.cs | 1 - .../Networking/Helpers/NetDebug.cs | 3 +- .../Networking/Helpers/PortChecker.cs | 28 +- Intersect.Server/Networking/Helpers/UPnP.cs | 19 +- .../Networking/IntersectNetworkServer.cs | 7 +- .../Networking/IntersectNetworkSocket.cs | 3 +- .../LiteNetLib/ServerNetwork.LiteNetLib.cs | 15 +- .../Networking/NetworkedPacketHandler.cs | 18 +- .../Notifications/Notification.cs | 10 +- .../Web/ApiService.AppSettings.cs | 17 +- Intersect.Server/Web/ApiService.cs | 15 +- .../Web/Configuration/ApiConfiguration.cs | 1 - .../Configuration/TokenGenerationOptions.cs | 5 +- .../Web/Http/HttpStatusCodeExtensions.cs | 13 +- .../Web/Middleware/IntersectRequestLogging.cs | 9 +- .../Web/Pages/Account/Login.cshtml | 1 + .../Web/Pages/Account/Logout.cshtml | 1 + .../Web/Pages/Shared/_Toasts.cshtml | 1 + .../Networking/SinglePlayerNetwork.cs | 8 +- Intersect.Tests.Client/Stub.cs | 1 - .../Extensions/DateTimeExtensionsTests.cs | 1 - .../GameObjectInfoAttributeTests.cs | 1 - .../Extensions/RandomExtensionsTests.cs | 1 - .../Factories/FactoryRegistryTests.cs | 4 +- .../IO/Files/FileSystemHelperTests.cs | 1 - .../Network/PacketHandlerAttributeTests.cs | 1 - .../Plugins/Loaders/ManifestLoaderTest.cs | 7 +- .../Plugins/Manifests/JsonManifestTests.cs | 2 - .../Plugins/Manifests/Types/AuthorTests.cs | 1 - .../Plugins/Manifests/Types/AuthorsTests.cs | 3 - .../Plugins/VirtualTestManifest.cs | 1 - Intersect.Tests/Utilities/MathHelperTests.cs | 2 - Intersect.Tests/Utilities/TextUtilsTests.cs | 1 - Intersect.Tests/Utilities/TimingTests.cs | 1 - Intersect.Tests/Utilities/ValueUtilsTests.cs | 1 - .../Intersect.OpenPortChecker/PortChecker.cs | 4 +- .../Intersect.OpenPortChecker/Program.cs | 1 - 485 files changed, 1507 insertions(+), 3614 deletions(-) create mode 100644 Framework/Intersect.Framework.Core/Core/ApplicationContext.cs delete mode 100644 Framework/Intersect.Framework.Core/Logging/Formatting/DefaultFormatter.cs delete mode 100644 Framework/Intersect.Framework.Core/Logging/Formatting/ILogFormatter.cs delete mode 100644 Framework/Intersect.Framework.Core/Logging/ILogger.cs delete mode 100644 Framework/Intersect.Framework.Core/Logging/LegacyLogging.cs delete mode 100644 Framework/Intersect.Framework.Core/Logging/LogConfiguration.cs delete mode 100644 Framework/Intersect.Framework.Core/Logging/LogLevel.cs delete mode 100644 Framework/Intersect.Framework.Core/Logging/Output/ILogOutput.cs create mode 100644 Framework/Intersect.Framework.Core/Serialization/SafeStringEnumConverter.cs delete mode 100644 Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Core.cs delete mode 100644 Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Flags.cs delete mode 100644 Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Static.cs delete mode 100644 Intersect (Core)/Core/ExperimentalFeatures/ExperimentNamespace.cs delete mode 100644 Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlag.cs delete mode 100644 Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlagAlias.cs delete mode 100644 Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlagAliasAttribute.cs delete mode 100644 Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlagConverter.cs delete mode 100644 Intersect (Core)/Core/ExperimentalFeatures/IExperimentalFlag.cs delete mode 100644 Intersect (Core)/Core/ExperimentalFeatures/IFlagProvider.cs delete mode 100644 Intersect (Core)/Extensions/LogLevelExtensions.cs delete mode 100644 Intersect (Core)/Logging/Formatting/PrettyFormatter.cs delete mode 100644 Intersect (Core)/Logging/Log.cs delete mode 100644 Intersect (Core)/Logging/Logger.cs delete mode 100644 Intersect (Core)/Logging/MemoryDump.cs delete mode 100644 Intersect (Core)/Logging/Output/ConciseConsoleOutput.cs delete mode 100644 Intersect (Core)/Logging/Output/ConsoleOutput.cs delete mode 100644 Intersect (Core)/Logging/Output/FileOutput.cs delete mode 100644 Intersect.Server.Core/Core/ExperimentalFeatures/Experiments.cs delete mode 100644 Intersect.Server.Core/Database/DbLogger.cs delete mode 100644 Intersect.Server.Core/Database/DbLoggerProvider.cs delete mode 100644 Intersect.Server/Core/Commands/ExperimentsCommand.cs diff --git a/Examples/Intersect.Examples.Plugin.Client.Tests/ManifestTest.cs b/Examples/Intersect.Examples.Plugin.Client.Tests/ManifestTest.cs index da717b4067..f96440c7c0 100644 --- a/Examples/Intersect.Examples.Plugin.Client.Tests/ManifestTest.cs +++ b/Examples/Intersect.Examples.Plugin.Client.Tests/ManifestTest.cs @@ -1,7 +1,6 @@ // NUnit 3 tests // See documentation : https://github.com/nunit/docs/wiki/NUnit-Documentation using Intersect.Plugins.Loaders; - using NUnit.Framework; namespace Intersect.Examples.Plugin.Client diff --git a/Examples/Intersect.Examples.Plugin.Client/ExampleCommandLineOptions.cs b/Examples/Intersect.Examples.Plugin.Client/ExampleCommandLineOptions.cs index 38812f8f5c..a340688c85 100644 --- a/Examples/Intersect.Examples.Plugin.Client/ExampleCommandLineOptions.cs +++ b/Examples/Intersect.Examples.Plugin.Client/ExampleCommandLineOptions.cs @@ -1,7 +1,5 @@ using CommandLine; - using Intersect.Utilities; - using System; namespace Intersect.Examples.Plugin.Client diff --git a/Examples/Intersect.Examples.Plugin.Client/ExamplePluginConfiguration.cs b/Examples/Intersect.Examples.Plugin.Client/ExamplePluginConfiguration.cs index 2f3dc27644..f9f27c774f 100644 --- a/Examples/Intersect.Examples.Plugin.Client/ExamplePluginConfiguration.cs +++ b/Examples/Intersect.Examples.Plugin.Client/ExamplePluginConfiguration.cs @@ -1,5 +1,4 @@ using Intersect.Plugins; - using Newtonsoft.Json; namespace Intersect.Examples.Plugin.Client diff --git a/Examples/Intersect.Examples.Plugin.Client/Manifest.cs b/Examples/Intersect.Examples.Plugin.Client/Manifest.cs index 9b97610c0d..beaa34993c 100644 --- a/Examples/Intersect.Examples.Plugin.Client/Manifest.cs +++ b/Examples/Intersect.Examples.Plugin.Client/Manifest.cs @@ -1,9 +1,7 @@ using Intersect.Plugins.Interfaces; using Intersect.Plugins.Manifests.Types; using Intersect.Utilities; - using Semver; - using System; using System.Collections.Generic; diff --git a/Examples/Intersect.Examples.Plugin.Client/PacketHandlers/ExamplePluginServerPacketHandler.cs b/Examples/Intersect.Examples.Plugin.Client/PacketHandlers/ExamplePluginServerPacketHandler.cs index 7cc76dd2e3..c15e3cb8dd 100644 --- a/Examples/Intersect.Examples.Plugin.Client/PacketHandlers/ExamplePluginServerPacketHandler.cs +++ b/Examples/Intersect.Examples.Plugin.Client/PacketHandlers/ExamplePluginServerPacketHandler.cs @@ -1,8 +1,6 @@ using Intersect.Examples.Plugin.Packets.Client; using Intersect.Examples.Plugin.Packets.Server; -using Intersect.Logging; using Intersect.Network; - using System; namespace Intersect.Examples.Plugin.Client.PacketHandlers @@ -21,15 +19,15 @@ public bool Handle(IPacketSender packetSender, ExamplePluginServerPacket packet) throw new ArgumentNullException(nameof(packet)); } - Log.Info($"Received server packet! The server said '{packet.ExamplePluginMessage}'."); + ApplicationContext.Context.Value?.Logger.LogInformation($"Received server packet! The server said '{packet.ExamplePluginMessage}'."); var packetSent = packetSender.Send(new ExamplePluginClientPacket("A message from the client!")); if (packetSent) { - Log.Info("Sent response back to the server!"); + ApplicationContext.Context.Value?.Logger.LogInformation("Sent response back to the server!"); } else { - Log.Error("Failed to send response back to the server!"); + ApplicationContext.Context.Value?.Logger.LogError("Failed to send response back to the server!"); } return packetSent; diff --git a/Examples/Intersect.Examples.Plugin.Server/ExampleServerPluginEntry.cs b/Examples/Intersect.Examples.Plugin.Server/ExampleServerPluginEntry.cs index 315abcccd2..908690d28b 100644 --- a/Examples/Intersect.Examples.Plugin.Server/ExampleServerPluginEntry.cs +++ b/Examples/Intersect.Examples.Plugin.Server/ExampleServerPluginEntry.cs @@ -5,7 +5,6 @@ using Intersect.Network.Packets.Client; using Intersect.Plugins; using Intersect.Server.Plugins; - using System; namespace Intersect.Examples.Plugin.Server diff --git a/Examples/Intersect.Examples.Plugin.Server/Manifest.cs b/Examples/Intersect.Examples.Plugin.Server/Manifest.cs index 1c4b8c39dc..85febcec9f 100644 --- a/Examples/Intersect.Examples.Plugin.Server/Manifest.cs +++ b/Examples/Intersect.Examples.Plugin.Server/Manifest.cs @@ -1,9 +1,7 @@ using Intersect.Plugins.Interfaces; using Intersect.Plugins.Manifests.Types; using Intersect.Utilities; - using Semver; - using System; using System.Collections.Generic; diff --git a/Examples/Intersect.Examples.Plugin.Server/Networking/Handlers/ExamplePluginClientPacketHandler.cs b/Examples/Intersect.Examples.Plugin.Server/Networking/Handlers/ExamplePluginClientPacketHandler.cs index c2f246372e..153b662660 100644 --- a/Examples/Intersect.Examples.Plugin.Server/Networking/Handlers/ExamplePluginClientPacketHandler.cs +++ b/Examples/Intersect.Examples.Plugin.Server/Networking/Handlers/ExamplePluginClientPacketHandler.cs @@ -1,5 +1,4 @@ using Intersect.Examples.Plugin.Packets.Client; -using Intersect.Logging; using Intersect.Network; namespace Intersect.Examples.Plugin.Server.Networking.Handlers @@ -8,7 +7,7 @@ public class ExamplePluginClientPacketHandler : IPacketHandler ValueList } catch (Exception exception) { - LegacyLogging.Logger?.Warn( + ApplicationContext.Context.Value?.Logger.LogWarning( exception, - $@"{StoredType.Name}[Count={mIdMap.Count},NullCount={mIdMap.Count(pair => pair.Value == null)}]" + "{StoredType}[Count={Count}, Null={NullCount}]", + StoredType.GetName(qualified: true), + mIdMap.Count, + mIdMap.Count(pair => pair.Value == null) ); throw; diff --git a/Framework/Intersect.Framework.Core/Config/DatabaseOptions.cs b/Framework/Intersect.Framework.Core/Config/DatabaseOptions.cs index 9717f4ceca..2175d72035 100644 --- a/Framework/Intersect.Framework.Core/Config/DatabaseOptions.cs +++ b/Framework/Intersect.Framework.Core/Config/DatabaseOptions.cs @@ -1,5 +1,4 @@ using System.ComponentModel; - using Newtonsoft.Json; using Newtonsoft.Json.Converters; @@ -31,8 +30,8 @@ public partial class DatabaseOptions NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Populate )] - [DefaultValue(Logging.LogLevel.Error)] - public Logging.LogLevel LogLevel { get; set; } = Logging.LogLevel.Error; + [DefaultValue(Microsoft.Extensions.Logging.LogLevel.Error)] + public Microsoft.Extensions.Logging.LogLevel LogLevel { get; set; } = Microsoft.Extensions.Logging.LogLevel.Error; public bool KillServerOnConcurrencyException { get; set; } = DefaultKillServerOnConcurrencyException; } diff --git a/Framework/Intersect.Framework.Core/Config/LoggingOptions.cs b/Framework/Intersect.Framework.Core/Config/LoggingOptions.cs index 425a3a5647..5ccb471d2c 100644 --- a/Framework/Intersect.Framework.Core/Config/LoggingOptions.cs +++ b/Framework/Intersect.Framework.Core/Config/LoggingOptions.cs @@ -1,10 +1,13 @@ -using Intersect.Logging; +using Intersect.Framework.Core.Serialization; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; namespace Intersect.Config; public partial class LoggingOptions { - public LogLevel Level { get; set; } = LogLevel.Info; + [JsonConverter(typeof(SafeStringEnumConverter))] + public LogLevel Level { get; set; } = LogLevel.Information; /// /// Determines whether chat logs should be written into the logging database diff --git a/Framework/Intersect.Framework.Core/Config/PaperdollOptions.cs b/Framework/Intersect.Framework.Core/Config/PaperdollOptions.cs index 5b78e81002..b54ab104ba 100644 --- a/Framework/Intersect.Framework.Core/Config/PaperdollOptions.cs +++ b/Framework/Intersect.Framework.Core/Config/PaperdollOptions.cs @@ -1,5 +1,4 @@ using System.Runtime.Serialization; - using Newtonsoft.Json; namespace Intersect.Config; diff --git a/Framework/Intersect.Framework.Core/Config/Passability.cs b/Framework/Intersect.Framework.Core/Config/Passability.cs index 2fb5a57151..f4cac1e7ea 100644 --- a/Framework/Intersect.Framework.Core/Config/Passability.cs +++ b/Framework/Intersect.Framework.Core/Config/Passability.cs @@ -1,5 +1,4 @@ using System.Runtime.Serialization; - using Newtonsoft.Json; namespace Intersect.Config; diff --git a/Framework/Intersect.Framework.Core/Configuration/ClientConfiguration.cs b/Framework/Intersect.Framework.Core/Configuration/ClientConfiguration.cs index b5a8c15b12..78a7a3fd85 100644 --- a/Framework/Intersect.Framework.Core/Configuration/ClientConfiguration.cs +++ b/Framework/Intersect.Framework.Core/Configuration/ClientConfiguration.cs @@ -1,9 +1,8 @@ using System.ComponentModel; using System.Runtime.Serialization; - using Intersect.Enums; -using Intersect.Logging; using Intersect.Utilities; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; namespace Intersect.Configuration; @@ -264,8 +263,8 @@ public void Validate() #region Hidden Properties [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] - [DefaultValue(LogLevel.Info)] - public LogLevel LogLevel { get; set; } = LogLevel.Info; + [DefaultValue(LogLevel.Information)] + public LogLevel LogLevel { get; set; } = LogLevel.Information; #endregion diff --git a/Framework/Intersect.Framework.Core/Configuration/ConfigurationHelper.cs b/Framework/Intersect.Framework.Core/Configuration/ConfigurationHelper.cs index 4629053f44..bb256ce9a9 100644 --- a/Framework/Intersect.Framework.Core/Configuration/ConfigurationHelper.cs +++ b/Framework/Intersect.Framework.Core/Configuration/ConfigurationHelper.cs @@ -1,8 +1,8 @@ using System.Text; - +using Intersect.Core; +using Intersect.Framework.Reflection; using Intersect.IO.Files; -using Intersect.Logging; - +using Microsoft.Extensions.Logging; using Newtonsoft.Json; namespace Intersect.Configuration; @@ -34,7 +34,12 @@ public static T Load(T configuration, string filePath, bool failQuietly = fal } catch (Exception exception) { - LegacyLogging.Logger?.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error when reading {ConfigurationType} from {FilePath}", + typeof(T).GetName(qualified: true), + filePath + ); throw; } @@ -46,12 +51,12 @@ public static T Save(T configuration, string filePath, bool failQuietly = fal var directoryPath = Path.GetDirectoryName(filePath); if (directoryPath == null) { - throw new ArgumentNullException(); + throw new ArgumentException($"'{filePath}' has no directory name", nameof(filePath)); } if (!FileSystemHelper.EnsureDirectoryExists(directoryPath)) { - throw new FileNotFoundException("Missing directory.", directoryPath); + throw new DirectoryNotFoundException($"Directory does not exist: {directoryPath}"); } try @@ -64,7 +69,12 @@ public static T Save(T configuration, string filePath, bool failQuietly = fal } catch (Exception exception) { - LegacyLogging.Logger?.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error when writing {ConfigurationType} to {FilePath}", + typeof(T).GetName(qualified: true), + filePath + ); throw; } @@ -84,7 +94,12 @@ public static T LoadSafely(T configuration, string filePath = null) } catch (Exception exception) { - LegacyLogging.Logger?.Warn(exception); + ApplicationContext.Context.Value?.Logger.LogWarning( + exception, + "Error when reading {ConfigurationType} to {FilePath}", + typeof(T).GetName(qualified: true), + filePath + ); } finally { @@ -94,7 +109,12 @@ public static T LoadSafely(T configuration, string filePath = null) } catch (Exception exception) { - LegacyLogging.Logger?.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error when writing {ConfigurationType} to {FilePath}", + typeof(T).GetName(qualified: true), + filePath + ); } } diff --git a/Framework/Intersect.Framework.Core/Core/ApplicationContext.cs b/Framework/Intersect.Framework.Core/Core/ApplicationContext.cs new file mode 100644 index 0000000000..600776bd42 --- /dev/null +++ b/Framework/Intersect.Framework.Core/Core/ApplicationContext.cs @@ -0,0 +1,6 @@ +namespace Intersect.Core; + +public static class ApplicationContext +{ + public static readonly AsyncLocal Context = new(); +} \ No newline at end of file diff --git a/Framework/Intersect.Framework.Core/Core/IApplicationContext.cs b/Framework/Intersect.Framework.Core/Core/IApplicationContext.cs index 7217c07c1e..2236d6de71 100644 --- a/Framework/Intersect.Framework.Core/Core/IApplicationContext.cs +++ b/Framework/Intersect.Framework.Core/Core/IApplicationContext.cs @@ -1,6 +1,7 @@ -using Intersect.Logging; + using Intersect.Plugins.Interfaces; using Intersect.Threading; +using Microsoft.Extensions.Logging; namespace Intersect.Core; @@ -63,8 +64,8 @@ public interface IApplicationContext : IDisposable void Start(bool lockUntilShutdown = true); /// - /// Start the application with a . + /// Start the application with a . /// - /// the instance being used + /// the instance being used ILockingActionQueue StartWithActionQueue(); } diff --git a/Framework/Intersect.Framework.Core/Entities/ExperienceCurve.cs b/Framework/Intersect.Framework.Core/Entities/ExperienceCurve.cs index 292ef473a6..e5d2480696 100644 --- a/Framework/Intersect.Framework.Core/Entities/ExperienceCurve.cs +++ b/Framework/Intersect.Framework.Core/Entities/ExperienceCurve.cs @@ -1,5 +1,5 @@ -using Intersect.Logging; - +using Intersect.Core; +using Microsoft.Extensions.Logging; using NCalc; namespace Intersect.Server.Utilities; @@ -45,7 +45,7 @@ protected virtual void Exp(FunctionArgs args) { if (args.Parameters == null || args.Parameters.Length < 3) { - LegacyLogging.Logger?.Error("Tried to execute Exp with fewer than three arguments."); + ApplicationContext.Context.Value?.Logger.LogError("Tried to execute Exp with fewer than three arguments."); args.Result = 0L; } diff --git a/Framework/Intersect.Framework.Core/GameObjects/AnimationBase.cs b/Framework/Intersect.Framework.Core/GameObjects/AnimationBase.cs index c7701d3422..e8524e9995 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/AnimationBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/AnimationBase.cs @@ -1,8 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; using Intersect.Models; - using Microsoft.EntityFrameworkCore; - using Newtonsoft.Json; namespace Intersect.GameObjects; diff --git a/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorBooleanAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorBooleanAttribute.cs index 73c2778de1..9814d4b670 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorBooleanAttribute.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorBooleanAttribute.cs @@ -1,5 +1,4 @@ using System.Reflection; - using Intersect.Localization; namespace Intersect.GameObjects.Annotations; diff --git a/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorDictionaryAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorDictionaryAttribute.cs index 18d53852da..b3763234c6 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorDictionaryAttribute.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorDictionaryAttribute.cs @@ -4,7 +4,7 @@ using Intersect.Localization; #if !DEBUG -using Intersect.Logging; + #endif namespace Intersect.GameObjects.Annotations; diff --git a/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorFormattedAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorFormattedAttribute.cs index cc4ed2a040..e9aff2709c 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorFormattedAttribute.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorFormattedAttribute.cs @@ -1,9 +1,8 @@ using System.Reflection; - using Intersect.Localization; #if !DEBUG -using Intersect.Logging; + #endif namespace Intersect.GameObjects.Annotations; diff --git a/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorReferenceAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorReferenceAttribute.cs index b2b1c9528f..39cffa4d94 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorReferenceAttribute.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Annotations/EditorReferenceAttribute.cs @@ -1,5 +1,4 @@ using System.Reflection; - using Intersect.Collections; using Intersect.GameObjects.Maps; using Intersect.GameObjects.Maps.MapList; diff --git a/Framework/Intersect.Framework.Core/GameObjects/ClassBase.cs b/Framework/Intersect.Framework.Core/GameObjects/ClassBase.cs index 713dd07166..1464f2b31b 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/ClassBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/ClassBase.cs @@ -1,11 +1,9 @@ using System.ComponentModel.DataAnnotations.Schema; - using Intersect.Enums; using Intersect.GameObjects.Maps; using Intersect.Models; using Intersect.Server.Utilities; using Intersect.Utilities; - using Newtonsoft.Json; namespace Intersect.GameObjects; diff --git a/Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionList.cs b/Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionList.cs index 9e1dab36f0..c514967d3d 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionList.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Conditions/ConditionList.cs @@ -1,6 +1,5 @@ using Intersect.Framework.Core.Serialization; using Intersect.GameObjects.Events; - using Newtonsoft.Json; namespace Intersect.GameObjects.Conditions; diff --git a/Framework/Intersect.Framework.Core/GameObjects/Crafting/CraftBase.cs b/Framework/Intersect.Framework.Core/GameObjects/Crafting/CraftBase.cs index c04eea947f..9b2ce8fc3d 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Crafting/CraftBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Crafting/CraftBase.cs @@ -1,8 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; - using Intersect.Models; using Intersect.GameObjects.Events; - using Newtonsoft.Json; using Intersect.GameObjects.Conditions; diff --git a/Framework/Intersect.Framework.Core/GameObjects/Crafting/CraftingTableBase.cs b/Framework/Intersect.Framework.Core/GameObjects/Crafting/CraftingTableBase.cs index da468b05a2..f64a4b1773 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Crafting/CraftingTableBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Crafting/CraftingTableBase.cs @@ -1,8 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; - using Intersect.GameObjects.Crafting; using Intersect.Models; - using Newtonsoft.Json; namespace Intersect.GameObjects; diff --git a/Framework/Intersect.Framework.Core/GameObjects/Events/EventBase.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/EventBase.cs index 90ad312f93..7ed83d428b 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Events/EventBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Events/EventBase.cs @@ -1,7 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; using Intersect.Framework.Core.Serialization; using Intersect.Models; - using Newtonsoft.Json; namespace Intersect.GameObjects.Events; diff --git a/Framework/Intersect.Framework.Core/GameObjects/Events/EventPage.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/EventPage.cs index 7b573d4cd1..3b2157a680 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Events/EventPage.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Events/EventPage.cs @@ -1,7 +1,6 @@ using Intersect.Enums; using Intersect.GameObjects.Conditions; using Intersect.GameObjects.Events.Commands; - using Newtonsoft.Json; namespace Intersect.GameObjects.Events; diff --git a/Framework/Intersect.Framework.Core/GameObjects/Events/VariableMod.cs b/Framework/Intersect.Framework.Core/GameObjects/Events/VariableMod.cs index 2e8ca016e8..0e4a7f14de 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Events/VariableMod.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Events/VariableMod.cs @@ -1,5 +1,4 @@ using Intersect.Enums; - using Newtonsoft.Json; namespace Intersect.GameObjects.Events; diff --git a/Framework/Intersect.Framework.Core/GameObjects/ItemBase.cs b/Framework/Intersect.Framework.Core/GameObjects/ItemBase.cs index 74f5474f72..2c8e7a6838 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/ItemBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/ItemBase.cs @@ -6,9 +6,7 @@ using Intersect.GameObjects.Ranges; using Intersect.Models; using Intersect.Utilities; - using Microsoft.EntityFrameworkCore; - using Newtonsoft.Json; namespace Intersect.GameObjects; diff --git a/Framework/Intersect.Framework.Core/GameObjects/Maps/MapAttribute.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapAttribute.cs index ca0c15e1ec..8e3e4818b8 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Maps/MapAttribute.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapAttribute.cs @@ -1,7 +1,6 @@ using Intersect.Enums; using Intersect.GameObjects.Annotations; using Intersect.Localization; - using Newtonsoft.Json; namespace Intersect.GameObjects.Maps; diff --git a/Framework/Intersect.Framework.Core/GameObjects/Maps/MapAutotiles.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapAutotiles.cs index da76cd0cba..0334f74c09 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Maps/MapAutotiles.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapAutotiles.cs @@ -1,4 +1,5 @@ -using Intersect.Logging; +using Intersect.Core; +using Microsoft.Extensions.Logging; namespace Intersect.GameObjects.Maps; @@ -536,14 +537,14 @@ public void CacheRenderState(int x, int y, string layerName) if (mMyMap == null) { - LegacyLogging.Logger?.Error($"{nameof(mMyMap)}=null"); + ApplicationContext.Context.Value?.Logger.LogError($"{nameof(mMyMap)}=null"); return; } if (mMyMap.Layers == null) { - LegacyLogging.Logger?.Error($"{nameof(mMyMap.Layers)}=null"); + ApplicationContext.Context.Value?.Logger.LogError($"{nameof(mMyMap.Layers)}=null"); return; } @@ -556,7 +557,7 @@ public void CacheRenderState(int x, int y, string layerName) var layer = mMyMap.Layers[layerName]; if (mMyMap.Layers[layerName] == null) { - LegacyLogging.Logger?.Error($"{nameof(layer)}=null"); + ApplicationContext.Context.Value?.Logger.LogError($"{nameof(layer)}=null"); return; } @@ -601,14 +602,14 @@ public void CalculateAutotile(int x, int y, string layerName, MapBase[,] surroun // Exit out if we don//t have an auatotile if (mMyMap == null) { - LegacyLogging.Logger?.Error($"{nameof(mMyMap)}=null"); + ApplicationContext.Context.Value?.Logger.LogError($"{nameof(mMyMap)}=null"); return; } if (mMyMap.Layers == null) { - LegacyLogging.Logger?.Error($"{nameof(mMyMap.Layers)}=null"); + ApplicationContext.Context.Value?.Logger.LogError($"{nameof(mMyMap.Layers)}=null"); return; } @@ -621,7 +622,7 @@ public void CalculateAutotile(int x, int y, string layerName, MapBase[,] surroun var layer = mMyMap.Layers[layerName]; if (mMyMap.Layers[layerName] == null) { - LegacyLogging.Logger?.Error($"{nameof(layer)}=null"); + ApplicationContext.Context.Value?.Logger.LogError($"{nameof(layer)}=null"); return; } diff --git a/Framework/Intersect.Framework.Core/GameObjects/Maps/MapBase.cs b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapBase.cs index 54668be3bc..8d77cd9e31 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Maps/MapBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Maps/MapBase.cs @@ -5,7 +5,6 @@ using Intersect.Framework.Core.Serialization; using Intersect.GameObjects.Events; using Intersect.Models; - using Newtonsoft.Json; namespace Intersect.GameObjects.Maps; diff --git a/Framework/Intersect.Framework.Core/GameObjects/NpcBase.cs b/Framework/Intersect.Framework.Core/GameObjects/NpcBase.cs index d9965fde47..6fad8318bf 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/NpcBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/NpcBase.cs @@ -1,11 +1,9 @@ using System.ComponentModel.DataAnnotations.Schema; - using Intersect.Enums; using Intersect.GameObjects.Conditions; using Intersect.GameObjects.Events; using Intersect.Models; using Intersect.Utilities; - using Newtonsoft.Json; namespace Intersect.GameObjects; diff --git a/Framework/Intersect.Framework.Core/GameObjects/ProjectileBase.cs b/Framework/Intersect.Framework.Core/GameObjects/ProjectileBase.cs index 173fba5f4e..5a1a068c77 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/ProjectileBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/ProjectileBase.cs @@ -1,7 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; using Intersect.Enums; using Intersect.Models; - using Newtonsoft.Json; namespace Intersect.GameObjects; diff --git a/Framework/Intersect.Framework.Core/GameObjects/QuestBase.cs b/Framework/Intersect.Framework.Core/GameObjects/QuestBase.cs index 05042747ea..607012e1a5 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/QuestBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/QuestBase.cs @@ -1,12 +1,10 @@ using System.ComponentModel.DataAnnotations.Schema; - using Intersect.Enums; using Intersect.Framework.Core.Serialization; using Intersect.GameObjects.Conditions; using Intersect.GameObjects.Events; using Intersect.Localization; using Intersect.Models; - using Newtonsoft.Json; namespace Intersect.GameObjects; diff --git a/Framework/Intersect.Framework.Core/GameObjects/ResourceBase.cs b/Framework/Intersect.Framework.Core/GameObjects/ResourceBase.cs index ec180e351d..4e66017722 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/ResourceBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/ResourceBase.cs @@ -1,11 +1,8 @@ using System.ComponentModel.DataAnnotations.Schema; - using Intersect.GameObjects.Conditions; using Intersect.GameObjects.Events; using Intersect.Models; - using Microsoft.EntityFrameworkCore; - using Newtonsoft.Json; namespace Intersect.GameObjects; diff --git a/Framework/Intersect.Framework.Core/GameObjects/ShopBase.cs b/Framework/Intersect.Framework.Core/GameObjects/ShopBase.cs index 61386a7432..7c826c9d8a 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/ShopBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/ShopBase.cs @@ -1,7 +1,5 @@ using System.ComponentModel.DataAnnotations.Schema; - using Intersect.Models; - using Newtonsoft.Json; namespace Intersect.GameObjects; diff --git a/Framework/Intersect.Framework.Core/GameObjects/SpellBase.cs b/Framework/Intersect.Framework.Core/GameObjects/SpellBase.cs index eab96cabe3..0311d842a0 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/SpellBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/SpellBase.cs @@ -4,9 +4,7 @@ using Intersect.GameObjects.Events; using Intersect.Models; using Intersect.Utilities; - using Microsoft.EntityFrameworkCore; - using Newtonsoft.Json; namespace Intersect.GameObjects; diff --git a/Framework/Intersect.Framework.Core/GameObjects/TilesetBase.cs b/Framework/Intersect.Framework.Core/GameObjects/TilesetBase.cs index c552580143..99c109c845 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/TilesetBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/TilesetBase.cs @@ -1,5 +1,4 @@ using Intersect.Models; - using Newtonsoft.Json; namespace Intersect.GameObjects; diff --git a/Framework/Intersect.Framework.Core/GameObjects/TimeBase.cs b/Framework/Intersect.Framework.Core/GameObjects/TimeBase.cs index 7a251ed30d..f7927686f6 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/TimeBase.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/TimeBase.cs @@ -1,5 +1,4 @@ using System.ComponentModel.DataAnnotations.Schema; - using Newtonsoft.Json; namespace Intersect.GameObjects; diff --git a/Framework/Intersect.Framework.Core/GameObjects/Variables/VariableValue.cs b/Framework/Intersect.Framework.Core/GameObjects/Variables/VariableValue.cs index 47b81e9efc..e64f7ba230 100644 --- a/Framework/Intersect.Framework.Core/GameObjects/Variables/VariableValue.cs +++ b/Framework/Intersect.Framework.Core/GameObjects/Variables/VariableValue.cs @@ -1,6 +1,7 @@ using System.ComponentModel.DataAnnotations.Schema; +using Intersect.Core; using Intersect.Enums; -using Intersect.Logging; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -121,7 +122,11 @@ public static bool TryParse(string value, out JObject jObject) return true; } - LegacyLogging.Logger?.Warn(new ArgumentNullException(nameof(jObject), @"Invalid variable value stored in the database.")); + ApplicationContext.Context.Value?.Logger.LogWarning( + new ArgumentNullException(nameof(jObject), @"Invalid variable value stored in the database."), + "Invalid variable value stored in the database:\n{Value}", + value + ); } catch (Exception exception) { @@ -129,7 +134,7 @@ public static bool TryParse(string value, out JObject jObject) #if DEBUG /* Only log in DEBUG in case the variable contains * sensitive information. */ - LegacyLogging.Logger?.Warn(exception); + ApplicationContext.Context.Value?.Logger.LogWarning(exception, "Error while parsing:\n{Value}", value); #endif } diff --git a/Framework/Intersect.Framework.Core/IO/Files/FileSystemHelper.cs b/Framework/Intersect.Framework.Core/IO/Files/FileSystemHelper.cs index cf8264677f..76a12948d3 100644 --- a/Framework/Intersect.Framework.Core/IO/Files/FileSystemHelper.cs +++ b/Framework/Intersect.Framework.Core/IO/Files/FileSystemHelper.cs @@ -2,9 +2,9 @@ using System.Diagnostics.Contracts; using System.IO.Abstractions; using System.Reflection; - +using Intersect.Core; using Intersect.Extensions; -using Intersect.Logging; +using Microsoft.Extensions.Logging; namespace Intersect.IO.Files; @@ -54,7 +54,11 @@ public static bool EnsureDirectoryExists(string directoryPath) } catch (Exception exception) { - LegacyLogging.Logger?.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Failed to create {DirectoryPath}", + directoryPath + ); return false; } diff --git a/Framework/Intersect.Framework.Core/Intersect.Framework.Core.csproj b/Framework/Intersect.Framework.Core/Intersect.Framework.Core.csproj index a2c425c597..5bf630af26 100644 --- a/Framework/Intersect.Framework.Core/Intersect.Framework.Core.csproj +++ b/Framework/Intersect.Framework.Core/Intersect.Framework.Core.csproj @@ -18,6 +18,7 @@ + diff --git a/Framework/Intersect.Framework.Core/Logging/Formatting/DefaultFormatter.cs b/Framework/Intersect.Framework.Core/Logging/Formatting/DefaultFormatter.cs deleted file mode 100644 index 61c81ced57..0000000000 --- a/Framework/Intersect.Framework.Core/Logging/Formatting/DefaultFormatter.cs +++ /dev/null @@ -1,133 +0,0 @@ -using System.Text; - -namespace Intersect.Logging.Formatting; - - -/// -/// Basic formatter for text logs, includes details and timestamps. -/// -public partial class DefaultFormatter : ILogFormatter -{ - - public const string DefaultTimestampFormat = "yyyy-MM-dd HH:mm:ss.fff"; - - public DefaultFormatter() - { - TimestampFormat = DefaultTimestampFormat; - } - - public string TimestampFormat { get; set; } - - /// - public string Format( - LogConfiguration configuration, - LogLevel logLevel, - DateTime dateTime, - Exception exception, - string message, - params object[] args - ) - { - var prefix = FormatPrefix(configuration, logLevel, dateTime).ToString(); - var builder = new StringBuilder(); - - if (message != null) - { - FormatLine(builder, prefix, message, args); - } - - if (exception != null) - { - FormatLine(builder, prefix, exception); - } - - return builder.ToString(); - } - - protected virtual StringBuilder FormatPrefix( - LogConfiguration configuration, - LogLevel logLevel, - DateTime dateTime, - StringBuilder builder = null - ) - { - if (builder == null) - { - builder = new StringBuilder(); - } - - if (!string.IsNullOrWhiteSpace(TimestampFormat)) - { - builder.Append(dateTime.ToString(TimestampFormat)); - builder.Append(' '); - } - - builder.Append($"[{logLevel}]"); - builder.Append(' '); - - // ReSharper disable once InvertIf - if (!string.IsNullOrEmpty(configuration.Tag)) - { - builder.Append(configuration.Tag); - builder.Append(": "); - } - - return builder; - } - - private static void FormatLine( - StringBuilder builder, - string prefix, - string message, - params object[] args - ) - { - builder.Append(prefix); - - if (args?.Length > 0) - { - builder.AppendFormat(message, args); - } - else - { - builder.Append(message); - } - - builder.AppendLine(); - } - - private static void FormatLine( - StringBuilder builder, - string prefix, - Exception exception, - bool recurse = true - ) - { - if (!string.IsNullOrWhiteSpace(prefix)) - { - builder.Append(prefix); - } - - builder.AppendLine($@"{exception.GetType().Name}: {exception.Message}"); - - if (exception.StackTrace?.Length < 10000) - { - builder.AppendLine($@" Stack: {exception.StackTrace}"); - } - - builder.AppendLine(); - - if (!recurse) - { - return; - } - - var innerException = exception; - while ((innerException = innerException.InnerException) != null) - { - builder.AppendLine(@"Caused By"); - FormatLine(builder, null, innerException, false); - } - } - -} diff --git a/Framework/Intersect.Framework.Core/Logging/Formatting/ILogFormatter.cs b/Framework/Intersect.Framework.Core/Logging/Formatting/ILogFormatter.cs deleted file mode 100644 index 61b981cd91..0000000000 --- a/Framework/Intersect.Framework.Core/Logging/Formatting/ILogFormatter.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace Intersect.Logging.Formatting; - - -public interface ILogFormatter -{ - - string Format( - LogConfiguration configuration, - LogLevel logLevel, - DateTime dateTime, - Exception exception, - string message, - params object[] args - ); - -} diff --git a/Framework/Intersect.Framework.Core/Logging/ILogger.cs b/Framework/Intersect.Framework.Core/Logging/ILogger.cs deleted file mode 100644 index 7be4f92b29..0000000000 --- a/Framework/Intersect.Framework.Core/Logging/ILogger.cs +++ /dev/null @@ -1,69 +0,0 @@ -namespace Intersect.Logging; - - -public interface ILogger -{ - - LogConfiguration Configuration { get; set; } - - void All(string message); - - void All(string format, params object[] args); - - void All(Exception exception, string message = null); - - void Debug(string message); - - void Debug(string format, params object[] args); - - void Debug(Exception exception, string message = null); - - void Diagnostic(string message); - - void Diagnostic(string format, params object[] args); - - void Diagnostic(Exception exception, string message = null); - - void Error(string message); - - void Error(string format, params object[] args); - - void Error(Exception exception, string message = null); - - void Info(string message); - - void Info(string format, params object[] args); - - void Info(Exception exception, string message = null); - - void Trace(string message); - - void Trace(string format, params object[] args); - - void Trace(Exception exception, string message = null); - - void Verbose(string message); - - void Verbose(string format, params object[] args); - - void Verbose(Exception exception, string message = null); - - void Warn(string message); - - void Warn(string format, params object[] args); - - void Warn(Exception exception, string message = null); - - void Write(LogLevel logLevel, string message); - - void Write(LogLevel logLevel, string format, params object[] args); - - void Write(LogLevel logLevel, Exception exception, string message = null); - - void Write(string message); - - void Write(string format, params object[] args); - - void Write(Exception exception, string message = null); - -} diff --git a/Framework/Intersect.Framework.Core/Logging/LegacyLogging.cs b/Framework/Intersect.Framework.Core/Logging/LegacyLogging.cs deleted file mode 100644 index 8aa4fcd634..0000000000 --- a/Framework/Intersect.Framework.Core/Logging/LegacyLogging.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Intersect.Logging; - -public static class LegacyLogging -{ - public static ILogger? Logger { get; set; } -} \ No newline at end of file diff --git a/Framework/Intersect.Framework.Core/Logging/LogConfiguration.cs b/Framework/Intersect.Framework.Core/Logging/LogConfiguration.cs deleted file mode 100644 index 5b0640f1f8..0000000000 --- a/Framework/Intersect.Framework.Core/Logging/LogConfiguration.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.Collections.Immutable; -using System.Diagnostics; - -using Intersect.Logging.Formatting; -using Intersect.Logging.Output; -using Microsoft.Extensions.Logging; - -namespace Intersect.Logging; - -/// -/// Configuration class for . -/// -public sealed partial class LogConfiguration -{ - private static readonly ILogFormatter DefaultFormatter = new DefaultFormatter(); - - private static readonly ImmutableList DefaultFormatters = - ImmutableList.Create() ?? throw new InvalidOperationException(); - - private static readonly ImmutableList DefaultOutputs = - ImmutableList.Create() ?? throw new InvalidOperationException(); - - private LogLevel mLogLevel; - - public static LogConfiguration Default => new LogConfiguration - { - Formatters = DefaultFormatters, - -#if DEBUG - LogLevel = Debugger.IsAttached ? LogLevel.All : LogLevel.Debug, -#else - LogLevel = Debugger.IsAttached ? LogLevel.All : LogLevel.Trace, -#endif - - Tag = null - }; - - public ILogFormatter Formatter => Formatters.FirstOrDefault() ?? DefaultFormatter; - - public IReadOnlyList? Formatters { get; init; } - - public LogLevel LogLevel - { - get => mLogLevel; - set => mLogLevel = value; - } - - public IReadOnlyList Outputs { get; init; } - - public string Tag { get; init; } - - internal LogConfiguration Clone() => - MemberwiseClone() as LogConfiguration ?? throw new InvalidOperationException(); -} diff --git a/Framework/Intersect.Framework.Core/Logging/LogLevel.cs b/Framework/Intersect.Framework.Core/Logging/LogLevel.cs deleted file mode 100644 index 505b82241c..0000000000 --- a/Framework/Intersect.Framework.Core/Logging/LogLevel.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace Intersect.Logging; - - -[JsonConverter(typeof(StringEnumConverter))] -public enum LogLevel : byte -{ - - None = 0, - - Error = 0x20, - - Warn = 0x40, - - Info = 0x60, - - Trace = 0x80, - - Verbose = 0xA0, - - Debug = 0xC0, - - Diagnostic = 0xE0, - - All = 0xFF - -} diff --git a/Framework/Intersect.Framework.Core/Logging/Output/ILogOutput.cs b/Framework/Intersect.Framework.Core/Logging/Output/ILogOutput.cs deleted file mode 100644 index 17fab2a925..0000000000 --- a/Framework/Intersect.Framework.Core/Logging/Output/ILogOutput.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace Intersect.Logging.Output; - - -public interface ILogOutput -{ - - LogLevel LogLevel { get; set; } - - void Write(LogConfiguration configuration, LogLevel logLevel, string message); - - void Write( - LogConfiguration configuration, - LogLevel logLevel, - string format, - params object[] args - ); - - void Write( - LogConfiguration configuration, - LogLevel logLevel, - Exception exception, - string message - ); - - void Write( - LogConfiguration configuration, - LogLevel logLevel, - Exception exception, - string format, - params object[] args - ); - -} diff --git a/Framework/Intersect.Framework.Core/Models/ObjectCacheData.cs b/Framework/Intersect.Framework.Core/Models/ObjectCacheData.cs index c80c99e15f..b2d1de27df 100644 --- a/Framework/Intersect.Framework.Core/Models/ObjectCacheData.cs +++ b/Framework/Intersect.Framework.Core/Models/ObjectCacheData.cs @@ -28,6 +28,8 @@ public string Checksum public string Version { get; init; } + public ObjectCacheKey GetKey() => new(Id: Id, Checksum: Checksum, Version: Version); + public static string? GetCacheFileName(Id id) { var hashData = new byte[32]; diff --git a/Framework/Intersect.Framework.Core/Models/ObjectDataDiskCache.cs b/Framework/Intersect.Framework.Core/Models/ObjectDataDiskCache.cs index b149866df9..79ad002438 100644 --- a/Framework/Intersect.Framework.Core/Models/ObjectDataDiskCache.cs +++ b/Framework/Intersect.Framework.Core/Models/ObjectDataDiskCache.cs @@ -5,8 +5,9 @@ using System.Security.Cryptography; using System.Text; using Intersect.Configuration; +using Intersect.Core; using Intersect.Framework; -using Intersect.Logging; +using Microsoft.Extensions.Logging; namespace Intersect.Models; @@ -127,7 +128,7 @@ public static bool TryLoad(Guid id, [NotNullWhen(true)] out ObjectCacheData objectCacheData) } catch (Exception exception) { - LegacyLogging.Logger?.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Failed to save cache item {CacheKey}", + objectCacheData.GetKey() + ); return false; } } diff --git a/Framework/Intersect.Framework.Core/Network/Ceras.cs b/Framework/Intersect.Framework.Core/Network/Ceras.cs index 643e44b254..c4ee28028b 100644 --- a/Framework/Intersect.Framework.Core/Network/Ceras.cs +++ b/Framework/Intersect.Framework.Core/Network/Ceras.cs @@ -1,7 +1,9 @@ using Ceras; -using Intersect.Logging; +using Intersect.Core; +using Intersect.Framework.Reflection; using K4os.Compression.LZ4; +using Microsoft.Extensions.Logging; namespace Intersect.Network; @@ -97,7 +99,7 @@ public object Deserialize(byte[] data) } catch (Exception exception) { - LegacyLogging.Logger?.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Failed to deserialize Ceras packet"); return null; } @@ -114,7 +116,11 @@ public object Deserialize(byte[] data) } catch (Exception exception) { - LegacyLogging.Logger?.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Failed to deserialize Ceras packet to a {Type}", + typeof(T).GetName(qualified: true) + ); return default; } diff --git a/Framework/Intersect.Framework.Core/Network/INetwork.cs b/Framework/Intersect.Framework.Core/Network/INetwork.cs index 0bc7a77e18..34a90a8e5b 100644 --- a/Framework/Intersect.Framework.Core/Network/INetwork.cs +++ b/Framework/Intersect.Framework.Core/Network/INetwork.cs @@ -1,5 +1,4 @@ using Intersect.Plugins.Interfaces; - using System.Net; using Intersect.Core; diff --git a/Framework/Intersect.Framework.Core/Network/IntersectPacket.cs b/Framework/Intersect.Framework.Core/Network/IntersectPacket.cs index 2fa0300d98..6c66e487cc 100644 --- a/Framework/Intersect.Framework.Core/Network/IntersectPacket.cs +++ b/Framework/Intersect.Framework.Core/Network/IntersectPacket.cs @@ -1,7 +1,7 @@ using Intersect.Collections; using Intersect.Framework.Reflection; #if DIAGNOSTIC -using Intersect.Logging; + #endif using MessagePack; @@ -31,7 +31,7 @@ public virtual byte[] Data throw new Exception($"Failed to serialize {this.GetFullishName()}"); #if DIAGNOSTIC - Log.Debug($"{GetType().FullName}({mCachedData.Length})={Convert.ToHexString(mCachedData)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"{GetType().FullName}({mCachedData.Length})={Convert.ToHexString(mCachedData)}"); #endif return mCachedData; } diff --git a/Framework/Intersect.Framework.Core/Network/MessagePacker.cs b/Framework/Intersect.Framework.Core/Network/MessagePacker.cs index e3c72cbdc2..8428ce3278 100644 --- a/Framework/Intersect.Framework.Core/Network/MessagePacker.cs +++ b/Framework/Intersect.Framework.Core/Network/MessagePacker.cs @@ -1,6 +1,7 @@ -using Intersect.Logging; +using Intersect.Core; using MessagePack; using Intersect.Memory; +using Microsoft.Extensions.Logging; namespace Intersect.Network; @@ -45,7 +46,7 @@ public byte[] Serialize(IntersectPacket packet) if (!silent) { - LegacyLogging.Logger?.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Failed to deserialize packet data"); } return null; diff --git a/Framework/Intersect.Framework.Core/Network/PacketHandlerRegistry.cs b/Framework/Intersect.Framework.Core/Network/PacketHandlerRegistry.cs index 3f5a0e403a..9c42e1968c 100644 --- a/Framework/Intersect.Framework.Core/Network/PacketHandlerRegistry.cs +++ b/Framework/Intersect.Framework.Core/Network/PacketHandlerRegistry.cs @@ -1,7 +1,7 @@ using Intersect.Collections; -using Intersect.Logging; using System.Reflection; using Intersect.Framework.Reflection; +using Microsoft.Extensions.Logging; namespace Intersect.Network; @@ -262,13 +262,13 @@ protected virtual bool TryRegister(IEnumerable methodInfos, object t var packetType = PacketHandlerAttribute.GetPacketType(methodInfo); if (!PacketTypeRegistry.IsRegistered(packetType)) { - Logger.Error($"The packet type '{packetType.FullName}' has not been registered, a handler cannot be added."); + Logger.LogError($"The packet type '{packetType.FullName}' has not been registered, a handler cannot be added."); return false; } if (HasHandler(packetType)) { - Logger.Error($"There is already a packet handler for '{packetType.FullName}'."); + Logger.LogError($"There is already a packet handler for '{packetType.FullName}'."); return false; } @@ -279,7 +279,12 @@ protected virtual bool TryRegister(IEnumerable methodInfos, object t catch (Exception exception) #pragma warning restore CA1031 // Do not catch general exception types { - Logger.Error(exception); + Logger.LogError( + exception, + "Error registering handler for {Method} on {Type}", + methodInfo.Name, + methodInfo.DeclaringType?.GetName(qualified: true) + ); return false; } @@ -300,13 +305,13 @@ protected virtual bool TryRegister(IEnumerable types) var packetType = PacketHandlerAttribute.GetPacketType(type); if (!PacketTypeRegistry.IsRegistered(packetType)) { - Logger.Error($"The packet type '{packetType.FullName}' has not been registered, a handler cannot be added."); + Logger.LogError($"The packet type \'{packetType.FullName}\' has not been registered, a handler cannot be added."); return false; } if (HasHandler(packetType)) { - Logger.Error($"There is already a packet handler for '{packetType.FullName}'."); + Logger.LogError($"There is already a packet handler for '{packetType.FullName}'."); return false; } @@ -329,13 +334,13 @@ protected virtual bool TryRegister(Dictionary> collec var realPacketType = PacketHandlerAttribute.GetPacketType(handlerType); if (packetType != realPacketType) { - Logger.Error($"Handler {handlerType.FullName} is incompatible with {packetType.FullName}, expected {realPacketType.FullName}."); + Logger.LogError($"Handler {handlerType.FullName} is incompatible with {packetType.FullName}, expected {realPacketType.FullName}."); return false; } if (!PacketTypeRegistry.IsRegistered(realPacketType)) { - Logger.Error($"The packet type '{packetType.FullName}' has not been registered, a handler cannot be added."); + Logger.LogError($"The packet type '{packetType.FullName}' has not been registered, a handler cannot be added."); return false; } @@ -395,13 +400,13 @@ public virtual bool TryRegisterHandler(Type handlerType, out IPacketHandler hand var packetType = PacketHandlerAttribute.GetPacketType(handlerType); if (!PacketTypeRegistry.IsRegistered(packetType)) { - Logger.Error($"The packet type '{packetType.FullName}' has not been registered, a handler cannot be added."); + Logger.LogError($"The packet type '{packetType.FullName}' has not been registered, a handler cannot be added."); return false; } if (HasHandler(packetType)) { - Logger.Error($"There is already a packet handler for '{packetType.FullName}'."); + Logger.LogError($"There is already a packet handler for '{packetType.FullName}'."); return false; } diff --git a/Framework/Intersect.Framework.Core/Network/PacketTypeRegistry.cs b/Framework/Intersect.Framework.Core/Network/PacketTypeRegistry.cs index ce190793d6..0c0a91a9a8 100644 --- a/Framework/Intersect.Framework.Core/Network/PacketTypeRegistry.cs +++ b/Framework/Intersect.Framework.Core/Network/PacketTypeRegistry.cs @@ -1,6 +1,7 @@ using Intersect.Collections; -using Intersect.Logging; using System.Reflection; +using Intersect.Framework.Reflection; +using Microsoft.Extensions.Logging; namespace Intersect.Network; @@ -76,7 +77,11 @@ public bool TryRegister(Type packetType) case ArgumentNullException _: case ArgumentException _: case InvalidOperationException _: - Logger.Error(exception); + Logger.LogError( + exception, + "Failed to register packet type {Type}", + packetType.GetName(qualified: true) + ); return false; default: diff --git a/Framework/Intersect.Framework.Core/Plugins/IPluginBaseContext.cs b/Framework/Intersect.Framework.Core/Plugins/IPluginBaseContext.cs index 9ae9fed531..496e5e9c40 100644 --- a/Framework/Intersect.Framework.Core/Plugins/IPluginBaseContext.cs +++ b/Framework/Intersect.Framework.Core/Plugins/IPluginBaseContext.cs @@ -1,5 +1,4 @@ using System.Reflection; - using Intersect.Plugins.Interfaces; namespace Intersect.Plugins; diff --git a/Framework/Intersect.Framework.Core/Plugins/Interfaces/CreateLoggerOptions.cs b/Framework/Intersect.Framework.Core/Plugins/Interfaces/CreateLoggerOptions.cs index 599bffada8..5c47051f27 100644 --- a/Framework/Intersect.Framework.Core/Plugins/Interfaces/CreateLoggerOptions.cs +++ b/Framework/Intersect.Framework.Core/Plugins/Interfaces/CreateLoggerOptions.cs @@ -1,30 +1,30 @@ -using Intersect.Logging; -using Intersect.Logging.Formatting; + +using Microsoft.Extensions.Logging; namespace Intersect.Plugins.Interfaces; /// /// Configuration options for creating s. /// -public partial struct CreateLoggerOptions +public record struct CreateLoggerOptions { /// /// The minimum for console output, set to to disable. /// - public LogLevel Console { get; set; } + public LogLevel Console { get; init; } /// /// The minimum for file output, set to to disable. /// - public LogLevel File { get; set; } + public LogLevel File { get; init; } /// - /// The custom formatters to use for output from the created . + /// The name of the created . /// - public IReadOnlyList Formatters { get; set; } + public string Name { get; init; } /// - /// The name of the created . + /// The context type of the logger. /// - public string Name { get; set; } + public Type ContextType { get; init; } } \ No newline at end of file diff --git a/Framework/Intersect.Framework.Core/Plugins/Interfaces/ILoggingHelper.cs b/Framework/Intersect.Framework.Core/Plugins/Interfaces/ILoggingHelper.cs index 06b05f1e42..d6fc5489b1 100644 --- a/Framework/Intersect.Framework.Core/Plugins/Interfaces/ILoggingHelper.cs +++ b/Framework/Intersect.Framework.Core/Plugins/Interfaces/ILoggingHelper.cs @@ -1,4 +1,4 @@ -using Intersect.Logging; +using Microsoft.Extensions.Logging; namespace Intersect.Plugins.Interfaces; @@ -23,4 +23,11 @@ public interface ILoggingHelper /// options to configure the /// a specialized instance ILogger CreateLogger(CreateLoggerOptions createLoggerOptions); + + /// + /// Creates specialized s for the active plugin. + /// + /// options to configure the + /// a specialized instance + ILogger CreateLogger(CreateLoggerOptions createLoggerOptions); } \ No newline at end of file diff --git a/Framework/Intersect.Framework.Core/Plugins/Interfaces/IManifestHelper.cs b/Framework/Intersect.Framework.Core/Plugins/Interfaces/IManifestHelper.cs index 823d987481..4e44219238 100644 --- a/Framework/Intersect.Framework.Core/Plugins/Interfaces/IManifestHelper.cs +++ b/Framework/Intersect.Framework.Core/Plugins/Interfaces/IManifestHelper.cs @@ -1,5 +1,4 @@ using Intersect.Plugins.Manifests.Types; - using Semver; namespace Intersect.Plugins.Interfaces; diff --git a/Framework/Intersect.Framework.Core/Plugins/Manifests/JsonManifest.cs b/Framework/Intersect.Framework.Core/Plugins/Manifests/JsonManifest.cs index ca01ea0355..bad3c124c9 100644 --- a/Framework/Intersect.Framework.Core/Plugins/Manifests/JsonManifest.cs +++ b/Framework/Intersect.Framework.Core/Plugins/Manifests/JsonManifest.cs @@ -1,8 +1,6 @@ using Intersect.Plugins.Interfaces; using Intersect.Plugins.Manifests.Types; - using Newtonsoft.Json; - using Semver; namespace Intersect.Plugins.Manifests; diff --git a/Framework/Intersect.Framework.Core/Plugins/Manifests/Types/Authors.cs b/Framework/Intersect.Framework.Core/Plugins/Manifests/Types/Authors.cs index f03e403f3e..4197a29aee 100644 --- a/Framework/Intersect.Framework.Core/Plugins/Manifests/Types/Authors.cs +++ b/Framework/Intersect.Framework.Core/Plugins/Manifests/Types/Authors.cs @@ -1,5 +1,4 @@ using System.Collections; - using Newtonsoft.Json; namespace Intersect.Plugins.Manifests.Types; diff --git a/Framework/Intersect.Framework.Core/Reflection/ReflectionUtils.cs b/Framework/Intersect.Framework.Core/Reflection/ReflectionUtils.cs index 00adefdfcd..658f6ec4da 100644 --- a/Framework/Intersect.Framework.Core/Reflection/ReflectionUtils.cs +++ b/Framework/Intersect.Framework.Core/Reflection/ReflectionUtils.cs @@ -1,8 +1,8 @@ using System.IO.Compression; using System.Reflection; using System.Text; - -using Intersect.Logging; +using Intersect.Core; +using Microsoft.Extensions.Logging; namespace Intersect.Utilities; @@ -117,7 +117,11 @@ public static bool ExtractCompressedResource(string resourceName, Stream destina } catch (Exception exception) { - LegacyLogging.Logger?.Error(exception, $"resourceName: '{resourceName}'"); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "resourceName: '{ResourceName}'", + resourceName + ); return false; } @@ -145,7 +149,11 @@ public static bool ExtractResource(string resourceName, Stream destinationStream } catch (Exception exception) { - LegacyLogging.Logger?.Error(exception, $"resourceName: '{resourceName}'"); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "resourceName: '{ResourceName}'", + resourceName + ); return false; } diff --git a/Framework/Intersect.Framework.Core/Serialization/SafeStringEnumConverter.cs b/Framework/Intersect.Framework.Core/Serialization/SafeStringEnumConverter.cs new file mode 100644 index 0000000000..97ec63f68f --- /dev/null +++ b/Framework/Intersect.Framework.Core/Serialization/SafeStringEnumConverter.cs @@ -0,0 +1,42 @@ +using Intersect.Core; +using Intersect.Framework.Reflection; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; + +namespace Intersect.Framework.Core.Serialization; + +public sealed class SafeStringEnumConverter : JsonConverter +{ + private readonly StringEnumConverter _baseConverter = new(); + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + _baseConverter.WriteJson(writer, value, serializer); + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + try + { + return _baseConverter.ReadJson( + reader, + objectType, + existingValue, + serializer + ); + } + catch (Exception exception) + { + ApplicationContext.Context.Value?.Logger.LogWarning( + exception, + "Error parsing {ObjectType}", + objectType.GetName(qualified: true) + ); + + return existingValue; + } + } + + public override bool CanConvert(Type objectType) => _baseConverter.CanConvert(objectType); +} \ No newline at end of file diff --git a/Intersect (Core)/Console.cs b/Intersect (Core)/Console.cs index 79f33e26bc..80a5e92ed3 100644 --- a/Intersect (Core)/Console.cs +++ b/Intersect (Core)/Console.cs @@ -1,10 +1,8 @@ using System.Text; - using Intersect.IO; namespace Intersect; - using SystemConsole = System.Console; // TODO: Make this instanceable diff --git a/Intersect (Core)/Core/ApplicationContext`2.cs b/Intersect (Core)/Core/ApplicationContext`2.cs index eca27b18ee..c2fa13a834 100644 --- a/Intersect (Core)/Core/ApplicationContext`2.cs +++ b/Intersect (Core)/Core/ApplicationContext`2.cs @@ -1,12 +1,12 @@ -using Intersect.Logging; + using Intersect.Threading; using System.Collections.Concurrent; using System.Diagnostics; using System.Reflection; - using Intersect.Properties; using Intersect.Plugins.Interfaces; using Intersect.Network; +using Microsoft.Extensions.Logging; using AssemblyExtensions = Intersect.Reflection.AssemblyExtensions; namespace Intersect.Core; @@ -38,7 +38,7 @@ public abstract partial class ApplicationContext : IA /// the the application was started with /// the application-level /// - protected ApplicationContext(TStartupOptions startupOptions, Logger logger, IPacketHelper packetHelper) + protected ApplicationContext(TStartupOptions startupOptions, ILogger logger, IPacketHelper packetHelper) { mDisposeLock = new object(); mShutdownLock = new object(); @@ -177,7 +177,7 @@ protected virtual void DiscoverServices() foreach (var serviceType in serviceTypes) { - Log.Info($"Discovered service type: {serviceType.FullName}"); + ApplicationContext.Context.Value?.Logger.LogInformation($"Discovered service type: {serviceType.FullName}"); Debug.Assert(serviceType != null, nameof(serviceType) + " != null"); if (!(Activator.CreateInstance(serviceType) is IApplicationService service)) { @@ -233,7 +233,7 @@ public void Start(bool lockUntilShutdown = true) } catch (Exception exception) { - Logger.Error(exception); + Logger.LogError(exception, "Failed to start application context"); return; } @@ -249,7 +249,7 @@ public void Start(bool lockUntilShutdown = true) } catch (ServiceLifecycleFailureException serviceLifecycleFailureException) { - Logger.Error(serviceLifecycleFailureException); + Logger.LogError(serviceLifecycleFailureException, "Error occurred during application startup"); return; } @@ -265,7 +265,7 @@ public void Start(bool lockUntilShutdown = true) lock (mShutdownLock) { Monitor.Wait(mShutdownLock); - Log.Diagnostic(DeveloperStrings.ApplicationContextExited); + ApplicationContext.Context.Value?.Logger.LogTrace(DeveloperStrings.ApplicationContextExited); } #endregion Wait for application thread @@ -367,17 +367,11 @@ protected virtual void NotifyNonTerminatingExceptionOccurred() { } internal static void ProcessUnhandledException(object sender, Exception exception) { - var currentException = exception; - var innerException = false; - - while (currentException != null) - { - Log.Error(innerException ? "Caused by:" : $"Received unhandled exception from {sender}: {currentException.Message}"); - Log.Error(currentException); - - currentException = currentException.InnerException; - innerException = true; - } + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Received an unhandled exception from {Sender}", + sender + ); } private void SafeAbort(bool hasErrors) @@ -540,16 +534,19 @@ private void InternalDispose() } catch (ServiceLifecycleFailureException serviceLifecycleFailureException) { - Logger.Error(serviceLifecycleFailureException); + Logger.LogError( + serviceLifecycleFailureException, + "Error occurred while stopping services during context disposal" + ); } var stopwatch = new Stopwatch(); stopwatch.Start(); - Log.Info($@"Beginning context dispose. ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation($@"Beginning context dispose. ({stopwatch.ElapsedMilliseconds}ms)"); Dispose(true); - Log.Info($@"GC.SuppressFinalize ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation($@"GC.SuppressFinalize ({stopwatch.ElapsedMilliseconds}ms)"); GC.SuppressFinalize(this); - Log.Info($@"InternalDispose() completed. ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation($@"InternalDispose() completed. ({stopwatch.ElapsedMilliseconds}ms)"); IsDisposed = true; } diff --git a/Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Core.cs b/Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Core.cs deleted file mode 100644 index 8fb5d8ab85..0000000000 --- a/Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Core.cs +++ /dev/null @@ -1,257 +0,0 @@ -using System.Reflection; -using System.Text; - -using Intersect.Extensions; -using Intersect.Framework.Core.Serialization; -using Intersect.Logging; -using Intersect.Utilities; - -using Newtonsoft.Json; - -namespace Intersect.Core.ExperimentalFeatures; - - -public abstract partial class CommonExperiments : IFlagProvider - where TExperiments : CommonExperiments -{ - - private static readonly Guid NamespaceId = Guid.Parse("c68012b3-d666-4204-84eb-4976f2b570ab"); - - private readonly IDictionary mFlagsById; - - private readonly IDictionary mFlagsByName; - - protected CommonExperiments() - { - mFlagsById = new Dictionary(); - mFlagsByName = new Dictionary(); - - RegisterPropertiesAndAliases(); - } - - public bool IsEnabled(Guid flagId) - { - return mFlagsById.TryGetValue(flagId, out var property) && - property.GetValue(this) is IExperimentalFlag flag && - flag.Enabled; - } - - public bool IsEnabled(string flagName) - { - return mFlagsByName.TryGetValue(flagName, out var property) && - property.GetValue(this) is IExperimentalFlag flag && - flag.Enabled; - } - - public bool TryGet(Guid flagId, out IExperimentalFlag flag) - { - return ValueUtils.SetDefault(TryGetProperty(flagId, out var property), out flag) && - property.TryGetValue(this, out flag); - } - - public bool TryGet(string flagName, out IExperimentalFlag flag) - { - return ValueUtils.SetDefault(TryGetProperty(flagName, out var property), out flag) && - property.TryGetValue(this, out flag); - } - - private void RegisterPropertiesAndAliases() - { - PropertyInfo existingFlag; - var experimentsType = typeof(TExperiments); - var aliasProperties = new List<(PropertyInfo property, ExperimentalFlagAliasAttribute aliasAttribute)>(); - var properties = - experimentsType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - - var flagProperties = properties - .Where(property => typeof(IExperimentalFlag).IsAssignableFrom(property.PropertyType)) - .ToList(); - - flagProperties.ForEach( - property => - { - var aliasAttribute = property?.GetCustomAttribute(true); - if (aliasAttribute != null) - { - aliasProperties.Add((property, aliasAttribute)); - - return; - } - - if (property?.DeclaringType == null) - { - throw new InvalidOperationException(); - } - - var flagName = property.Name.ToLowerInvariant(); - var namespaceId = GetNamespaceIdFor(property.DeclaringType); - var flagId = GuidUtils.CreateNamed(namespaceId, property.Name); - - if (TryGetProperty(flagName, out existingFlag)) - { - throw new InvalidOperationException( - $@"Tried to add a flag with name '{flagName}' in '{property.DeclaringType?.FullName}' but there is already a flag with that name defined in '{existingFlag.DeclaringType?.FullName}'." - ); - } - - mFlagsById.Add(flagId, property); - mFlagsByName.Add(flagName, property); - } - ); - - aliasProperties.ForEach( - pair => - { - var (property, aliasAttribute) = pair; - var aliasName = property.Name.ToLowerInvariant(); - var targetName = aliasAttribute.Of; - var alias = new ExperimentalFlagAlias(this, targetName, aliasName); - property.SetValue(this, alias); - - if (TryGetProperty(aliasName, out existingFlag)) - { - throw new InvalidOperationException( - $@"Tried to add an alias with name '{aliasName}' in '{property.DeclaringType?.FullName}' but there is already a flag with that name defined in '{existingFlag.DeclaringType?.FullName}'." - ); - } - - mFlagsByName.Add(aliasName, property); - } - ); - } - - public bool Disable(IExperimentalFlag flag) - { - return TrySet(flag, false); - } - - public bool Disable(Guid flagId) - { - return TrySet(flagId, false); - } - - public bool Disable(string flagName) - { - return TrySet(flagName, false); - } - - public bool Enable(IExperimentalFlag flag) - { - return TrySet(flag, true); - } - - public bool Enable(Guid flagId) - { - return TrySet(flagId, true); - } - - public bool Enable(string flagName) - { - return TrySet(flagName, true); - } - - protected bool TryGetProperty(IExperimentalFlag flag, out PropertyInfo flagPropertyInfo) - { - return mFlagsById.TryGetValue(flag.Guid, out flagPropertyInfo); - } - - protected bool TryGetProperty(Guid flagId, out PropertyInfo flagPropertyInfo) - { - return mFlagsById.TryGetValue(flagId, out flagPropertyInfo); - } - - protected bool TryGetProperty(string flagName, out PropertyInfo flagPropertyInfo) - { - return ValueUtils.SetDefault(!string.IsNullOrWhiteSpace(flagName), out flagPropertyInfo) && - mFlagsByName.TryGetValue(flagName.ToLowerInvariant(), out flagPropertyInfo); - } - - private bool InternalTrySet(PropertyInfo property, IExperimentalFlag flag, bool enabled) - { - /* Unwraps the flag */ - if (flag is ExperimentalFlagAlias && !TryGet(flag.Guid, out flag)) - { - return false; - } - - if (property == null && !TryGetProperty(flag, out property)) - { - return false; - } - - property.SetValue(this, flag.With(enabled)); - Save(); - - return true; - } - - public bool TrySet(IExperimentalFlag flag, bool enabled) - { - return InternalTrySet(null, flag, enabled); - } - - public bool TrySet(Guid flagId, bool enabled) - { - return TryGetProperty(flagId, out var property) && - property.GetValue(this) is IExperimentalFlag flag && - InternalTrySet(property, flag, enabled); - } - - public bool TrySet(string flagName, bool enabled) - { - return TryGetProperty(flagName, out var property) && - property.GetValue(this) is IExperimentalFlag flag && - InternalTrySet(property, flag, enabled); - } - - protected virtual bool Load() - { - if (!File.Exists(CONFIG_PATH)) - { - return false; - } - - try - { - var json = File.ReadAllText(CONFIG_PATH, Encoding.UTF8); - JsonConvert.PopulateObject( - json, Instance, new JsonSerializerSettings - { - Converters = new List - { - new ExperimentalFlagConverter() - }, - SerializationBinder = new IntersectTypeSerializationBinder(), - } - ); - - return true; - } - catch (Exception exception) - { - Log.Error(exception); - - return false; - } - } - - protected virtual void Save() - { - try - { - var directory = Path.GetDirectoryName(CONFIG_PATH) ?? "resources/config"; - if (!Directory.Exists(directory)) - { - Directory.CreateDirectory(directory); - } - - var json = JsonConvert.SerializeObject(Instance, Formatting.Indented); - File.WriteAllText(CONFIG_PATH, json, Encoding.UTF8); - } - catch (Exception exception) - { - Log.Error(exception); - } - } - -} diff --git a/Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Flags.cs b/Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Flags.cs deleted file mode 100644 index 9247da33b4..0000000000 --- a/Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Flags.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Newtonsoft.Json; - -namespace Intersect.Core.ExperimentalFeatures; - - -public abstract partial class CommonExperiments where TExperiments : CommonExperiments -{ - - [JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public IExperimentalFlag All { get; protected set; } = new ExperimentalFlag(nameof(All), NamespaceId); - - [JsonIgnore, ExperimentalFlagAlias(nameof(All))] - public IExperimentalFlag ExperimentalFeatures { get; protected set; } - -} diff --git a/Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Static.cs b/Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Static.cs deleted file mode 100644 index 3937b5157f..0000000000 --- a/Intersect (Core)/Core/ExperimentalFeatures/CommonExperiments.Static.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Reflection; - -namespace Intersect.Core.ExperimentalFeatures; - - -public abstract partial class CommonExperiments where TExperiments : CommonExperiments -{ - - public const string CONFIG_PATH = "resources/config/experiments.config.json"; - - private static readonly IDictionary mNamespaceIdsByDeclaringType; - - private static TExperiments mInstance; - - static CommonExperiments() - { - mNamespaceIdsByDeclaringType = new Dictionary(); - } - - protected static TExperiments Instance - { - get => mInstance ?? - throw new InvalidOperationException( - $@"Did you forget to set this in the static constructor for '{typeof(TExperiments).AssemblyQualifiedName}'." - ); - set => mInstance = value; - } - - protected static Guid GetNamespaceIdFor(Type declaringType) - { - if (mNamespaceIdsByDeclaringType.TryGetValue(declaringType, out var namespaceId)) - { - return namespaceId; - } - - var namespaceIdProperty = declaringType.GetField( - nameof(NamespaceId), BindingFlags.Static | BindingFlags.NonPublic - ); - - if (namespaceIdProperty == null) - { - throw new InvalidOperationException(); - } - - // ReSharper disable once InvertIf - if (namespaceIdProperty.GetValue(null) is Guid generatedNamespaceId) - { - mNamespaceIdsByDeclaringType[declaringType] = generatedNamespaceId; - - return generatedNamespaceId; - } - - throw new InvalidOperationException(); - } - -} diff --git a/Intersect (Core)/Core/ExperimentalFeatures/ExperimentNamespace.cs b/Intersect (Core)/Core/ExperimentalFeatures/ExperimentNamespace.cs deleted file mode 100644 index e515ac59a5..0000000000 --- a/Intersect (Core)/Core/ExperimentalFeatures/ExperimentNamespace.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Intersect.Core.ExperimentalFeatures; - - -[Serializable] -public abstract partial class ExperimentNamespace -{ - -} diff --git a/Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlag.cs b/Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlag.cs deleted file mode 100644 index d4555e5f86..0000000000 --- a/Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlag.cs +++ /dev/null @@ -1,84 +0,0 @@ -using Intersect.Utilities; - -using Newtonsoft.Json; - -namespace Intersect.Core.ExperimentalFeatures; - - -public partial struct ExperimentalFlag : IExperimentalFlag -{ - - private readonly IExperimentalFlag mParentFlag; - - [JsonProperty(nameof(Guid))] private Guid mGuid; - - [JsonIgnore] - public Guid Guid => mGuid; - - [JsonProperty(nameof(Name))] private string mName; - - [JsonIgnore] - public string Name => mName; - - [JsonProperty(nameof(Enabled))] private bool mEnabled; - - [JsonIgnore] - public bool Enabled => (mParentFlag?.Enabled ?? true) && mEnabled; - - private ExperimentalFlag(ExperimentalFlag flag, bool enabled = false) - { - mParentFlag = flag.mParentFlag; - mGuid = flag.Guid; - mName = flag.Name; - mEnabled = enabled; - } - - public ExperimentalFlag( - string name, - Guid namespaceId, - bool enabled = false, - IExperimentalFlag parentFlag = null - ) - { - if (string.IsNullOrWhiteSpace(name)) - { - throw new ArgumentNullException(nameof(name)); - } - - mParentFlag = parentFlag; - mGuid = GuidUtils.CreateNamed(namespaceId, name); - mName = name; - mEnabled = enabled; - } - - public IExperimentalFlag With(bool enabled) - { - return new ExperimentalFlag(this, enabled); - } - - /// - public bool Equals(IExperimentalFlag other) - { - return this == other; - } - - /// - /// - /// - /// - public static implicit operator bool(ExperimentalFlag flag) - { - return flag.Enabled; - } - - public static bool operator ==(ExperimentalFlag a, IExperimentalFlag b) - { - return a.Guid == b.Guid && a.Enabled == b.Enabled; - } - - public static bool operator !=(ExperimentalFlag a, IExperimentalFlag b) - { - return a.Guid != b.Guid || a.Enabled != b.Enabled; - } - -} diff --git a/Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlagAlias.cs b/Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlagAlias.cs deleted file mode 100644 index aaf60a2973..0000000000 --- a/Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlagAlias.cs +++ /dev/null @@ -1,77 +0,0 @@ -namespace Intersect.Core.ExperimentalFeatures; - - -public partial struct ExperimentalFlagAlias : IExperimentalFlag -{ - - private readonly IFlagProvider mFlagProvider; - - private readonly string mTargetName; - - private Guid mCachedGuid; - - public string Name { get; } - - public ExperimentalFlagAlias( - IFlagProvider flagProvider, - string targetName, - string aliasName - ) - { - if (string.IsNullOrWhiteSpace(targetName)) - { - throw new ArgumentNullException(nameof(targetName)); - } - - if (string.IsNullOrWhiteSpace(aliasName)) - { - throw new ArgumentNullException(nameof(aliasName)); - } - - mFlagProvider = flagProvider; - mTargetName = targetName; - mCachedGuid = default(Guid); - - Name = aliasName; - } - - /// - public Guid Guid - { - get - { - if (mCachedGuid != default(Guid)) - { - return mCachedGuid; - } - - if (!mFlagProvider.TryGet(mTargetName, out var flag)) - { - throw new ArgumentException(nameof(mTargetName)); - } - - return mCachedGuid = flag.Guid; - } - } - - /// - public bool Enabled => mFlagProvider.IsEnabled(Guid); - - /// - public bool Equals(IExperimentalFlag other) - { - return Guid == other?.Guid && Enabled == other.Enabled; - } - - /// - public IExperimentalFlag With(bool enabled) - { - if (!mFlagProvider.TryGet(Guid, out var flag)) - { - throw new InvalidOperationException(); - } - - return flag.With(enabled); - } - -} diff --git a/Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlagAliasAttribute.cs b/Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlagAliasAttribute.cs deleted file mode 100644 index 174d99ebd5..0000000000 --- a/Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlagAliasAttribute.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Intersect.Core.ExperimentalFeatures; - - -[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] -public partial class ExperimentalFlagAliasAttribute : Attribute -{ - - public ExperimentalFlagAliasAttribute(string of) - { - if (string.IsNullOrWhiteSpace(of)) - { - throw new ArgumentNullException(nameof(of)); - } - - Of = of; - } - - public string Of { get; } - -} diff --git a/Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlagConverter.cs b/Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlagConverter.cs deleted file mode 100644 index dbb0c0d91b..0000000000 --- a/Intersect (Core)/Core/ExperimentalFeatures/ExperimentalFlagConverter.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Newtonsoft.Json; - -namespace Intersect.Core.ExperimentalFeatures; - - -public partial class ExperimentalFlagConverter : JsonConverter -{ - - public override bool CanRead => true; - - public override bool CanWrite => true; - - /// - public override void WriteJson( - JsonWriter writer, - ExperimentalFlag value, - JsonSerializer serializer - ) - { - serializer.Serialize(writer, value); - } - - /// - public override ExperimentalFlag ReadJson( - JsonReader reader, - Type objectType, - ExperimentalFlag existingValue, - bool hasExistingValue, - JsonSerializer serializer - ) - { - serializer.Populate(reader, existingValue); - - return existingValue; - } - -} diff --git a/Intersect (Core)/Core/ExperimentalFeatures/IExperimentalFlag.cs b/Intersect (Core)/Core/ExperimentalFeatures/IExperimentalFlag.cs deleted file mode 100644 index 82f2333846..0000000000 --- a/Intersect (Core)/Core/ExperimentalFeatures/IExperimentalFlag.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace Intersect.Core.ExperimentalFeatures; - - -public interface IExperimentalFlag : IEquatable -{ - - Guid Guid { get; } - - string Name { get; } - - bool Enabled { get; } - - /// - /// Creates a clone of this with the given enablement. - /// - /// the new enablement state - /// a clone of this flag with the new enablement state - IExperimentalFlag With(bool enabled); - -} diff --git a/Intersect (Core)/Core/ExperimentalFeatures/IFlagProvider.cs b/Intersect (Core)/Core/ExperimentalFeatures/IFlagProvider.cs deleted file mode 100644 index 26355c7ad9..0000000000 --- a/Intersect (Core)/Core/ExperimentalFeatures/IFlagProvider.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Intersect.Core.ExperimentalFeatures; - - -public interface IFlagProvider -{ - - bool IsEnabled(Guid flagId); - - bool IsEnabled(string flagName); - - bool TryGet(Guid flagId, out IExperimentalFlag flag); - - bool TryGet(string flagName, out IExperimentalFlag flag); - -} diff --git a/Intersect (Core)/Core/ServiceLifecycleFailureException.cs b/Intersect (Core)/Core/ServiceLifecycleFailureException.cs index 008e21df67..b32680dd4b 100644 --- a/Intersect (Core)/Core/ServiceLifecycleFailureException.cs +++ b/Intersect (Core)/Core/ServiceLifecycleFailureException.cs @@ -1,7 +1,6 @@ using System.Diagnostics; using System.Diagnostics.Contracts; using System.Runtime.Serialization; - using Intersect.Properties; namespace Intersect.Core; diff --git a/Intersect (Core)/CustomColors.cs b/Intersect (Core)/CustomColors.cs index 5710a1c532..aa5a7fdaff 100644 --- a/Intersect (Core)/CustomColors.cs +++ b/Intersect (Core)/CustomColors.cs @@ -1,7 +1,6 @@ using System.Text; - -using Intersect.Logging; - +using Intersect.Core; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; namespace Intersect; @@ -238,7 +237,7 @@ public sealed partial class ItemsNamespace {5, Color.Yellow}, }; - public Dictionary MapRarities = new Dictionary() + public Dictionary MapRarities = new Dictionary() { { 0, new LabelColor(Color.White, Color.Black, new Color(100, 0, 0, 0)) }, { 1, new LabelColor(Color.Gray, Color.Black, new Color(100, 0, 0, 0)) }, @@ -269,7 +268,11 @@ public static bool Load() } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Failed to deserialize '{Path}'", + filepath + ); return false; } @@ -282,9 +285,9 @@ public static bool Save() { Console.WriteLine("Saving custom colors..."); + var filepath = Path.Combine(Options.ResourcesDirectory, "colors.json"); try { - var filepath = Path.Combine(Options.ResourcesDirectory, "colors.json"); Directory.CreateDirectory(Options.ResourcesDirectory); var json = JsonConvert.SerializeObject(Root, Formatting.Indented, new ColorConverter()); File.WriteAllText(filepath, json, Encoding.UTF8); @@ -293,7 +296,7 @@ public static bool Save() } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Failed to save to '{Path}'", filepath); return false; } diff --git a/Intersect (Core)/Extensions/LogLevelExtensions.cs b/Intersect (Core)/Extensions/LogLevelExtensions.cs deleted file mode 100644 index 06c2666bf7..0000000000 --- a/Intersect (Core)/Extensions/LogLevelExtensions.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace Intersect.Extensions; - - -public static partial class LogLevelExtensions -{ - - public static Logging.LogLevel AsIntersectLogLevel(this Microsoft.Extensions.Logging.LogLevel logLevel) - { - switch (logLevel) - { - case Microsoft.Extensions.Logging.LogLevel.Trace: - return Logging.LogLevel.Diagnostic; - - case Microsoft.Extensions.Logging.LogLevel.Debug: - return Logging.LogLevel.Debug; - - case Microsoft.Extensions.Logging.LogLevel.Information: - return Logging.LogLevel.Info; - - case Microsoft.Extensions.Logging.LogLevel.Warning: - return Logging.LogLevel.Warn; - - case Microsoft.Extensions.Logging.LogLevel.Error: - case Microsoft.Extensions.Logging.LogLevel.Critical: - return Logging.LogLevel.Error; - - case Microsoft.Extensions.Logging.LogLevel.None: - return Logging.LogLevel.None; - - default: - - throw new ArgumentOutOfRangeException(nameof(logLevel), logLevel, null); - } - } - -} diff --git a/Intersect (Core)/Factories/FactoryRegistry.cs b/Intersect (Core)/Factories/FactoryRegistry.cs index 2be85b2de5..263662edba 100644 --- a/Intersect (Core)/Factories/FactoryRegistry.cs +++ b/Intersect (Core)/Factories/FactoryRegistry.cs @@ -1,9 +1,9 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; - -using Intersect.Logging; +using Intersect.Core; +using Intersect.Framework.Reflection; using Intersect.Properties; -using Intersect.Reflection; +using Microsoft.Extensions.Logging; namespace Intersect.Factories; @@ -59,11 +59,15 @@ public static bool TryCreate(out TValue value, params object[] args) } catch (InvalidOperationException exception) { - Log.Warn(exception); + ApplicationContext.Context.Value?.Logger.LogWarning( + exception, + "Failed to create {TypeName}", + typeof(TValue).GetName(qualified: true) + ); } catch (Exception exception) { - Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( exception, string.Format( CultureInfo.CurrentCulture, ExceptionMessages.SwallowingExceptionFromWithQualifiedName, diff --git a/Intersect (Core)/Intersect.Core.csproj b/Intersect (Core)/Intersect.Core.csproj index 43ce3bf743..991d7be542 100644 --- a/Intersect (Core)/Intersect.Core.csproj +++ b/Intersect (Core)/Intersect.Core.csproj @@ -86,7 +86,7 @@ - + diff --git a/Intersect (Core)/Localization/LocaleArgument.cs b/Intersect (Core)/Localization/LocaleArgument.cs index fc04472ee0..a81b57307a 100644 --- a/Intersect (Core)/Localization/LocaleArgument.cs +++ b/Intersect (Core)/Localization/LocaleArgument.cs @@ -1,5 +1,4 @@ using System.ComponentModel; - using Newtonsoft.Json; namespace Intersect.Localization; diff --git a/Intersect (Core)/Localization/LocaleCommandNamespace.cs b/Intersect (Core)/Localization/LocaleCommandNamespace.cs index 8b4dd4e49b..a306f6ef2f 100644 --- a/Intersect (Core)/Localization/LocaleCommandNamespace.cs +++ b/Intersect (Core)/Localization/LocaleCommandNamespace.cs @@ -1,6 +1,5 @@ using System.Collections.Immutable; using System.Reflection; - using Newtonsoft.Json; namespace Intersect.Localization; diff --git a/Intersect (Core)/Logging/Formatting/PrettyFormatter.cs b/Intersect (Core)/Logging/Formatting/PrettyFormatter.cs deleted file mode 100644 index f39712bdc3..0000000000 --- a/Intersect (Core)/Logging/Formatting/PrettyFormatter.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Text; - -namespace Intersect.Logging.Formatting; - -/// -/// Pretty log formatter that does not include timestamps or extended details. -/// -/// -public partial class PrettyFormatter : DefaultFormatter -{ - - /// - protected override StringBuilder FormatPrefix( - LogConfiguration configuration, - LogLevel logLevel, - DateTime dateTime, - StringBuilder builder = null - ) - { - if (builder == null) - { - builder = new StringBuilder(); - } - - // ReSharper disable once InvertIf - if (!string.IsNullOrEmpty(configuration.Tag)) - { - builder.Append(configuration.Tag); - builder.Append(": "); - } - - return builder; - } - -} diff --git a/Intersect (Core)/Logging/Log.cs b/Intersect (Core)/Logging/Log.cs deleted file mode 100644 index e07e74c386..0000000000 --- a/Intersect (Core)/Logging/Log.cs +++ /dev/null @@ -1,239 +0,0 @@ -using System.Collections.Immutable; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using Intersect.Logging.Formatting; -using Intersect.Logging.Output; - -namespace Intersect.Logging; - -public static partial class Log -{ - internal static readonly DateTime Initial = DateTime.Now; - - private static string ExecutableName => - Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName); - - public static string SuggestFilename( - DateTime? time = null, - string prefix = null, - string extensionPrefix = null - ) => - $"{prefix?.Trim() ?? ""}{ExecutableName}-{time ?? Initial:yyyy_MM_dd-HH_mm_ss_fff}{(string.IsNullOrWhiteSpace(extensionPrefix) ? "" : "." + extensionPrefix)}.log"; - - #region Global - - static Log() - { - var outputs = ImmutableList.Create( - new FileOutput(), new FileOutput($"errors-{ExecutableName}.log", LogLevel.Error), - new ConciseConsoleOutput(Debugger.IsAttached ? LogLevel.All : LogLevel.Error) - ) ?? - throw new InvalidOperationException(); - - Pretty = new Logger( - new LogConfiguration - { - Formatters = ImmutableList.Create(new PrettyFormatter()) ?? throw new InvalidOperationException(), - LogLevel = LogConfiguration.Default.LogLevel, - Outputs = outputs - } - ); - - Default = new Logger( - new LogConfiguration - { - Formatters = ImmutableList.Create(new DefaultFormatter()) ?? throw new InvalidOperationException(), - LogLevel = LogConfiguration.Default.LogLevel, - Outputs = outputs, - } - ); - - LegacyLogging.Logger = Default; - } - - public static Logger Pretty { get; internal set; } - - public static Logger Default { get; internal set; } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Write(LogLevel logLevel, string message) - { - Default.Write(logLevel, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Write(LogLevel logLevel, string format, params object[] args) - { - Default.Write(logLevel, format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Write(LogLevel logLevel, Exception exception, string message = null) - { - Default.Write(logLevel, exception); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Write(string message) - { - Default.Write(message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Write(string format, params object[] args) - { - Default.Write(format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Write(Exception exception, string message = null) - { - Default.Write(exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void All(string message) - { - Default.All(message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void All(string format, params object[] args) - { - Default.All(format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void All(Exception exception, string message = null) - { - Default.All(exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Error(string message) - { - Default.Error(message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Error(string format, params object[] args) - { - Default.Error(format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Error(Exception exception, string message = null) - { - Default.Error(exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Warn(string message) - { - Default.Warn(message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Warn(string format, params object[] args) - { - Default.Warn(format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Warn(Exception exception, string message = null) - { - Default.Warn(exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Info(string message) - { - Default.Info(message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Info(string format, params object[] args) - { - Default.Info(format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Info(Exception exception, string message = null) - { - Default.Info(exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Trace(string message) - { - Default.Trace(message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Trace(string format, params object[] args) - { - Default.Trace(format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Trace(Exception exception, string message = null) - { - Default.Trace(exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Debug(string message) - { - Default.Debug(message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Debug(string format, params object[] args) - { - Default.Debug(format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Debug(Exception exception, string message = null) - { - Default.Debug(exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Diagnostic(string message) - { - Default.Diagnostic(message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Diagnostic(string format, params object[] args) - { - Default.Diagnostic(format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Diagnostic(Exception exception, string message = null) - { - Default.Diagnostic(exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Verbose(string message) - { - Default.Verbose(message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Verbose(string format, params object[] args) - { - Default.Verbose(format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void Verbose(Exception exception, string message = null) - { - Default.Verbose(exception, message); - } - - #endregion -} diff --git a/Intersect (Core)/Logging/Logger.cs b/Intersect (Core)/Logging/Logger.cs deleted file mode 100644 index 31ca0bd28a..0000000000 --- a/Intersect (Core)/Logging/Logger.cs +++ /dev/null @@ -1,264 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace Intersect.Logging; - - -public partial class Logger : ILogger -{ - - public Logger() : this(LogConfiguration.Default) { } - - public Logger(string tag = null) : this( - new LogConfiguration {Tag = string.IsNullOrEmpty(tag?.Trim()) ? null : tag} - ) - { - } - - public Logger(LogConfiguration configuration) - { - Configuration = configuration; - } - - public LogConfiguration Configuration { get; set; } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Write(LogLevel logLevel, string message) - { - if (Configuration.LogLevel < logLevel) - { - return; - } - - string trace = null; - if (logLevel == LogLevel.Trace) - { - trace = Environment.StackTrace; - } - - foreach (var output in Configuration.Outputs) - { - output.Write(Configuration, logLevel, message); - if (trace != null) - { - output.Write(Configuration, logLevel, trace); - } - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Write(LogLevel logLevel, string format, params object[] args) - { - if (Configuration.LogLevel < logLevel) - { - return; - } - - string trace = null; - if (logLevel == LogLevel.Trace) - { - trace = Environment.StackTrace; - } - - foreach (var output in Configuration.Outputs) - { - output.Write(Configuration, logLevel, format, args); - if (trace != null) - { - output.Write(Configuration, logLevel, trace); - } - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Write(LogLevel logLevel, Exception exception, string message = null) - { - if (Configuration.LogLevel < logLevel) - { - return; - } - - string trace = null; - if (logLevel == LogLevel.Trace) - { - trace = Environment.StackTrace; - } - - foreach (var output in Configuration.Outputs) - { - output.Write(Configuration, logLevel, exception, message); - if (trace != null) - { - output.Write(Configuration, logLevel, trace); - } - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Write(string message) - { - Write(Configuration.LogLevel, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Write(string format, params object[] args) - { - Write(Configuration.LogLevel, format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Write(Exception exception, string message = null) - { - Write(Configuration.LogLevel, exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void All(string message) - { - Write(LogLevel.All, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void All(string format, params object[] args) - { - Write(LogLevel.All, format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void All(Exception exception, string message = null) - { - Write(LogLevel.All, exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Error(string message) - { - Write(LogLevel.Error, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Error(string format, params object[] args) - { - Write(LogLevel.Error, format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Error(Exception exception, string message = null) - { - Write(LogLevel.Error, exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Warn(string message) - { - Write(LogLevel.Warn, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Warn(string format, params object[] args) - { - Write(LogLevel.Warn, format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Warn(Exception exception, string message = null) - { - Write(LogLevel.Warn, exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Info(string message) - { - Write(LogLevel.Info, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Info(string format, params object[] args) - { - Write(LogLevel.Info, format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Info(Exception exception, string message = null) - { - Write(LogLevel.Info, exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Trace(string message) - { - Write(LogLevel.Trace, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Trace(string format, params object[] args) - { - Write(LogLevel.Trace, format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Trace(Exception exception, string message = null) - { - Write(LogLevel.Trace, exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Debug(string message) - { - Write(LogLevel.Debug, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Debug(string format, params object[] args) - { - Write(LogLevel.Debug, format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Debug(Exception exception, string message = null) - { - Write(LogLevel.Debug, exception, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Diagnostic(string message) - { -#if INTERSECT_DIAGNOSTIC - Write(LogLevel.Diagnostic, message); -#endif - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Diagnostic(string format, params object[] args) - { -#if INTERSECT_DIAGNOSTIC - Write(LogLevel.Diagnostic, format, args); -#endif - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Diagnostic(Exception exception, string message = null) - { -#if INTERSECT_DIAGNOSTIC - Write(LogLevel.Diagnostic, exception, message); -#endif - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Verbose(string message) - { - Write(LogLevel.Verbose, message); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Verbose(string format, params object[] args) - { - Write(LogLevel.Verbose, format, args); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public virtual void Verbose(Exception exception, string message = null) - { - Write(LogLevel.Verbose, exception, message); - } - -} diff --git a/Intersect (Core)/Logging/MemoryDump.cs b/Intersect (Core)/Logging/MemoryDump.cs deleted file mode 100644 index a8d1533b60..0000000000 --- a/Intersect (Core)/Logging/MemoryDump.cs +++ /dev/null @@ -1,95 +0,0 @@ -using System.Text; - -namespace Intersect.Logging; - - -public static partial class MemoryDump -{ - - private static string sDumpDirectory; - - static MemoryDump() - { - DumpDirectory = "logs/dumps"; - } - - public static string DumpDirectory - { - get => Path.Combine(Environment.CurrentDirectory, sDumpDirectory ?? ""); - set => sDumpDirectory = value; - } - - private static void EnsureDirectory() - { - if (!Directory.Exists(DumpDirectory)) - { - Directory.CreateDirectory(DumpDirectory); - } - } - - private static string GetDumpFilename() - { - return Path.Combine(DumpDirectory, $"{DateTime.Now:yyyy_MM_dd-HH_mm_ss_fff}.log"); - } - - public static bool Dump(byte[] data) - { - if (data == null) - { - throw new ArgumentNullException(); - } - - var written = false; - using (var writeStream = new FileStream(GetDumpFilename(), FileMode.CreateNew, FileAccess.Write)) - { - if (data.Length > 0) - { - writeStream.Write(data, 0, data.Length); - written = true; - } - else - { - var bytes = Encoding.UTF8.GetBytes("There was no data to dump."); - writeStream.Write(bytes, 0, bytes.Length); - } - - writeStream.Close(); - } - - return written; - } - - public static bool Dump(Stream stream) - { - if (stream == null) - { - throw new ArgumentNullException(); - } - - var written = false; - using (var writeStream = new FileStream(GetDumpFilename(), FileMode.CreateNew, FileAccess.Write)) - { - if (stream.Length > 0) - { - int read; - var buffer = new byte[4096]; - while (0 < (read = stream.Read(buffer, 0, 4096))) - { - writeStream.Write(buffer, 0, read); - } - - written = true; - } - else - { - var bytes = Encoding.UTF8.GetBytes("There was no data to dump."); - writeStream.Write(bytes, 0, bytes.Length); - } - - writeStream.Close(); - } - - return written; - } - -} diff --git a/Intersect (Core)/Logging/Output/ConciseConsoleOutput.cs b/Intersect (Core)/Logging/Output/ConciseConsoleOutput.cs deleted file mode 100644 index 77760ebf97..0000000000 --- a/Intersect (Core)/Logging/Output/ConciseConsoleOutput.cs +++ /dev/null @@ -1,93 +0,0 @@ -namespace Intersect.Logging.Output; - -// TODO: Figure out what doesn't need to be duplicated between this and ConsoleOutput -public partial class ConciseConsoleOutput : ILogOutput -{ - - public ConciseConsoleOutput(LogLevel logLevel = LogLevel.All) - { - LogLevel = logLevel; - } - - public LogLevel LogLevel { get; set; } - - public void Write(LogConfiguration configuration, LogLevel logLevel, string message) - { - InternalWrite(configuration, logLevel, null, message); - } - - public void Write(LogConfiguration configuration, LogLevel logLevel, string format, params object[] args) - { - InternalWrite(configuration, logLevel, null, format, args); - } - - public void Write(LogConfiguration configuration, LogLevel logLevel, Exception exception, string message) - { - InternalWrite(configuration, logLevel, exception, message); - } - - public void Write( - LogConfiguration configuration, - LogLevel logLevel, - Exception exception, - string format, - params object[] args - ) - { - InternalWrite(configuration, logLevel, exception, format, args); - } - - private void InternalWrite( - LogConfiguration configuration, - LogLevel logLevel, - Exception exception, - string format, - params object[] args - ) - { - if (LogLevel < logLevel) - { - return; - } - - var writer = Console.Out; - if (logLevel < LogLevel.Info) - { - writer = Console.Error; - } - - if (string.IsNullOrEmpty(format)) - { - writer.Write(configuration.Formatter.Format(configuration, logLevel, DateTime.UtcNow, exception, null)); - } - else - { - writer.Write( - configuration.Formatter.Format(configuration, logLevel, DateTime.UtcNow, null, format, args) - ); - - if (exception != null) - { - writer.Write( - configuration.Formatter.Format( - configuration, logLevel, DateTime.UtcNow, null, @"See logs for more information." - ) - ); - } - } - - writer.Flush(); - } - - private static void Flush() - { - Console.Error.Flush(); - Console.Out.Flush(); - } - - public void Close() - { - Flush(); - } - -} diff --git a/Intersect (Core)/Logging/Output/ConsoleOutput.cs b/Intersect (Core)/Logging/Output/ConsoleOutput.cs deleted file mode 100644 index 1e2c12ae45..0000000000 --- a/Intersect (Core)/Logging/Output/ConsoleOutput.cs +++ /dev/null @@ -1,77 +0,0 @@ -namespace Intersect.Logging.Output; - - -public partial class ConsoleOutput : ILogOutput -{ - - public ConsoleOutput(LogLevel logLevel = LogLevel.All) - { - LogLevel = logLevel; - } - - public LogLevel LogLevel { get; set; } - - public void Write(LogConfiguration configuration, LogLevel logLevel, string message) - { - InternalWrite(configuration, logLevel, null, message); - } - - public void Write(LogConfiguration configuration, LogLevel logLevel, string format, params object[] args) - { - InternalWrite(configuration, logLevel, null, format, args); - } - - public void Write(LogConfiguration configuration, LogLevel logLevel, Exception exception, string message) - { - InternalWrite(configuration, logLevel, exception, message); - } - - public void Write( - LogConfiguration configuration, - LogLevel logLevel, - Exception exception, - string format, - params object[] args - ) - { - InternalWrite(configuration, logLevel, exception, format, args); - } - - protected void InternalWrite( - LogConfiguration configuration, - LogLevel logLevel, - Exception exception, - string format, - params object[] args - ) - { - if (LogLevel < logLevel) - { - return; - } - - var writer = Console.Out; - if (LogLevel < LogLevel.Info) - { - writer = Console.Error; - } - - writer.Write( - configuration.Formatter.Format(configuration, logLevel, DateTime.UtcNow, exception, format, args) - ); - - writer.Flush(); - } - - private static void Flush() - { - Console.Error.Flush(); - Console.Out.Flush(); - } - - public void Close() - { - Flush(); - } - -} diff --git a/Intersect (Core)/Logging/Output/FileOutput.cs b/Intersect (Core)/Logging/Output/FileOutput.cs deleted file mode 100644 index a8928f2683..0000000000 --- a/Intersect (Core)/Logging/Output/FileOutput.cs +++ /dev/null @@ -1,189 +0,0 @@ -using System.Text; - -using Intersect.IO.Files; - -namespace Intersect.Logging.Output; - - -public partial class FileOutput : ILogOutput -{ - - private static readonly string Spacer = Environment.NewLine + new string('-', 80) + Environment.NewLine; - - private string mFilename; - - private StreamWriter mWriter; - - public FileOutput(string filename = null, bool append = true) : this(filename, LogLevel.All, append) - { - } - - public FileOutput(string filename, LogLevel logLevel, bool append = true) - { - Filename = string.IsNullOrEmpty(filename) ? Log.SuggestFilename() : filename; - LogLevel = logLevel; - Append = append; - } - - public bool Append { get; set; } - - public string Filename - { - get => mFilename; - set - { - if (string.IsNullOrEmpty(value)) - { - Log.Warn("Cannot set FileOutput to an empty file name."); - - return; - } - - Close(); - - mFilename = value; - } - } - - private StreamWriter Writer - { - get - { - if (mWriter != null) - { - return mWriter; - } - - var directory = Path.GetDirectoryName(mFilename) ?? ""; - directory = Path.Combine("logs", directory); - - if (!FileSystemHelper.EnsureDirectoryExists(directory)) - { - throw new InvalidOperationException("The logger directory could not be created or is a file."); - } - - var filename = Path.GetFileName(mFilename); - - mWriter = new StreamWriter(Path.Combine(directory, filename), Append, Encoding.UTF8) - { - AutoFlush = true - }; - - return mWriter; - } - } - - public LogLevel LogLevel { get; set; } - - public void Write(LogConfiguration configuration, LogLevel logLevel, string message) - { - InternalWrite(configuration, logLevel, null, message); - } - - public void Write(LogConfiguration configuration, LogLevel logLevel, string format, params object[] args) - { - InternalWrite(configuration, logLevel, null, format, args); - } - - public void Write(LogConfiguration configuration, LogLevel logLevel, Exception exception, string message) - { - InternalWrite(configuration, logLevel, exception, message); - } - - public void Write( - LogConfiguration configuration, - LogLevel logLevel, - Exception exception, - string format, - params object[] args - ) - { - InternalWrite(configuration, logLevel, exception, format, args); - } - - private void InternalWrite( - LogConfiguration configuration, - LogLevel logLevel, - Exception exception, - string format, - params object[] args - ) - { - string? line = default; - try - { - if (LogLevel < logLevel) - { - return; - } - - line = configuration.Formatter.Format( - configuration, - logLevel, - DateTime.UtcNow, - exception, - format, - args - ); - - lock (Writer) - { - Writer.Write(line); - Writer.Write(Spacer); - Writer.Flush(); - } - } - catch (Exception exceptionWhileWriting) - { - Console.WriteLine( - "Exception occurred while writing to file:\n\t{0}\n\t{1}", - line, - exceptionWhileWriting - ); - } - } - - ~FileOutput() - { - Close(); - } - - public void Flush() - { - if (mWriter == null) - { - return; - } - - try - { - mWriter.Flush(); - } - catch (ObjectDisposedException) - { - /* Ignore this exception */ - } - } - - public void Close() - { - Flush(); - - if (mWriter == null) - { - return; - } - - try - { - mWriter.Close(); - } - catch (ObjectDisposedException) - { - /* Ignore this exception */ - } - - mWriter = null; - } - -} diff --git a/Intersect (Core)/Network/AbstractConnection.cs b/Intersect (Core)/Network/AbstractConnection.cs index d11fca72e4..78f642d4aa 100644 --- a/Intersect (Core)/Network/AbstractConnection.cs +++ b/Intersect (Core)/Network/AbstractConnection.cs @@ -1,4 +1,5 @@ -using Intersect.Logging; +using Intersect.Core; +using Microsoft.Extensions.Logging; namespace Intersect.Network; @@ -46,19 +47,19 @@ public virtual void HandleConnected() { IsConnected = true; - Log.Debug($"Connection established to remote [{Guid}/{Ip}:{Port}]."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Connection established to remote [{Guid}/{Ip}:{Port}]."); } public void HandleApproved() { - Log.Debug($"Connection approved to remote [{Guid}/{Ip}:{Port}]."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Connection approved to remote [{Guid}/{Ip}:{Port}]."); } public virtual void HandleDisconnected() { IsConnected = false; - Log.Debug($"Connection terminated to remote [{Guid}/{Ip}:{Port}]."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Connection terminated to remote [{Guid}/{Ip}:{Port}]."); } public abstract void Disconnect(string message = default); diff --git a/Intersect (Core)/Network/AbstractNetwork.cs b/Intersect (Core)/Network/AbstractNetwork.cs index a8b82ec6b9..fd24f79cf6 100644 --- a/Intersect (Core)/Network/AbstractNetwork.cs +++ b/Intersect (Core)/Network/AbstractNetwork.cs @@ -1,10 +1,11 @@ using System.Collections.Concurrent; using System.Net; using Intersect.Core; -using Intersect.Logging; +using Intersect.Framework.Reflection; using Intersect.Memory; using Intersect.Plugins.Interfaces; using Intersect.Utilities; +using Microsoft.Extensions.Logging; namespace Intersect.Network; @@ -99,7 +100,7 @@ public void Dispose() if (!Disconnect(NetworkStatus.Quitting.ToString())) { - Log.Error("Error disconnecting while disposing."); + ApplicationContext.Logger.LogError("Error disconnecting while disposing."); } mNetworkLayerInterfaces?.ForEach(networkLayerInterface => networkLayerInterface?.Dispose()); @@ -189,7 +190,7 @@ public IConnection FindConnection(Guid guid) return connection; } - Log.Diagnostic($"Could not find connection {guid}."); + ApplicationContext.Logger.LogTrace($"Could not find connection {guid}."); return null; } @@ -232,9 +233,13 @@ protected bool RunForInterface(Func().Any(action); } - Log.Error(new ArgumentNullException(nameof(action))); - return false; + ApplicationContext.Logger.LogError( + new ArgumentNullException(nameof(action)), + "Failed to run action on {NetworkLayerInterfaceType}", + typeof(TNetworkLayerInterface).GetName(qualified: true) + ); + return false; } private void HandleInboundMessageAvailable(INetworkLayerInterface sender) @@ -246,7 +251,7 @@ private void HandleInboundMessageAvailable(INetworkLayerInterface sender) if (!sender.TryGetInboundBuffer(out var buffer, out var connection)) { - //Log.Error("Failed to obtain packet when told a packet was available."); + //ApplicationContext.Logger.LogError("Failed to obtain packet when told a packet was available."); return; } @@ -304,7 +309,7 @@ private void HandleInboundData(IBuffer buffer, IConnection connection) } else { - Log.Error("Handler == null, this shouldn't happen! Tell JC"); + ApplicationContext.Logger.LogError("Handler == null, this shouldn't happen! Tell JC"); Disconnect(connection, NetworkStatus.Unknown.ToString()); } } diff --git a/Intersect (Core)/Network/AsymmetricEncryptedPacket.cs b/Intersect (Core)/Network/AsymmetricEncryptedPacket.cs index cadf7850e4..1754e5448c 100644 --- a/Intersect (Core)/Network/AsymmetricEncryptedPacket.cs +++ b/Intersect (Core)/Network/AsymmetricEncryptedPacket.cs @@ -1,8 +1,9 @@ using System.Diagnostics.CodeAnalysis; using System.Security.Cryptography; +using Intersect.Core; using Intersect.Framework.Reflection; -using Intersect.Logging; using MessagePack; +using Microsoft.Extensions.Logging; namespace Intersect.Network; @@ -61,11 +62,11 @@ private bool TryDecrypt([NotNullWhen(true)] out IntersectPacket? innerPacket) { using var rsa = RSA.Create(parameters.Value); #if DIAGNOSTIC - Log.Debug($"{nameof(TryDecrypt)} {nameof(encryptedData)}({encryptedData.Length})={Convert.ToHexString(encryptedData)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"{nameof(TryDecrypt)} {nameof(encryptedData)}({encryptedData.Length})={Convert.ToHexString(encryptedData)}"); #endif var innerPacketData = rsa.Decrypt(encryptedData, RSAEncryptionPadding.OaepSHA256); #if DIAGNOSTIC - Log.Debug($"innerPacketData({innerPacketData.Length})={Convert.ToHexString(innerPacketData)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"innerPacketData({innerPacketData.Length})={Convert.ToHexString(innerPacketData)}"); #endif var deserializedObject = MessagePacker.Instance.Deserialize(innerPacketData); innerPacket = deserializedObject as IntersectPacket; @@ -77,18 +78,18 @@ private bool TryDecrypt([NotNullWhen(true)] out IntersectPacket? innerPacket) if (deserializedObject == default) { - Log.Debug("Null packet"); + ApplicationContext.Context.Value?.Logger.LogDebug("Null packet"); return false; } - Log.Debug($"Expected {nameof(InnerPacket)}, received {deserializedObject.GetFullishName()}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Expected {nameof(InnerPacket)}, received {deserializedObject.GetFullishName()}"); } catch (Exception exception) { - Log.Warn(exception); + ApplicationContext.Context.Value?.Logger.LogWarning(exception, "Error decrypting packet"); // #if DIAGNOSTIC - Log.Debug($"{nameof(TryDecrypt)} {nameof(encryptedData)}({encryptedData.Length})={Convert.ToHexString(encryptedData)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"{nameof(TryDecrypt)} {nameof(encryptedData)}({encryptedData.Length})={Convert.ToHexString(encryptedData)}"); // #endif } @@ -111,17 +112,17 @@ private bool TryEncrypt([NotNullWhen(true)] out byte[]? encryptedData) using var rsa = RSA.Create(parameters.Value); var innerPacketData = innerPacket.Data; #if DIAGNOSTIC - Log.Debug($"innerPacketData({innerPacketData.Length})={Convert.ToHexString(innerPacketData)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"innerPacketData({innerPacketData.Length})={Convert.ToHexString(innerPacketData)}"); #endif encryptedData = rsa.Encrypt(innerPacketData, RSAEncryptionPadding.OaepSHA256); #if DIAGNOSTIC - Log.Debug($"encryptedData({encryptedData.Length})={Convert.ToHexString(encryptedData)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"encryptedData({encryptedData.Length})={Convert.ToHexString(encryptedData)}"); #endif return true; } catch (Exception exception) { - Log.Warn(exception); + ApplicationContext.Context.Value?.Logger.LogWarning(exception, "Error encrypting packet"); return false; } } diff --git a/Intersect (Core)/Network/ConnectionPacket.cs b/Intersect (Core)/Network/ConnectionPacket.cs index fef1612c6c..2b9e074a87 100644 --- a/Intersect (Core)/Network/ConnectionPacket.cs +++ b/Intersect (Core)/Network/ConnectionPacket.cs @@ -1,11 +1,10 @@ using System.Security.Cryptography; using Intersect.Network.Packets; using Intersect.Utilities; - using MessagePack; #if INTERSECT_DIAGNOSTIC -using Intersect.Logging; + #endif namespace Intersect.Network; @@ -85,16 +84,16 @@ public long Offset protected static void DumpKey(RSAParameters parameters, bool isPublic) { #if INTERSECT_DIAGNOSTIC - Log.Diagnostic($"Exponent: {BitConverter.ToString(parameters.Exponent)}"); - Log.Diagnostic($"Modulus: {BitConverter.ToString(parameters.Modulus)}"); + ApplicationContext.Context.Value?.Logger.LogTrace($"Exponent: {BitConverter.ToString(parameters.Exponent)}"); + ApplicationContext.Context.Value?.Logger.LogTrace($"Modulus: {BitConverter.ToString(parameters.Modulus)}"); if (isPublic) return; - Log.Diagnostic($"D: {BitConverter.ToString(parameters.D)}"); - Log.Diagnostic($"DP: {BitConverter.ToString(parameters.DP)}"); - Log.Diagnostic($"DQ: {BitConverter.ToString(parameters.DQ)}"); - Log.Diagnostic($"InverseQ: {BitConverter.ToString(parameters.InverseQ)}"); - Log.Diagnostic($"P: {BitConverter.ToString(parameters.P)}"); - Log.Diagnostic($"Q: {BitConverter.ToString(parameters.Q)}"); + ApplicationContext.Context.Value?.Logger.LogTrace($"D: {BitConverter.ToString(parameters.D)}"); + ApplicationContext.Context.Value?.Logger.LogTrace($"DP: {BitConverter.ToString(parameters.DP)}"); + ApplicationContext.Context.Value?.Logger.LogTrace($"DQ: {BitConverter.ToString(parameters.DQ)}"); + ApplicationContext.Context.Value?.Logger.LogTrace($"InverseQ: {BitConverter.ToString(parameters.InverseQ)}"); + ApplicationContext.Context.Value?.Logger.LogTrace($"P: {BitConverter.ToString(parameters.P)}"); + ApplicationContext.Context.Value?.Logger.LogTrace($"Q: {BitConverter.ToString(parameters.Q)}"); #endif } } diff --git a/Intersect (Core)/Network/NetworkThread.cs b/Intersect (Core)/Network/NetworkThread.cs index 92ca9b8d17..d64396ff8f 100644 --- a/Intersect (Core)/Network/NetworkThread.cs +++ b/Intersect (Core)/Network/NetworkThread.cs @@ -1,6 +1,6 @@ using System.Diagnostics; - -using Intersect.Logging; +using Intersect.Core; +using Microsoft.Extensions.Logging; namespace Intersect.Network; @@ -75,10 +75,10 @@ private void Loop() continue; } - //Log.Debug($"Dispatching packet '{packet.GetType().Name}' (size={(packet as BinaryPacket)?.Buffer?.Length() ?? -1})."); + //ApplicationContext.Context.Value?.Logger.LogDebug($"Dispatching packet '{packet.GetType().Name}' (size={(packet as BinaryPacket)?.Buffer?.Length() ?? -1})."); if (!mDispatcher.Dispatch(packet)) { - Log.Warn($"Failed to dispatch packet '{packet}'."); + ApplicationContext.Context.Value?.Logger.LogWarning($"Failed to dispatch packet '{packet}'."); } #if DIAGNOSTIC @@ -96,7 +96,7 @@ private void Loop() sw.Stop(); - Log.Debug($"Exiting network thread ({Name})."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Exiting network thread ({Name})."); } } diff --git a/Intersect (Core)/Network/PacketQueue.cs b/Intersect (Core)/Network/PacketQueue.cs index 073022114a..eda6338d8b 100644 --- a/Intersect (Core)/Network/PacketQueue.cs +++ b/Intersect (Core)/Network/PacketQueue.cs @@ -77,12 +77,12 @@ public bool Enqueue(IPacket packet) throw new ArgumentNullException(); } - //Log.Debug("Waiting on queue lock..."); + //ApplicationContext.Context.Value?.Logger.LogDebug("Waiting on queue lock..."); lock (mQueueLock) { mQueue.Enqueue(packet); - //Log.Debug($"enqueuedSize={mQueue.Count}"); + //ApplicationContext.Context.Value?.Logger.LogDebug($"enqueuedSize={mQueue.Count}"); Monitor.Pulse(mQueueLock); } @@ -106,17 +106,17 @@ public bool TryNext(out IPacket packet) throw new ArgumentNullException(); } - //Log.Debug("Waiting on deque lock..."); + //ApplicationContext.Context.Value?.Logger.LogDebug("Waiting on deque lock..."); lock (mDequeLock) { - //Log.Debug("Waiting on queue lock..."); + //ApplicationContext.Context.Value?.Logger.LogDebug("Waiting on queue lock..."); lock (mQueueLock) { - //Log.Debug("Checking if blocked..."); + //ApplicationContext.Context.Value?.Logger.LogDebug("Checking if blocked..."); if (mQueue.Count < 1) { - //Log.Debug("Blocked... waiting for new packets..."); + //ApplicationContext.Context.Value?.Logger.LogDebug("Blocked... waiting for new packets..."); Monitor.Wait(mQueueLock); } @@ -127,7 +127,7 @@ public bool TryNext(out IPacket packet) return false; } - //Log.Debug($"size={mQueue.Count}"); + //ApplicationContext.Context.Value?.Logger.LogDebug($"size={mQueue.Count}"); packet = mQueue.Dequeue(); if (mQueue.Count > 0) { diff --git a/Intersect (Core)/Network/Packets/ApprovalPacket.cs b/Intersect (Core)/Network/Packets/ApprovalPacket.cs index 65e3214a4e..e0afc8a716 100644 --- a/Intersect (Core)/Network/Packets/ApprovalPacket.cs +++ b/Intersect (Core)/Network/Packets/ApprovalPacket.cs @@ -1,8 +1,9 @@ using System.Diagnostics; using System.Security.Cryptography; -using Intersect.Logging; +using Intersect.Core; using Intersect.Memory; using MessagePack; +using Microsoft.Extensions.Logging; namespace Intersect.Network.Packets; @@ -48,9 +49,9 @@ public override bool Encrypt() using (var buffer = new MemoryBuffer()) { #if INTERSECT_DIAGNOSTIC - Log.Debug($"Handshake secret: {BitConverter.ToString(HandshakeSecret)}."); - Log.Debug($"Specified AES Key: {BitConverter.ToString(AesKey)}"); - Log.Debug($"Assigning UUID: {Guid})."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Handshake secret: {BitConverter.ToString(HandshakeSecret)}."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Specified AES Key: {BitConverter.ToString(AesKey)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Assigning UUID: {Guid})."); #endif buffer.Write(HandshakeSecret, SIZE_HANDSHAKE_SECRET); buffer.Write(AesKey, SIZE_AES_KEY); @@ -65,7 +66,7 @@ public override bool Encrypt() EncryptedData = mRsa.Encrypt(buffer.ToArray(), RSAEncryptionPadding.OaepSHA256) ?? throw new InvalidOperationException("Failed to encrypt the buffer."); #if DIAGNOSTIC - Log.Debug($"ApprovalPacket.Encrypt() [{mRsa.KeySize}] EncryptedData({EncryptedData.Length})={Convert.ToHexString(EncryptedData)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"ApprovalPacket.Encrypt() [{mRsa.KeySize}] EncryptedData({EncryptedData.Length})={Convert.ToHexString(EncryptedData)}"); #endif return true; } @@ -83,7 +84,7 @@ public override bool Decrypt(RSA rsa) try { #if DIAGNOSTIC - Log.Debug( + ApplicationContext.Context.Value?.Logger.LogDebug( $"ApprovalPacket.Decrypt() [{rsa.KeySize}] EncryptedData({EncryptedData.Length})={Convert.ToHexString(EncryptedData)}" ); #endif @@ -125,9 +126,9 @@ public override bool Decrypt(RSA rsa) #endif #if INTERSECT_DIAGNOSTIC - Log.Debug($"Handshake secret: {BitConverter.ToString(HandshakeSecret)}."); - Log.Debug($"Assigned AES Key: {BitConverter.ToString(AesKey)}"); - Log.Debug($"Assigned UUID: {Guid})."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Handshake secret: {BitConverter.ToString(HandshakeSecret)}."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Assigned AES Key: {BitConverter.ToString(AesKey)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Assigned UUID: {Guid})."); #endif return true; @@ -135,7 +136,7 @@ public override bool Decrypt(RSA rsa) } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error decrypting approval packet"); return false; } } diff --git a/Intersect (Core)/Network/Packets/HailPacket.cs b/Intersect (Core)/Network/Packets/HailPacket.cs index f7a880b8a5..8abe222a41 100644 --- a/Intersect (Core)/Network/Packets/HailPacket.cs +++ b/Intersect (Core)/Network/Packets/HailPacket.cs @@ -1,12 +1,12 @@ using System.Diagnostics; using System.Security.Cryptography; - -using Intersect.Logging; +using Intersect.Core; using Intersect.Memory; using MessagePack; +using Microsoft.Extensions.Logging; #if INTERSECT_DIAGNOSTIC -using Intersect.Logging; + #endif namespace Intersect.Network.Packets; @@ -75,8 +75,8 @@ public override bool Encrypt() #endif #if INTERSECT_DIAGNOSTIC - Log.Debug($"VersionData: {BitConverter.ToString(VersionData)}"); - Log.Debug($"Handshake secret: {BitConverter.ToString(HandshakeSecret)}."); + ApplicationContext.Context.Value?.Logger.LogDebug($"VersionData: {BitConverter.ToString(VersionData)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Handshake secret: {BitConverter.ToString(HandshakeSecret)}."); #endif Debug.Assert(RsaParameters.Modulus != null, "RsaParameters.Modulus != null"); @@ -141,8 +141,8 @@ public override bool Decrypt(RSA rsa) #endif #if INTERSECT_DIAGNOSTIC - Log.Debug($"VersionData: {BitConverter.ToString(VersionData)}"); - Log.Debug($"Handshake secret: {BitConverter.ToString(HandshakeSecret)}."); + ApplicationContext.Context.Value?.Logger.LogDebug($"VersionData: {BitConverter.ToString(VersionData)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Handshake secret: {BitConverter.ToString(HandshakeSecret)}."); #endif if (!buffer.Read(out ushort bits)) @@ -175,7 +175,7 @@ public override bool Decrypt(RSA rsa) } catch (Exception exception) { - Log.Warn(exception); + ApplicationContext.Context.Value?.Logger.LogWarning(exception, "Error decrypting hail packet"); return false; } } diff --git a/Intersect (Core)/Plugins/Contexts/PluginBootstrapContext.cs b/Intersect (Core)/Plugins/Contexts/PluginBootstrapContext.cs index d3ea2f257b..0458e48564 100644 --- a/Intersect (Core)/Plugins/Contexts/PluginBootstrapContext.cs +++ b/Intersect (Core)/Plugins/Contexts/PluginBootstrapContext.cs @@ -1,5 +1,4 @@ using CommandLine; - using Intersect.Factories; using Intersect.Plugins.Helpers; using Intersect.Plugins.Interfaces; diff --git a/Intersect (Core)/Plugins/Contexts/PluginContext.cs b/Intersect (Core)/Plugins/Contexts/PluginContext.cs index 60698d7b47..5dfd53dc3c 100644 --- a/Intersect (Core)/Plugins/Contexts/PluginContext.cs +++ b/Intersect (Core)/Plugins/Contexts/PluginContext.cs @@ -1,5 +1,4 @@ using System.Reflection; - using Intersect.Plugins.Helpers; using Intersect.Plugins.Interfaces; diff --git a/Intersect (Core)/Plugins/Helpers/CommandLineHelper.cs b/Intersect (Core)/Plugins/Helpers/CommandLineHelper.cs index 8ed8a34fb2..43dabf10e6 100644 --- a/Intersect (Core)/Plugins/Helpers/CommandLineHelper.cs +++ b/Intersect (Core)/Plugins/Helpers/CommandLineHelper.cs @@ -1,7 +1,7 @@ using CommandLine; - -using Intersect.Logging; +using Intersect.Framework.Reflection; using Intersect.Plugins.Interfaces; +using Microsoft.Extensions.Logging; namespace Intersect.Plugins.Helpers; @@ -40,11 +40,19 @@ private TArguments HandleErrors(IEnumerable errors) if (fatalParsingError) { - Logger.Error(exception); + Logger.LogCritical( + exception, + "Failed to parse {ArgumentsType}", + typeof(TArguments).GetName(qualified: true) + ); } else { - Logger.Warn(exception); + Logger.LogWarning( + exception, + "Failed to parse {ArgumentsType}", + typeof(TArguments).GetName(qualified: true) + ); } return default; diff --git a/Intersect (Core)/Plugins/Helpers/LoggingHelper.cs b/Intersect (Core)/Plugins/Helpers/LoggingHelper.cs index 31c87bcf9d..ea19bc2dad 100644 --- a/Intersect (Core)/Plugins/Helpers/LoggingHelper.cs +++ b/Intersect (Core)/Plugins/Helpers/LoggingHelper.cs @@ -1,8 +1,10 @@ -using Intersect.Logging; -using Intersect.Logging.Output; -using Intersect.Plugins.Interfaces; -using System.Collections.Immutable; +using Intersect.Plugins.Interfaces; using System.Diagnostics; +using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Core; +using Serilog.Extensions.Logging; +using ILogger = Microsoft.Extensions.Logging.ILogger; namespace Intersect.Plugins.Helpers; @@ -10,7 +12,7 @@ namespace Intersect.Plugins.Helpers; internal sealed partial class LoggingHelper : ILoggingHelper { private static readonly string BasePluginLogPath = Path.Combine( - "plugins", $"{Log.Initial:yyyy_MM_dd-HH_mm_ss_fff}" + "plugins", $"{Process.GetCurrentProcess().StartTime:yyyy_MM_dd-HH_mm_ss_fff}" ); private static Logger CreateLogger(IManifestHelper manifest, CreateLoggerOptions createLoggerOptions) @@ -19,30 +21,25 @@ private static Logger CreateLogger(IManifestHelper manifest, CreateLoggerOptions ? manifest.Key : $"{manifest.Key}.{createLoggerOptions.Name}"; - var outputs = new List(); + var loggerConfiguration = new LoggerConfiguration().Enrich.FromLogContext(); if (createLoggerOptions.File > LogLevel.None) { - outputs.Add( - new FileOutput(Path.Combine(BasePluginLogPath, $"{logName}.log"), createLoggerOptions.File) + var pluginLogPath = Path.Combine(BasePluginLogPath, $"{logName}.log"); + loggerConfiguration = loggerConfiguration.WriteTo.File( + path: pluginLogPath, + restrictedToMinimumLevel: LevelConvert.ToSerilogLevel(createLoggerOptions.File) ); } if (createLoggerOptions.Console > LogLevel.None) { - outputs.Add(new ConciseConsoleOutput(createLoggerOptions.Console)); + loggerConfiguration = loggerConfiguration.WriteTo.Console( + restrictedToMinimumLevel: LevelConvert.ToSerilogLevel(createLoggerOptions.File) + ); } - var immutableOutputs = outputs.ToImmutableList(); - Debug.Assert(immutableOutputs != null, $"{nameof(immutableOutputs)} != null"); - - return new Logger( - new LogConfiguration - { - LogLevel = LogConfiguration.Default.LogLevel, - Outputs = immutableOutputs - } - ); + return loggerConfiguration.CreateLogger(); } private readonly IManifestHelper mManifest; @@ -58,15 +55,20 @@ internal LoggingHelper(ILogger applicationLogger, IManifestHelper manifest) Application = applicationLogger; Plugin = CreateLogger( - manifest, new CreateLoggerOptions + new CreateLoggerOptions { - Console = Debugger.IsAttached ? LogLevel.Debug : LogLevel.None, - File = LogLevel.Info + Console = Debugger.IsAttached ? LogLevel.Debug : LogLevel.None, File = LogLevel.Information, } ); } /// public ILogger CreateLogger(CreateLoggerOptions createLoggerOptions) => - CreateLogger(mManifest, createLoggerOptions); + new SerilogLoggerFactory(CreateLogger(mManifest, createLoggerOptions)).CreateLogger( + createLoggerOptions.ContextType + ); + + /// + public ILogger CreateLogger(CreateLoggerOptions createLoggerOptions) => + new SerilogLoggerFactory(CreateLogger(mManifest, createLoggerOptions)).CreateLogger(); } diff --git a/Intersect (Core)/Plugins/Loaders/ManifestLoader.cs b/Intersect (Core)/Plugins/Loaders/ManifestLoader.cs index dd59632b3a..aa9df28140 100644 --- a/Intersect (Core)/Plugins/Loaders/ManifestLoader.cs +++ b/Intersect (Core)/Plugins/Loaders/ManifestLoader.cs @@ -1,11 +1,12 @@ -using Intersect.Logging; + using Intersect.Plugins.Interfaces; using Intersect.Plugins.Manifests; - using Newtonsoft.Json; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Reflection; +using Intersect.Core; +using Microsoft.Extensions.Logging; namespace Intersect.Plugins.Loaders; @@ -66,7 +67,7 @@ public static IManifestHelper FindManifest(Assembly assembly) } catch (Exception exception) { - Log.Error(exception, "Exception thrown by manifest loader delegate."); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Exception thrown by manifest loader delegate."); } return default; @@ -132,14 +133,14 @@ internal static bool IsVirtualManifestType(Type type) if (mismatchedType != null) { - Log.Debug($"Expected: {ManifestType.AssemblyQualifiedName} in {ManifestType.Assembly.Location}"); - Log.Debug($"Loaded: {mismatchedType.AssemblyQualifiedName} in {mismatchedType.Assembly.Location}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Expected: {ManifestType.AssemblyQualifiedName} in {ManifestType.Assembly.Location}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Loaded: {mismatchedType.AssemblyQualifiedName} in {mismatchedType.Assembly.Location}"); if (!string.Equals( ManifestType.Assembly.Location, mismatchedType.Assembly.Location, StringComparison.Ordinal )) { - Log.Warn( + ApplicationContext.Context.Value?.Logger.LogWarning( $"Manifest loaded the core library from the wrong location." + $"\n\tExpected: {ManifestType.Assembly.Location}" + $"\n\t Actual: {mismatchedType.Assembly.Location}" @@ -161,7 +162,7 @@ internal static bool IsVirtualManifestType(Type type) return true; } - Log.Debug($"'{type.Name}' is missing a default constructor."); + ApplicationContext.Context.Value?.Logger.LogDebug($"'{type.Name}' is missing a default constructor."); return false; } diff --git a/Intersect (Core)/Plugins/Loaders/MissingPluginEntryException.cs b/Intersect (Core)/Plugins/Loaders/MissingPluginEntryException.cs index 871691911d..246fddb196 100644 --- a/Intersect (Core)/Plugins/Loaders/MissingPluginEntryException.cs +++ b/Intersect (Core)/Plugins/Loaders/MissingPluginEntryException.cs @@ -1,9 +1,7 @@ using System.Reflection; using System.Runtime.Serialization; - using Intersect.Extensions; using Intersect.Properties; - using Microsoft; namespace Intersect.Plugins.Loaders; diff --git a/Intersect (Core)/Plugins/Loaders/PluginLoader.Assembly.cs b/Intersect (Core)/Plugins/Loaders/PluginLoader.Assembly.cs index 780a4df6b3..b4a4737146 100644 --- a/Intersect (Core)/Plugins/Loaders/PluginLoader.Assembly.cs +++ b/Intersect (Core)/Plugins/Loaders/PluginLoader.Assembly.cs @@ -2,6 +2,7 @@ using Intersect.Properties; using System.Diagnostics.CodeAnalysis; using System.Reflection; +using Microsoft.Extensions.Logging; namespace Intersect.Plugins.Loaders; @@ -30,7 +31,7 @@ internal Plugin LoadFrom(IApplicationContext applicationContext, string assembly } catch (Exception exception) { - applicationContext.Logger.Error(exception); + applicationContext.Logger.LogError(exception, "Error loading plugin from {AssemblyPath}", assemblyPath); return default; } } @@ -46,11 +47,11 @@ internal Plugin LoadFrom(IApplicationContext applicationContext, Assembly assemb var manifest = ManifestLoader.FindManifest(assembly); if (manifest == null) { - applicationContext.Logger.Warn($"Unable to find a manifest in '{assembly.FullName}' ({assembly.Location})"); + applicationContext.Logger.LogWarning($"Unable to find a manifest in '{assembly.FullName}' ({assembly.Location})"); return default; } - applicationContext.Logger.Info($"Loading plugin {manifest.Name} v{manifest.Version} ({manifest.Key})."); + applicationContext.Logger.LogInformation($"Loading plugin {manifest.Name} v{manifest.Version} ({manifest.Key})."); var pluginReference = CreatePluginReference(assembly); if (pluginReference != null) @@ -58,7 +59,7 @@ internal Plugin LoadFrom(IApplicationContext applicationContext, Assembly assemb return Plugin.Create(applicationContext, manifest, pluginReference); } - applicationContext.Logger.Error($"Unable to find a plugin entry point in '{assembly.FullName}' ({assembly.Location})"); + applicationContext.Logger.LogError($"Unable to find a plugin entry point in '{assembly.FullName}' ({assembly.Location})"); return default; } } diff --git a/Intersect (Core)/Plugins/Loaders/PluginLoader.Configuration.cs b/Intersect (Core)/Plugins/Loaders/PluginLoader.Configuration.cs index 4d8b29e50e..3a5c585eb4 100644 --- a/Intersect (Core)/Plugins/Loaders/PluginLoader.Configuration.cs +++ b/Intersect (Core)/Plugins/Loaders/PluginLoader.Configuration.cs @@ -1,9 +1,9 @@ using Intersect.Core; - using Newtonsoft.Json; using System.Diagnostics.CodeAnalysis; using System.Text; using Intersect.Framework.Core.Serialization; +using Microsoft.Extensions.Logging; namespace Intersect.Plugins.Loaders; @@ -67,7 +67,7 @@ Plugin plugin } catch (Exception exception) { - applicationContext.Logger.Warn( + applicationContext.Logger.LogWarning( exception, $"Failed to load plugin configuration from '{configurationFilePath}', using default values." ); @@ -93,7 +93,7 @@ Plugin plugin } catch (Exception exception) { - applicationContext.Logger.Warn( + applicationContext.Logger.LogWarning( exception, $"Failed to backup existing configuration from {configurationFilePath} to {backupConfigurationFilePath}" ); @@ -103,7 +103,7 @@ Plugin plugin } catch (Exception exception) { - applicationContext.Logger.Warn( + applicationContext.Logger.LogWarning( exception, $"Failed to save plugin configuration to '{configurationFilePath}'." ); } diff --git a/Intersect (Core)/Plugins/Loaders/PluginLoader.Discovery.cs b/Intersect (Core)/Plugins/Loaders/PluginLoader.Discovery.cs index ef87ae345e..128f3b8666 100644 --- a/Intersect (Core)/Plugins/Loaders/PluginLoader.Discovery.cs +++ b/Intersect (Core)/Plugins/Loaders/PluginLoader.Discovery.cs @@ -1,5 +1,6 @@ using Intersect.Core; using System.Diagnostics; +using Microsoft.Extensions.Logging; namespace Intersect.Plugins.Loaders; @@ -38,7 +39,7 @@ IEnumerable pluginDirectories var key = discoveredPlugin.Manifest.Key; if (!plugins.TryGetValue(discoveredPlugin.Manifest.Key, out var existingPlugin) || existingPlugin == default || - existingPlugin.Manifest.Version < discoveredPlugin.Manifest.Version) + existingPlugin.Manifest.Version.ComparePrecedenceTo(discoveredPlugin.Manifest.Version) < 0) { plugins[key] = discoveredPlugin; } @@ -79,7 +80,7 @@ string pluginDirectory .Where(plugin => plugin != default); } - applicationContext.Logger.Warn( + applicationContext.Logger.LogWarning( $@"Directory was specified as a plugin directory but does not exist: '{pluginDirectory}'" ); diff --git a/Intersect (Core)/Plugins/PluginHelper.cs b/Intersect (Core)/Plugins/PluginHelper.cs index 5199a4be4f..850674d625 100644 --- a/Intersect (Core)/Plugins/PluginHelper.cs +++ b/Intersect (Core)/Plugins/PluginHelper.cs @@ -1,4 +1,6 @@ -using Intersect.Logging; + + +using Microsoft.Extensions.Logging; namespace Intersect.Plugins; diff --git a/Intersect (Core)/Plugins/PluginInstance.cs b/Intersect (Core)/Plugins/PluginInstance.cs index b04f3727f6..f77cf7571d 100644 --- a/Intersect (Core)/Plugins/PluginInstance.cs +++ b/Intersect (Core)/Plugins/PluginInstance.cs @@ -1,6 +1,5 @@  using Intersect.Factories; - using Microsoft; namespace Intersect.Plugins; diff --git a/Intersect (Core)/Plugins/PluginService.cs b/Intersect (Core)/Plugins/PluginService.cs index 4158fc2666..faed5d0cc3 100644 --- a/Intersect (Core)/Plugins/PluginService.cs +++ b/Intersect (Core)/Plugins/PluginService.cs @@ -4,6 +4,7 @@ using System.Collections.Concurrent; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using Microsoft.Extensions.Logging; namespace Intersect.Plugins; @@ -72,7 +73,7 @@ public override bool Bootstrap(IApplicationContext applicationContext) // Discover plugins var discoveredPlugins = Loader.DiscoverPlugins(applicationContext, PluginDirectories); - applicationContext.Logger.Info( + applicationContext.Logger.LogInformation( $"Discovered {discoveredPlugins.Count} plugins:\n{string.Join("\n", discoveredPlugins.Select(plugin => plugin.Key))}" ); @@ -201,7 +202,7 @@ Action> action // applicationContext.Strings.Errors.PluginLifecycleFailed.ToString(lifecycleState) // ); - applicationContext.Logger.Error( + applicationContext.Logger.LogError( exception, $"Failed to invoke {action.Method?.Name} for {pair.Key.Key}." ); } diff --git a/Intersect (Core)/Threading/ConcurrentInstance.cs b/Intersect (Core)/Threading/ConcurrentInstance.cs index 73e8e9dcf2..20b0c7a079 100644 --- a/Intersect (Core)/Threading/ConcurrentInstance.cs +++ b/Intersect (Core)/Threading/ConcurrentInstance.cs @@ -1,6 +1,6 @@ using System.Diagnostics; - -using Intersect.Logging; +using Intersect.Core; +using Microsoft.Extensions.Logging; namespace Intersect.Threading; @@ -25,24 +25,24 @@ public void ClearWith(TInstance instance, Action action) { var stopwatch = new Stopwatch(); stopwatch.Start(); - Log.Info($@"Acquiring context lock... ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation($@"Acquiring context lock... ({stopwatch.ElapsedMilliseconds}ms)"); Acquire(); - Log.Info($@"Acquired. ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation($@"Acquired. ({stopwatch.ElapsedMilliseconds}ms)"); if (mInstance != instance) { - Log.Info($@"Exiting lock... ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation($@"Exiting lock... ({stopwatch.ElapsedMilliseconds}ms)"); Monitor.Exit(mLock); } action.Invoke(); - Log.Info($@"Clearing instance... ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation($@"Clearing instance... ({stopwatch.ElapsedMilliseconds}ms)"); Clear(instance); - Log.Info($@"Releasing context lock... ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation($@"Releasing context lock... ({stopwatch.ElapsedMilliseconds}ms)"); Release(); - Log.Info($@"Released. ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation($@"Released. ({stopwatch.ElapsedMilliseconds}ms)"); } public void Acquire() diff --git a/Intersect (Core)/Updater/Updater.cs b/Intersect (Core)/Updater/Updater.cs index d481850b66..870894078f 100644 --- a/Intersect (Core)/Updater/Updater.cs +++ b/Intersect (Core)/Updater/Updater.cs @@ -3,11 +3,10 @@ using System.Reflection; using System.Security.Cryptography; using System.Text; - using Intersect.Configuration; +using Intersect.Core; using Intersect.Framework.Core.Serialization; -using Intersect.Logging; - +using Microsoft.Extensions.Logging; using Newtonsoft.Json; namespace Intersect.Updater; @@ -443,7 +442,7 @@ private async Task StreamDownloads() catch (Exception ex) { //Errored - Log.Error("Failed to download streamed files, failure occured on "); + ApplicationContext.Context.Value?.Logger.LogError("Failed to download streamed files, failure occured on "); return false; } } diff --git a/Intersect (Core)/Utilities/AlphanumComparator.cs b/Intersect (Core)/Utilities/AlphanumComparator.cs index 640566ae85..03d9af0a07 100644 --- a/Intersect (Core)/Utilities/AlphanumComparator.cs +++ b/Intersect (Core)/Utilities/AlphanumComparator.cs @@ -33,7 +33,6 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. * */ - using System.Collections; using System.Text; diff --git a/Intersect (Core)/Utilities/Formula.cs b/Intersect (Core)/Utilities/Formula.cs index ebb813b1e1..e6a8f5f2d3 100644 --- a/Intersect (Core)/Utilities/Formula.cs +++ b/Intersect (Core)/Utilities/Formula.cs @@ -1,5 +1,5 @@ -using Intersect.Logging; - +using Intersect.Core; +using Microsoft.Extensions.Logging; using NCalc; namespace Intersect.Utilities; @@ -76,11 +76,11 @@ public string Source if (!Load()) { - Log.Warn($"Error loading formula from {mSource}."); + ApplicationContext.Context.Value?.Logger.LogWarning($"Error loading formula from {mSource}."); } else { - Log.Debug($"Loaded new formula from {mSource}."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Loaded new formula from {mSource}."); } } } @@ -109,14 +109,14 @@ public bool Load() if (!Parameters.TryGetValue(name, out var formulaParameter)) { - Log.Error($"Tried to access non-existent parameter '{name}' in a formula."); + ApplicationContext.Context.Value?.Logger.LogError($"Tried to access non-existent parameter '{name}' in a formula."); return; } if (args == null) { - Log.Error($"Formula parameter '{name}' arguments were null."); + ApplicationContext.Context.Value?.Logger.LogError($"Formula parameter '{name}' arguments were null."); return; } @@ -137,7 +137,7 @@ public bool Load() { if (!SYSTEM_MATH_FUNCTIONS.Contains(name)) { - Log.Error($"Tried to access non-existent function '{name}' in a formula."); + ApplicationContext.Context.Value?.Logger.LogError($"Tried to access non-existent function '{name}' in a formula."); } return; @@ -145,7 +145,7 @@ public bool Load() if (args == null) { - Log.Error($"Formula function '{name}' arguments were null."); + ApplicationContext.Context.Value?.Logger.LogError($"Formula function '{name}' arguments were null."); return; } @@ -168,7 +168,7 @@ public bool RegisterFunction(string name, FormulaFunction function, bool shouldO { if (!shouldOverride) { - Log.Debug($"Formula function '{name}' already exists, not overriding."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Formula function '{name}' already exists, not overriding."); return false; } @@ -200,7 +200,7 @@ public bool RegisterParameter(string name, object value, bool shouldOverride = f { if (!shouldOverride) { - Log.Debug($"Formula parameter '{name}' already exists, not overriding."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Formula parameter '{name}' already exists, not overriding."); return false; } @@ -217,7 +217,7 @@ public bool RegisterEvaluatedParameter(string name, object value, bool shouldOve { if (!shouldOverride) { - Log.Debug($"Formula evaluated parameter '{name}' already exists,not overriding."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Formula evaluated parameter '{name}' already exists,not overriding."); return false; } @@ -228,7 +228,7 @@ public bool RegisterEvaluatedParameter(string name, object value, bool shouldOve { if (args == null) { - Log.Error($"Formula function '{name}' arguments were null."); + ApplicationContext.Context.Value?.Logger.LogError($"Formula function '{name}' arguments were null."); return; } diff --git a/Intersect (Core)/Utilities/GameObjectTypeUtils.cs b/Intersect (Core)/Utilities/GameObjectTypeUtils.cs index 2516484352..bc5ae66480 100644 --- a/Intersect (Core)/Utilities/GameObjectTypeUtils.cs +++ b/Intersect (Core)/Utilities/GameObjectTypeUtils.cs @@ -1,5 +1,4 @@ using System.Data; - using Intersect.Enums; namespace Intersect.Utilities; diff --git a/Intersect (Core)/Utilities/Retry.cs b/Intersect (Core)/Utilities/Retry.cs index ae5d3dae3c..d5ec7c1b14 100644 --- a/Intersect (Core)/Utilities/Retry.cs +++ b/Intersect (Core)/Utilities/Retry.cs @@ -1,4 +1,5 @@ -using Intersect.Logging; +using Intersect.Core; +using Microsoft.Extensions.Logging; namespace Intersect.Utilities; @@ -8,9 +9,12 @@ public static partial class Retry public delegate bool TryParameterlessAction(out TResult result); - private static void DumpExceptions(List exceptions) + private static void DumpExceptions(List exceptions, string message) { - exceptions?.ForEach(exception => Log.Error(exception)); + foreach (var exception in exceptions) + { + ApplicationContext.Context.Value?.Logger.LogError(exception, message); + } } public static TResult Execute( @@ -28,7 +32,7 @@ public static TResult Execute( if (retryInterval.TotalMilliseconds < 2000) { - Log.Warn("You should probably not be using Retry if you need such short intervals."); + ApplicationContext.Context.Value?.Logger.LogWarning("You should probably not be using Retry if you need such short intervals."); } if (action == null) @@ -60,7 +64,7 @@ public static TResult Execute( caughtExceptions.Add(exception); if (++consecutiveExceptions >= consecutiveFailuresUntilAbort) { - DumpExceptions(caughtExceptions); + DumpExceptions(caughtExceptions, "Failed too many times consecutively, aborting."); throw new OperationCanceledException("Failed too many times consecutively, aborting."); } @@ -77,7 +81,7 @@ public static TResult Execute( return result; } - DumpExceptions(caughtExceptions); + DumpExceptions(caughtExceptions, "Bad Retry state!"); throw caughtExceptions.FindLast(e => true) ?? new InvalidOperationException("Bad Retry state!"); } diff --git a/Intersect.Client.Core/Core/Audio.cs b/Intersect.Client.Core/Core/Audio.cs index f4cb8f16d0..96097cfb66 100644 --- a/Intersect.Client.Core/Core/Audio.cs +++ b/Intersect.Client.Core/Core/Audio.cs @@ -4,8 +4,9 @@ using Intersect.Client.Framework.Entities; using Intersect.Client.Framework.File_Management; using Intersect.Client.General; -using Intersect.Logging; +using Intersect.Core; using Intersect.Utilities; +using Microsoft.Extensions.Logging; namespace Intersect.Client.Core; @@ -182,7 +183,7 @@ private static void StartMusic(string filename, int fadein = 0, bool loop = fals if (sMyMusic != null) { - Log.Warn($"Trying to start '{filename}' without properly closing '{sCurrentSong}'."); + ApplicationContext.Context.Value?.Logger.LogTrace($"Trying to start '{filename}' without properly closing '{sCurrentSong}'."); } sMyMusic = music.CreateInstance(); diff --git a/Intersect.Client.Core/Core/Bootstrapper.cs b/Intersect.Client.Core/Core/Bootstrapper.cs index 9facb1d71e..c2454cd171 100644 --- a/Intersect.Client.Core/Core/Bootstrapper.cs +++ b/Intersect.Client.Core/Core/Bootstrapper.cs @@ -1,18 +1,21 @@ +using System.Diagnostics; +using System.Reflection; using CommandLine; - +using Intersect.Core; using Intersect.Factories; -using Intersect.Logging; using Intersect.Network; using Intersect.Plugins; using Intersect.Plugins.Contexts; using Intersect.Plugins.Helpers; +using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Events; +using Serilog.Extensions.Logging; namespace Intersect.Client.Core; internal static partial class Bootstrapper { - public static ClientContext? Context { get; private set; } - public static void Start(params string[] args) { var parser = new Parser( @@ -31,11 +34,30 @@ public static void Start(params string[] args) } ); - var logger = Log.Default; + var commandLineOptions = parser.ParseArguments(args) + .MapResult(HandleParsedArguments, HandleParserErrors); + + var executableName = Path.GetFileNameWithoutExtension( + Process.GetCurrentProcess().MainModule?.FileName ?? Assembly.GetExecutingAssembly().GetName().Name + ); + var loggerConfiguration = new LoggerConfiguration().MinimumLevel + .Is(Debugger.IsAttached ? LogEventLevel.Debug : LogEventLevel.Information).Enrich.FromLogContext().WriteTo + .Console().WriteTo.File( + Path.Combine( + "logs", + $"{executableName}-{Process.GetCurrentProcess().StartTime:yyyy_MM_dd-HH_mm_ss_fff}.log" + ) + ).WriteTo.File( + Path.Combine("logs", $"errors-{executableName}.log"), + restrictedToMinimumLevel: LogEventLevel.Error + ); + + var logger = new SerilogLoggerFactory(loggerConfiguration.CreateLogger()).CreateLogger("Client"); + var packetTypeRegistry = new PacketTypeRegistry(logger, typeof(SharedConstants).Assembly); if (!packetTypeRegistry.TryRegisterBuiltIn()) { - logger.Error("Failed to register built-in packets."); + logger.LogError("Failed to register built-in packets."); return; } @@ -43,9 +65,6 @@ public static void Start(params string[] args) var packetHelper = new PacketHelper(packetTypeRegistry, packetHandlerRegistry); _ = FactoryRegistry.RegisterFactory(PluginBootstrapContext.CreateFactory(args, parser, packetHelper)); - var commandLineOptions = parser.ParseArguments(args) - .MapResult(HandleParsedArguments, HandleParserErrors); - if (!string.IsNullOrWhiteSpace(commandLineOptions.WorkingDirectory)) { var workingDirectory = commandLineOptions.WorkingDirectory.Trim(); @@ -56,12 +75,13 @@ public static void Start(params string[] args) } else { - Log.Warn($"Failed to set working directory to '{workingDirectory}', path does not exist: {resolvedWorkingDirectory}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Failed to set working directory to '{workingDirectory}', path does not exist: {resolvedWorkingDirectory}"); } } - Context = new ClientContext(commandLineOptions, logger, packetHelper); - Context.Start(); + var context = new ClientContext(commandLineOptions, logger, packetHelper); + ApplicationContext.Context.Value = context; + context.Start(); } private static ClientCommandLineOptions HandleParsedArguments(ClientCommandLineOptions clientCommandLineOptions) => @@ -79,11 +99,17 @@ private static ClientCommandLineOptions HandleParserErrors(IEnumerable er if (fatalParsingError) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogCritical( + exception, + "Critical error during command line argument parsing" + ); } else { - Log.Warn(exception); + ApplicationContext.Context.Value?.Logger.LogWarning( + exception, + "Error occurred during command line argument parsing" + ); } return default; diff --git a/Intersect.Client.Core/Core/ClientCommandLineOptions.cs b/Intersect.Client.Core/Core/ClientCommandLineOptions.cs index fd74a34dfc..9cf6a1d20c 100644 --- a/Intersect.Client.Core/Core/ClientCommandLineOptions.cs +++ b/Intersect.Client.Core/Core/ClientCommandLineOptions.cs @@ -1,5 +1,4 @@ using CommandLine; - using Intersect.Client.Framework.Graphics; using Intersect.Core; diff --git a/Intersect.Client.Core/Core/ClientContext.cs b/Intersect.Client.Core/Core/ClientContext.cs index 36ea056c56..903e4cfe4b 100644 --- a/Intersect.Client.Core/Core/ClientContext.cs +++ b/Intersect.Client.Core/Core/ClientContext.cs @@ -2,10 +2,10 @@ using Intersect.Client.Plugins.Contexts; using Intersect.Core; using Intersect.Factories; -using Intersect.Logging; using Intersect.Plugins; using Intersect.Plugins.Interfaces; using Intersect.Reflection; +using Microsoft.Extensions.Logging; namespace Intersect.Client.Core; @@ -18,7 +18,7 @@ internal sealed partial class ClientContext : ApplicationContext) != fieldType.GetGenericTypeDefinition()) { - Log.Error(new NotSupportedException($"Unsupported localization type for {groupType.Name}.{fieldInfo.Name}: {fieldInfo.FieldType.FullName}")); + ApplicationContext.Context.Value?.Logger.LogError( + new NotSupportedException( + $"Unsupported localization type for {groupType.Name}.{fieldInfo.Name}: {fieldInfo.FieldType.FullName}" + ), + "Invalid field type {Type}", + fieldType + ); break; } @@ -172,7 +178,15 @@ public static void Load() var localizedParameterType = parameters.Last(); if (localizedParameterType != typeof(LocalizedString)) { - Log.Error(new NotSupportedException($"Unsupported localization dictionary value type for {groupType.Name}.{fieldInfo.Name}: {localizedParameterType.FullName}")); + ApplicationContext.Context.Value?.Logger.LogError( + new NotSupportedException( + $"Unsupported localization dictionary value type for {groupType.Name}.{fieldInfo.Name}: {localizedParameterType.FullName}" + ), + "Unsupported localization dictionary value type for {GroupName}.{FieldName}: {ParameterTypeName}", + groupType.Name, + fieldInfo.Name, + localizedParameterType.FullName + ); break; } @@ -194,13 +208,13 @@ public static void Load() if (missingStrings.Count > 0) { - Log.Warn($"Missing strings, overwriting strings file:\n\t{string.Join(",\n\t", missingStrings)}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Missing strings, overwriting strings file:\n\t{string.Join(",\n\t", missingStrings)}"); SaveSerialized(serialized); } } catch (Exception exception) { - Log.Warn(exception); + ApplicationContext.Context.Value?.Logger.LogWarning(exception, "Error occurred while loading strings"); Save(); } diff --git a/Intersect.Client.Core/Maps/MapInstance.cs b/Intersect.Client.Core/Maps/MapInstance.cs index 56ca6e2a7a..33094d18c5 100644 --- a/Intersect.Client.Core/Maps/MapInstance.cs +++ b/Intersect.Client.Core/Maps/MapInstance.cs @@ -13,14 +13,14 @@ using Intersect.Client.General; using Intersect.Client.Localization; using Intersect.Compression; +using Intersect.Core; using Intersect.Enums; using Intersect.Framework.Core.Serialization; using Intersect.GameObjects; using Intersect.GameObjects.Maps; -using Intersect.Logging; using Intersect.Network.Packets.Server; using Intersect.Utilities; - +using Microsoft.Extensions.Logging; using Newtonsoft.Json; namespace Intersect.Client.Maps; @@ -770,7 +770,7 @@ public void BuildVBOs() var endVbo = DateTime.UtcNow; var elapsedVbo = endVbo - startVbo; - Log.Info($"Built VBO for map instance {Id} in {elapsedVbo.TotalMilliseconds}ms"); + ApplicationContext.Context.Value?.Logger.LogInformation($"Built VBO for map instance {Id} in {elapsedVbo.TotalMilliseconds}ms"); // lock (mTileBuffers) // { @@ -1237,10 +1237,10 @@ private void DrawAutoTile( var bufferForFrame = bufferGroup[animationFrameIndex]; // if (bufferForFrame is MonoTileBuffer monoTileBuffer) // { - // Log.Info($"[{Name}][{layerName}] Buffer for {monoTileBuffer._texture?.Name} frame {i} has {monoTileBuffer._addedTileCount.Count} unique tiles"); + // ApplicationContext.Context.Value?.Logger.LogInformation($"[{Name}][{layerName}] Buffer for {monoTileBuffer._texture?.Name} frame {i} has {monoTileBuffer._addedTileCount.Count} unique tiles"); // foreach (var (key, value) in monoTileBuffer._addedTileCount.OrderByDescending(kvp => kvp.Value)) // { - // Log.Info($"[{Name}][{layerName}] {key} has {value} occurrences"); + // ApplicationContext.Context.Value?.Logger.LogInformation($"[{Name}][{layerName}] {key} has {value} occurrences"); // } // } outputBuffers[animationFrameIndex][bufferIndex] = bufferForFrame; diff --git a/Intersect.Client.Core/MonoGame/Audio/MonoMusicInstance.cs b/Intersect.Client.Core/MonoGame/Audio/MonoMusicInstance.cs index 639a5d9a36..dce3268bb9 100644 --- a/Intersect.Client.Core/MonoGame/Audio/MonoMusicInstance.cs +++ b/Intersect.Client.Core/MonoGame/Audio/MonoMusicInstance.cs @@ -1,5 +1,4 @@ using Intersect.Client.General; - using Microsoft.Xna.Framework.Audio; namespace Intersect.Client.MonoGame.Audio; diff --git a/Intersect.Client.Core/MonoGame/Audio/MonoMusicSource.cs b/Intersect.Client.Core/MonoGame/Audio/MonoMusicSource.cs index 46c1241056..be531e9107 100644 --- a/Intersect.Client.Core/MonoGame/Audio/MonoMusicSource.cs +++ b/Intersect.Client.Core/MonoGame/Audio/MonoMusicSource.cs @@ -3,10 +3,9 @@ using Intersect.Client.Interface.Game.Chat; using Intersect.Client.Localization; using Intersect.Client.Utilities; -using Intersect.Logging; - +using Intersect.Core; +using Microsoft.Extensions.Logging; using Microsoft.Xna.Framework.Audio; - using NVorbis; namespace Intersect.Client.MonoGame.Audio; @@ -107,7 +106,7 @@ public DynamicSoundEffectInstance LoadSong() } catch (Exception exception) { - Log.Error(exception, $"Error loading '{mPath}'."); + ApplicationContext.Context.Value?.Logger.LogError(exception, $"Error loading '{mPath}'."); ChatboxMsg.AddMessage( new ChatboxMsg( $"{Strings.Errors.LoadFile.ToString(Strings.Words.LcaseSound)} [{mPath}]", new Color(0xBF, 0x0, 0x0), Enums.ChatMessageType.Error diff --git a/Intersect.Client.Core/MonoGame/Audio/MonoSoundInstance.cs b/Intersect.Client.Core/MonoGame/Audio/MonoSoundInstance.cs index 278c7db431..267ae74851 100644 --- a/Intersect.Client.Core/MonoGame/Audio/MonoSoundInstance.cs +++ b/Intersect.Client.Core/MonoGame/Audio/MonoSoundInstance.cs @@ -1,5 +1,6 @@ using Intersect.Client.General; - +using Intersect.Core; +using Microsoft.Extensions.Logging; using Microsoft.Xna.Framework.Audio; namespace Intersect.Client.MonoGame.Audio; @@ -53,7 +54,7 @@ public override void Play() } catch (Exception ex) { - Logging.Log.Debug(ex, "Error trying to play sound in MonoSoundInstance.Play()"); + ApplicationContext.Context.Value?.Logger.LogDebug(ex, "Error trying to play sound in MonoSoundInstance.Play()"); } } diff --git a/Intersect.Client.Core/MonoGame/Audio/MonoSoundSource.cs b/Intersect.Client.Core/MonoGame/Audio/MonoSoundSource.cs index b9e028778e..7d7a3f1a79 100644 --- a/Intersect.Client.Core/MonoGame/Audio/MonoSoundSource.cs +++ b/Intersect.Client.Core/MonoGame/Audio/MonoSoundSource.cs @@ -2,8 +2,8 @@ using Intersect.Client.General; using Intersect.Client.Interface.Game.Chat; using Intersect.Client.Localization; -using Intersect.Logging; - +using Intersect.Core; +using Microsoft.Extensions.Logging; using Microsoft.Xna.Framework.Audio; namespace Intersect.Client.MonoGame.Audio; @@ -93,7 +93,7 @@ private void LoadSound() } catch (Exception exception) { - Log.Error(exception, $"Error loading '{mPath}'."); + ApplicationContext.Context.Value?.Logger.LogError(exception, $"Error loading '{mPath}'."); ChatboxMsg.AddMessage( new ChatboxMsg( $"{Strings.Errors.LoadFile.ToString(Strings.Words.LcaseSound)} [{mPath}]", diff --git a/Intersect.Client.Core/MonoGame/Database/MonoDatabase.cs b/Intersect.Client.Core/MonoGame/Database/MonoDatabase.cs index e784143e92..6f8afe5281 100644 --- a/Intersect.Client.Core/MonoGame/Database/MonoDatabase.cs +++ b/Intersect.Client.Core/MonoGame/Database/MonoDatabase.cs @@ -1,7 +1,7 @@ using Intersect.Client.Framework.Database; using Intersect.Configuration; -using Intersect.Logging; - +using Intersect.Core; +using Microsoft.Extensions.Logging; using Microsoft.Win32; namespace Intersect.Client.MonoGame.Database; @@ -27,9 +27,11 @@ public override void DeletePreference(string key) } catch (Exception exception) { -#if DEBUG - Log.Error(exception); -#endif + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error occurred deleting preference {Key}", + key + ); } } @@ -44,7 +46,7 @@ public override void SavePreference(string key, TValue value) } catch (UnauthorizedAccessException) { - Log.Error($"Unable to save preference {key} in the registry."); + ApplicationContext.Context.Value?.Logger.LogError($"Unable to save preference {key} in the registry."); throw; } } diff --git a/Intersect.Client.Core/MonoGame/File Management/MonoContentManager.cs b/Intersect.Client.Core/MonoGame/File Management/MonoContentManager.cs index bd150fb75c..3deb74a669 100644 --- a/Intersect.Client.Core/MonoGame/File Management/MonoContentManager.cs +++ b/Intersect.Client.Core/MonoGame/File Management/MonoContentManager.cs @@ -6,8 +6,8 @@ using Intersect.Client.MonoGame.Audio; using Intersect.Compression; using Intersect.Configuration; -using Intersect.Logging; - +using Intersect.Core; +using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; namespace Intersect.Client.MonoGame.File_Management; @@ -16,13 +16,13 @@ namespace Intersect.Client.MonoGame.File_Management; public partial class MonoContentManager : GameContentManager { - public MonoContentManager(ILogger logger) : base(logger) + public MonoContentManager() { var rootPath = Path.GetFullPath(ClientConfiguration.ResourcesDirectory); if (!Directory.Exists(rootPath)) { - Log.Error(Strings.Errors.ResourcesNotFound); + ApplicationContext.Context.Value?.Logger.LogError(Strings.Errors.ResourcesNotFound); Environment.Exit(1); } diff --git a/Intersect.Client.Core/MonoGame/Graphics/MonoFont.cs b/Intersect.Client.Core/MonoGame/Graphics/MonoFont.cs index b21a7af485..7eba4552bd 100644 --- a/Intersect.Client.Core/MonoGame/Graphics/MonoFont.cs +++ b/Intersect.Client.Core/MonoGame/Graphics/MonoFont.cs @@ -1,7 +1,7 @@ using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.Graphics; -using Intersect.Logging; - +using Intersect.Core; +using Microsoft.Extensions.Logging; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; @@ -25,7 +25,13 @@ public MonoFont(string fontName, string fileName, int fontSize, ContentManager c } catch (Exception ex) { - Log.Trace(ex); + ApplicationContext.Context.Value?.Logger.LogTrace( + ex, + "Error occurred loading {FontName}, {FontSize} from {FileName}", + fontName, + fontSize, + fileName + ); } } diff --git a/Intersect.Client.Core/MonoGame/Graphics/MonoRenderTexture.cs b/Intersect.Client.Core/MonoGame/Graphics/MonoRenderTexture.cs index 419850b7ff..14ea46174b 100644 --- a/Intersect.Client.Core/MonoGame/Graphics/MonoRenderTexture.cs +++ b/Intersect.Client.Core/MonoGame/Graphics/MonoRenderTexture.cs @@ -1,6 +1,5 @@ using System.Runtime.CompilerServices; using Intersect.Client.Framework.Graphics; - using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; diff --git a/Intersect.Client.Core/MonoGame/Graphics/MonoShader.cs b/Intersect.Client.Core/MonoGame/Graphics/MonoShader.cs index 3e0e7c047c..7f015eb3ba 100644 --- a/Intersect.Client.Core/MonoGame/Graphics/MonoShader.cs +++ b/Intersect.Client.Core/MonoGame/Graphics/MonoShader.cs @@ -1,7 +1,6 @@ using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Graphics; using Intersect.IO.Files; - using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; diff --git a/Intersect.Client.Core/MonoGame/Graphics/MonoTexture.cs b/Intersect.Client.Core/MonoGame/Graphics/MonoTexture.cs index 16657fd12a..9053e550b1 100644 --- a/Intersect.Client.Core/MonoGame/Graphics/MonoTexture.cs +++ b/Intersect.Client.Core/MonoGame/Graphics/MonoTexture.cs @@ -3,10 +3,10 @@ using Intersect.Client.Interface.Game.Chat; using Intersect.Client.Localization; using Intersect.Compression; +using Intersect.Core; using Intersect.IO.Files; -using Intersect.Logging; using Intersect.Utilities; - +using Microsoft.Extensions.Logging; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -117,7 +117,7 @@ public void LoadTexture() _loadError = true; if (string.IsNullOrWhiteSpace(_realPath)) { - Log.Error("Invalid texture path (empty/null)."); + ApplicationContext.Context.Value?.Logger.LogError("Invalid texture path (empty/null)."); return; } @@ -126,7 +126,7 @@ public void LoadTexture() if (!File.Exists(_realPath)) { - Log.Error($"Texture does not exist: {relativePath}"); + ApplicationContext.Context.Value?.Logger.LogError($"Texture does not exist: {relativePath}"); return; } @@ -146,7 +146,7 @@ public void LoadTexture() } catch (Exception exception) { - Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( exception, $"Failed to load texture ({FileSystemHelper.FormatSize(fileStream.Length)}): {relativePath}" ); diff --git a/Intersect.Client.Core/MonoGame/Graphics/MonoTileBuffer.cs b/Intersect.Client.Core/MonoGame/Graphics/MonoTileBuffer.cs index a83f47c91e..6908bd8ddb 100644 --- a/Intersect.Client.Core/MonoGame/Graphics/MonoTileBuffer.cs +++ b/Intersect.Client.Core/MonoGame/Graphics/MonoTileBuffer.cs @@ -1,6 +1,7 @@ using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Graphics; -using Intersect.Logging; +using Intersect.Core; +using Microsoft.Extensions.Logging; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -32,14 +33,14 @@ public override bool TryAddTile(GameTexture texture, int x, int y, int srcX, int { if (_vertexBuffer != null) { - Log.Error("Unable to add tile to null vertex buffer"); + ApplicationContext.Context.Value?.Logger.LogError("Unable to add tile to null vertex buffer"); return false; } var platformTexture = (texture == _texture ? _platformTexture : default) ?? texture.GetTexture(); if (platformTexture == null) { - Log.Error("Unable to add tile to vertex buffer because the platform texture is null"); + ApplicationContext.Context.Value?.Logger.LogError("Unable to add tile to vertex buffer because the platform texture is null"); return false; } @@ -50,7 +51,7 @@ public override bool TryAddTile(GameTexture texture, int x, int y, int srcX, int } else if (_platformTexture != platformTexture) { - Log.Error("Mismatched platform texture"); + ApplicationContext.Context.Value?.Logger.LogError("Mismatched platform texture"); return false; } @@ -124,20 +125,20 @@ public override bool TryUpdateTile(GameTexture texture, int x, int y, int srcX, { if (_vertexBuffer == default) { - Log.Error("Unable to update tile on null vertex buffer"); + ApplicationContext.Context.Value?.Logger.LogError("Unable to update tile on null vertex buffer"); return false; } if (!_tileVertexOffset.TryGetValue(x << 16 | y, out var vertexIndex)) { - Log.Error("Unable to update tile that has not been added to the vertex buffer before"); + ApplicationContext.Context.Value?.Logger.LogError("Unable to update tile that has not been added to the vertex buffer before"); return false; } var platformTexture = (texture == _texture ? _platformTexture : default) ?? texture.GetTexture(); if (platformTexture == null) { - Log.Error("Unable to add tile to vertex buffer because the platform texture is null"); + ApplicationContext.Context.Value?.Logger.LogError("Unable to add tile to vertex buffer because the platform texture is null"); return false; } @@ -148,7 +149,7 @@ public override bool TryUpdateTile(GameTexture texture, int x, int y, int srcX, } else if (_platformTexture != platformTexture) { - Log.Error("Mismatched platform texture"); + ApplicationContext.Context.Value?.Logger.LogError("Mismatched platform texture"); return false; } diff --git a/Intersect.Client.Core/MonoGame/Input/MonoInput.cs b/Intersect.Client.Core/MonoGame/Input/MonoInput.cs index dc612fd90b..eade4edab2 100644 --- a/Intersect.Client.Core/MonoGame/Input/MonoInput.cs +++ b/Intersect.Client.Core/MonoGame/Input/MonoInput.cs @@ -1,5 +1,4 @@ using System.Diagnostics; - using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Gwen.Control; using Intersect.Client.Framework.Gwen.Input; @@ -7,8 +6,8 @@ using Intersect.Client.General; using Intersect.Client.MonoGame.Graphics; using Intersect.Client.ThirdParty; -using Intersect.Logging; - +using Intersect.Core; +using Microsoft.Extensions.Logging; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input; using Keys = Intersect.Client.Framework.GenericClasses.Keys; @@ -347,7 +346,7 @@ public override void Update(TimeSpan elapsed) { if (keyboardState.IsKeyDown(key.Value) && !mLastKeyboardState.IsKeyDown(key.Value)) { - Log.Diagnostic("{0} -> {1}", key.Key, key.Value); + ApplicationContext.Context.Value?.Logger.LogTrace("{0} -> {1}", key.Key, key.Value); Interface.Interface.GwenInput.ProcessMessage( new GwenInputMessage( IntersectInput.InputEvent.KeyDown, GetMousePosition(), (int) MouseButtons.None, key.Key diff --git a/Intersect.Client.Core/MonoGame/IntersectGame.cs b/Intersect.Client.Core/MonoGame/IntersectGame.cs index 69384f394f..3fe86d5f82 100644 --- a/Intersect.Client.Core/MonoGame/IntersectGame.cs +++ b/Intersect.Client.Core/MonoGame/IntersectGame.cs @@ -11,7 +11,6 @@ using Intersect.Client.MonoGame.Network; using Intersect.Configuration; using Intersect.Updater; - using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System.Diagnostics; @@ -21,11 +20,11 @@ using Intersect.Client.Framework.Graphics; using Intersect.Client.ThirdParty; using Intersect.Utilities; - using MainMenu = Intersect.Client.Interface.Menu.MainMenu; -using Intersect.Logging; using Intersect.Client.Interface.Shared; using Intersect.Client.MonoGame.NativeInterop; +using Intersect.Core; +using Microsoft.Extensions.Logging; namespace Intersect.Client.MonoGame; @@ -75,7 +74,7 @@ private IntersectGame(IClientContext context, Action postStartupAction) } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error occurred loading strings for client"); throw; } @@ -98,8 +97,8 @@ private IntersectGame(IClientContext context, Action postStartupAction) Content.RootDirectory = string.Empty; IsMouseVisible = true; - Globals.ContentManager = new MonoContentManager(Log.Default); - Globals.Database = new JsonDatabase(Log.Default); + Globals.ContentManager = new MonoContentManager(); + Globals.Database = new JsonDatabase(); // Load configuration. Globals.Database.LoadPreferences(); @@ -334,7 +333,7 @@ protected override void Draw(GameTime gameTime) protected override void OnExiting(object sender, EventArgs args) { - Log.Info("System window closing (due to user interaction most likely)."); + ApplicationContext.Context.Value?.Logger.LogInformation("System window closing (due to user interaction most likely)."); if (Globals.Me != null && Globals.Me.CombatTimer > Timing.Global?.Milliseconds) { @@ -570,7 +569,7 @@ public void Start(IClientContext context, Action postStartupAction) } catch (Exception exception) { - Log.Warn(exception, "Error occurred when trying to apply Harmony patch, this is not a fatal error"); + ApplicationContext.Context.Value?.Logger.LogWarning(exception, "Error occurred when trying to apply Harmony patch, this is not a fatal error"); } using var game = new IntersectGame(context, postStartupAction); @@ -586,7 +585,7 @@ private static void SdlInitPost() if (!Sdl2.SDL_SetHint(Sdl2.SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, false)) { - Log.Warn("Failed to set X11 Compositor hint"); + ApplicationContext.Context.Value?.Logger.LogWarning("Failed to set X11 Compositor hint"); } } } diff --git a/Intersect.Client.Core/MonoGame/Network/MonoSocket.cs b/Intersect.Client.Core/MonoGame/Network/MonoSocket.cs index 635eda40bd..c989ba492c 100644 --- a/Intersect.Client.Core/MonoGame/Network/MonoSocket.cs +++ b/Intersect.Client.Core/MonoGame/Network/MonoSocket.cs @@ -6,7 +6,6 @@ using System.Resources; using Intersect.Client.Framework.Network; using Intersect.Configuration; -using Intersect.Logging; using Intersect.Network; using Intersect.Network.Packets; using Intersect.Utilities; @@ -14,8 +13,10 @@ using Intersect.Client.General; using Intersect.Client.Interface.Menu; using Intersect.Client.Localization; +using Intersect.Core; using Intersect.Network.Packets.Unconnected.Client; using Intersect.Rsa; +using Microsoft.Extensions.Logging; namespace Intersect.Client.MonoGame.Network; @@ -166,7 +167,7 @@ private bool TryResolveEndPoint([NotNullWhen(true)] out IPEndPoint? endPoint) UnresolvableHostNames.Add(_lastHost); Interface.Interface.ShowError(Strings.Errors.HostNotFound); - Log.Error(socketException, $"Failed to resolve host: '{_lastHost}'"); + ApplicationContext.Context.Value?.Logger.LogError(socketException, $"Failed to resolve host: '{_lastHost}'"); endPoint = default; return false; } @@ -176,7 +177,7 @@ public override void Connect(string host, int port) { if (!Network.Connect()) { - Log.Error("An error occurred while attempting to connect."); + ApplicationContext.Context.Value?.Logger.LogError("An error occurred while attempting to connect."); } } @@ -229,7 +230,7 @@ public override void Update() var network = Network; if (network == default) { - Log.Info("No network created to poll for server status."); + ApplicationContext.Context.Value?.Logger.LogInformation("No network created to poll for server status."); } else { @@ -238,12 +239,12 @@ public override void Update() } else if (!UnresolvableHostNames.Contains(_lastHost)) { - Log.Info($"Unable to resolve '{_lastHost}:{_lastPort}'"); + ApplicationContext.Context.Value?.Logger.LogInformation($"Unable to resolve '{_lastHost}:{_lastPort}'"); } } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error resolving host"); } _resolvingHost = false; diff --git a/Intersect.Client.Core/Networking/Network.cs b/Intersect.Client.Core/Networking/Network.cs index c1c16a02a5..6a24654244 100644 --- a/Intersect.Client.Core/Networking/Network.cs +++ b/Intersect.Client.Core/Networking/Network.cs @@ -4,9 +4,10 @@ using Intersect.Client.General; using Intersect.Client.Localization; using Intersect.Configuration; -using Intersect.Logging; +using Intersect.Core; using Intersect.Network; using Intersect.Network.Events; +using Microsoft.Extensions.Logging; namespace Intersect.Client.Networking; @@ -38,7 +39,7 @@ public static void Close(string reason) } catch (Exception exception) { - Log.Trace(exception); + ApplicationContext.Context.Value?.Logger.LogTrace(exception, "Error closing socket"); } } @@ -53,7 +54,7 @@ public static void DebounceClose(string reason) { if (_closeTask != default) { - Log.Debug("Disconnect already queued, skipping"); + ApplicationContext.Context.Value?.Logger.LogDebug("Disconnect already queued, skipping"); return; } @@ -65,7 +66,7 @@ public static void DebounceClose(string reason) { if (_closeTask != task) { - Log.Debug("Disconnect interrupted, skipping"); + ApplicationContext.Context.Value?.Logger.LogDebug("Disconnect interrupted, skipping"); return; } diff --git a/Intersect.Client.Core/Networking/PacketHandler.cs b/Intersect.Client.Core/Networking/PacketHandler.cs index f0cf458713..744e4a6e86 100644 --- a/Intersect.Client.Core/Networking/PacketHandler.cs +++ b/Intersect.Client.Core/Networking/PacketHandler.cs @@ -16,7 +16,6 @@ using Intersect.GameObjects; using Intersect.GameObjects.Maps; using Intersect.GameObjects.Maps.MapList; -using Intersect.Logging; using Intersect.Network; using Intersect.Network.Packets; using Intersect.Network.Packets.Server; @@ -24,6 +23,7 @@ using Intersect.Framework; using Intersect.Models; using Intersect.Client.Interface.Shared; +using Microsoft.Extensions.Logging; namespace Intersect.Client.Networking; @@ -105,7 +105,7 @@ public bool HandlePacket(IPacket packet) if (!Registry.TryGetHandler(packet, out HandlePacketGeneric handler)) { - Logger.Error($"No registered handler for {packet.GetType().FullName}!"); + Logger.LogError($"No registered handler for {packet.GetType().FullName}!"); return false; } @@ -124,7 +124,7 @@ public bool HandlePacket(IPacket packet) if (!preHooks.All(hook => hook.Handle(VirtualSender, packet))) { // Hooks should not fail, if they do that's an error - Logger.Error($"PreHook handler failed for {packet.GetType().FullName}."); + Logger.LogError($"PreHook handler failed for {packet.GetType().FullName}."); return false; } } @@ -139,7 +139,7 @@ public bool HandlePacket(IPacket packet) if (!postHooks.All(hook => hook.Handle(VirtualSender, packet))) { // Hooks should not fail, if they do that's an error - Logger.Error($"PostHook handler failed for {packet.GetType().FullName}."); + Logger.LogError($"PostHook handler failed for {packet.GetType().FullName}."); return false; } } @@ -162,7 +162,7 @@ public void HandlePacket(IPacketSender packetSender, Intersect.Network.Packets.S //ConfigPacket public void HandlePacket(IPacketSender packetSender, ConfigPacket packet) { - Log.Debug("Received configuration from server."); + ApplicationContext.Context.Value?.Logger.LogDebug("Received configuration from server."); Options.LoadFromServer(packet.Config); Globals.WaitingOnServer = false; MainMenu.HandleReceivedConfiguration(); @@ -172,7 +172,7 @@ public void HandlePacket(IPacketSender packetSender, ConfigPacket packet) } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error loading strings"); throw; } Graphics.InitInGame(); @@ -216,7 +216,7 @@ public void HandlePacket(IPacketSender packetSender, MapAreaIdsPacket packet) continue; } - Log.Warn($"Failed to deserialized cached data for {cacheKey}, will fetch again"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Failed to deserialized cached data for {cacheKey}, will fetch again"); } cacheKeys.Add(new ObjectCacheKey(new Id(mapId))); @@ -246,7 +246,7 @@ private void HandleMap(IPacketSender packetSender, MapPacket packet, bool skipSa if (!ObjectDataDiskCache.TrySave(cacheData)) { - Log.Warn($"Failed to save cache for {cacheKey}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Failed to save cache for {cacheKey}"); } } @@ -494,7 +494,7 @@ public void HandlePacket(IPacketSender packetSender, EntityPositionPacket packet if (en == Globals.Me) { - Log.Debug($"received epp: {Timing.Global.Milliseconds}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"received epp: {Timing.Global.Milliseconds}"); } if (en == Globals.Me && @@ -1335,14 +1335,14 @@ public void HandlePacket(IPacketSender packetSender, HotbarPacket packet) { if (Globals.Me == null) { - Log.Debug("Can't set hotbar, Globals.Me is null!"); + ApplicationContext.Context.Value?.Logger.LogDebug("Can't set hotbar, Globals.Me is null!"); break; } if (Globals.Me.Hotbar == null) { - Log.Debug("Can't set hotbar, hotbar is null!"); + ApplicationContext.Context.Value?.Logger.LogDebug("Can't set hotbar, hotbar is null!"); break; } diff --git a/Intersect.Client.Core/Networking/UnconnectedPacketHandlers/ServerStatusResponsePacketHandler.cs b/Intersect.Client.Core/Networking/UnconnectedPacketHandlers/ServerStatusResponsePacketHandler.cs index 8fe4ccf534..f14ba05909 100644 --- a/Intersect.Client.Core/Networking/UnconnectedPacketHandlers/ServerStatusResponsePacketHandler.cs +++ b/Intersect.Client.Core/Networking/UnconnectedPacketHandlers/ServerStatusResponsePacketHandler.cs @@ -1,7 +1,8 @@ using Intersect.Client.Interface.Menu; -using Intersect.Logging; +using Intersect.Core; using Intersect.Network; using Intersect.Network.Packets.Unconnected.Server; +using Microsoft.Extensions.Logging; namespace Intersect.Client.Networking.UnconnectedPacketHandlers; @@ -17,7 +18,7 @@ public override bool Handle(IPacketSender packetSender, ServerStatusResponsePack } catch (Exception exception) { - Log.Debug(exception); + ApplicationContext.Context.Value?.Logger.LogDebug(exception, "Failed to set main menu network status"); return false; } } diff --git a/Intersect.Client.Core/Plugins/Helpers/PluginPacketSender.cs b/Intersect.Client.Core/Plugins/Helpers/PluginPacketSender.cs index be76271f10..102ea0acb6 100644 --- a/Intersect.Client.Core/Plugins/Helpers/PluginPacketSender.cs +++ b/Intersect.Client.Core/Plugins/Helpers/PluginPacketSender.cs @@ -1,13 +1,14 @@ using Intersect.Core; using Intersect.Network; using Intersect.Plugins.Interfaces; +using Microsoft.Extensions.Logging; namespace Intersect.Client.Plugins.Helpers; public sealed partial class PluginPacketSender : IPacketSender { private static IPacketSender? VirtualSender => Networking.Network.PacketHandler?.VirtualSender; - + private readonly IPacketHelper mPluginPluginPacketHelper; public PluginPacketSender(IPacketHelper pluginPacketHelper) @@ -27,7 +28,7 @@ public bool Send(IPacket packet) { throw new ArgumentNullException(nameof(packet)); } - + var packetType = packet.GetType(); var packetTypeRegisteredByPlugin = mPluginPluginPacketHelper.AllPluginPacketTypes.Contains(packetType); @@ -37,7 +38,7 @@ public bool Send(IPacket packet) } #if DEBUG - ApplicationContext?.Logger.Error( + ApplicationContext?.Logger.LogError( $"Tried to send packet of type {packetType.FullName} but it was not registered by this plugin.\n" + "Available packet types:\n" + $"{string.Join("\n", mPluginPluginPacketHelper.AllPluginPacketTypes.Select(type => type.FullName))}" diff --git a/Intersect.Client.Core/Program.cs b/Intersect.Client.Core/Program.cs index 83c3a9f9c9..bafad35f31 100644 --- a/Intersect.Client.Core/Program.cs +++ b/Intersect.Client.Core/Program.cs @@ -1,4 +1,4 @@ -using Intersect.Logging; + using Intersect.Utilities; using System.Diagnostics; using System.Globalization; @@ -6,7 +6,9 @@ using System.Resources; using Intersect.Client.ThirdParty; using Intersect.Configuration; +using Intersect.Core; using Intersect.Extensions; +using Microsoft.Extensions.Logging; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Graphics; @@ -149,7 +151,11 @@ private static string ReadProcessOutput(string name) } catch (Exception exception) { - Log.Warn(exception); + ApplicationContext.Context.Value?.Logger.LogWarning( + exception, + "Error reading process output from '{Name}'", + name + ); return string.Empty; } } @@ -253,7 +259,7 @@ private static void ExportDependency(string filename, string? folder = default, } else { - Log.Warn($"Was looking for '{resourceName}' but only the following resources were found:\n{string.Join("\n\t", assembly.GetManifestResourceNames())}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Was looking for '{resourceName}' but only the following resources were found:\n{string.Join("\n\t", assembly.GetManifestResourceNames())}"); var resourceStream = assembly.GetManifestResourceStream("Intersect Client.g.resources"); Debug.Assert(resourceStream != null, "resourceStream != null"); var resources = new ResourceSet(resourceStream); diff --git a/Intersect.Client.Core/ThirdParty/Steam.cs b/Intersect.Client.Core/ThirdParty/Steam.cs index 0fe83ca6c5..1d41e85427 100644 --- a/Intersect.Client.Core/ThirdParty/Steam.cs +++ b/Intersect.Client.Core/ThirdParty/Steam.cs @@ -1,7 +1,8 @@ using System.Reflection; using Intersect.Client.Framework.GenericClasses; using Intersect.Client.MonoGame.NativeInterop; -using Intersect.Logging; +using Intersect.Core; +using Microsoft.Extensions.Logging; using Steamworks; namespace Intersect.Client.ThirdParty; @@ -57,7 +58,10 @@ static Steam() } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error during Steam integration initialization" + ); Initialized = false; } } diff --git a/Intersect.Client.Framework/Database/JsonDatabase.cs b/Intersect.Client.Framework/Database/JsonDatabase.cs index 54ea5ce3ce..dd294496c0 100644 --- a/Intersect.Client.Framework/Database/JsonDatabase.cs +++ b/Intersect.Client.Framework/Database/JsonDatabase.cs @@ -1,7 +1,8 @@ using System.Diagnostics.CodeAnalysis; using System.Reflection; using Intersect.Configuration; -using Intersect.Logging; +using Intersect.Core; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -10,13 +11,11 @@ namespace Intersect.Client.Framework.Database; public class JsonDatabase : GameDatabase { private readonly string _instancePath; - private readonly ILogger _logger; private JObject? _instance; - public JsonDatabase(ILogger logger) + public JsonDatabase() { _instancePath = GetInstancePath(ClientConfiguration.Instance); - _logger = logger; _ = TryOpenOrCreate(_instancePath, out _instance); } @@ -52,7 +51,10 @@ private bool TryOpenOrCreate(string instancePath, [NotNullWhen(true)] out JObjec } catch (Exception exception) { - _logger.Error(exception, $"Failed to open or create part or all of the path: {instancePath}"); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + $"Failed to open or create part or all of the path: {instancePath}" + ); instance = default; return false; } @@ -85,8 +87,10 @@ private bool TryWrite(string instancePath, JObject instance) } catch (Exception exception) { - _logger.Error(exception, - $"Failed to open or create part or all of the path, or failed while writing to: {instancePath}"); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + $"Failed to open or create part or all of the path, or failed while writing to: {instancePath}" + ); instance = default; return false; } @@ -128,7 +132,9 @@ public override string LoadPreference(string key) return token.Value(); } - _logger.Warn($"Found invalid type {token.Type} stored in {key} instead of {JTokenType.String}."); + ApplicationContext.Context.Value?.Logger.LogWarning( + $"Found invalid type {token.Type} stored in {key} instead of {JTokenType.String}." + ); return string.Empty; } diff --git a/Intersect.Client.Framework/File Management/GameContentManager.cs b/Intersect.Client.Framework/File Management/GameContentManager.cs index 2ef3102c8b..427e20b45d 100644 --- a/Intersect.Client.Framework/File Management/GameContentManager.cs +++ b/Intersect.Client.Framework/File Management/GameContentManager.cs @@ -5,16 +5,15 @@ using Intersect.Client.Framework.Graphics; using Intersect.Compression; using Intersect.Configuration; -using Intersect.Logging; +using Intersect.Core; using Intersect.Plugins; +using Microsoft.Extensions.Logging; namespace Intersect.Client.Framework.File_Management; public abstract partial class GameContentManager : IContentManager { - public ILogger Logger { get; } - public enum UI { Menu, @@ -78,9 +77,8 @@ public enum UI public ContentWatcher ContentWatcher { get; protected set; } - protected GameContentManager(ILogger logger) + protected GameContentManager() { - Logger = logger; Current = this; } @@ -472,7 +470,11 @@ public virtual void SaveUIJson(UI stage, string name, string json, string resolu } catch (Exception exception) { - Logger.Debug(exception); + ApplicationContext.Context.Value?.Logger.LogDebug( + exception, + "Error occurred saving {ResourcePath}", + resourcePath + ); } }); return; @@ -489,7 +491,11 @@ public virtual void SaveUIJson(UI stage, string name, string json, string resolu } catch (Exception exception) { - Logger.Debug(exception); + ApplicationContext.Context.Value?.Logger.LogDebug( + exception, + "Error occurred saving {ResourcePath}", + resourcePath + ); } }); } diff --git a/Intersect.Client.Framework/Graphics/GameTexture.cs b/Intersect.Client.Framework/Graphics/GameTexture.cs index a0147af446..128cce9f59 100644 --- a/Intersect.Client.Framework/Graphics/GameTexture.cs +++ b/Intersect.Client.Framework/Graphics/GameTexture.cs @@ -1,7 +1,8 @@ using System.Runtime.CompilerServices; using Intersect.Client.Framework.Content; -using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.GenericClasses; +using Intersect.Core; +using Microsoft.Extensions.Logging; namespace Intersect.Client.Framework.Graphics; @@ -81,7 +82,10 @@ public GameTexturePackFrame? TexturePackFrame break; default: - GameContentManager.Current?.Logger.Error(new ArgumentOutOfRangeException(nameof(boundsComparison), boundsComparison.ToString())); + ApplicationContext.Context.Value?.Logger.LogError( + new ArgumentOutOfRangeException(nameof(boundsComparison), boundsComparison.ToString()), + "Failed to get bounding texture" + ); break; } diff --git a/Intersect.Client.Framework/Gwen/Control/Base.cs b/Intersect.Client.Framework/Gwen/Control/Base.cs index 036126bd3f..d31ffc49ff 100644 --- a/Intersect.Client.Framework/Gwen/Control/Base.cs +++ b/Intersect.Client.Framework/Gwen/Control/Base.cs @@ -11,7 +11,9 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Intersect.Client.Framework.Gwen.Renderer; +using Intersect.Core; using Intersect.Framework.Reflection; +using Microsoft.Extensions.Logging; namespace Intersect.Client.Framework.Gwen.Control; @@ -895,13 +897,17 @@ public void LoadJsonUi(GameContentManager.UI stage, string? resolution, bool sav { if (string.IsNullOrWhiteSpace(Name)) { - GameContentManager.Current?.Logger.Warn($"Attempted to load layout for nameless {GetType().FullName}"); + ApplicationContext.Context.Value?.Logger.LogWarning( + $"Attempted to load layout for nameless {GetType().FullName}" + ); return; } if (string.IsNullOrWhiteSpace(resolution) || string.IsNullOrEmpty(resolution)) { - GameContentManager.Current?.Logger.Warn($"Attempted to load layout for {Name} with no resolution"); + ApplicationContext.Context.Value?.Logger.LogWarning( + $"Attempted to load layout for {Name} with no resolution" + ); return; } @@ -1202,7 +1208,7 @@ private bool HasNamedChildren() #if DIAGNOSTIC ~Base() { - Log.Debug($"IDisposable object finalized: {GetType()}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"IDisposable object finalized: {GetType()}"); } #endif diff --git a/Intersect.Client.Framework/Gwen/Control/Button.cs b/Intersect.Client.Framework/Gwen/Control/Button.cs index c589c97d45..31d111535b 100644 --- a/Intersect.Client.Framework/Gwen/Control/Button.cs +++ b/Intersect.Client.Framework/Gwen/Control/Button.cs @@ -2,7 +2,6 @@ using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Gwen.Input; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/Control/CheckBox.cs b/Intersect.Client.Framework/Gwen/Control/CheckBox.cs index 4e7508e508..20b36ec770 100644 --- a/Intersect.Client.Framework/Gwen/Control/CheckBox.cs +++ b/Intersect.Client.Framework/Gwen/Control/CheckBox.cs @@ -1,6 +1,5 @@ using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.Graphics; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/Control/ComboBox.cs b/Intersect.Client.Framework/Gwen/Control/ComboBox.cs index 76d94e4a30..18ecf5d106 100644 --- a/Intersect.Client.Framework/Gwen/Control/ComboBox.cs +++ b/Intersect.Client.Framework/Gwen/Control/ComboBox.cs @@ -1,7 +1,6 @@ using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Gwen.Control.EventArguments; using Intersect.Client.Framework.Gwen.ControlInternal; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/Control/ImagePanel.cs b/Intersect.Client.Framework/Gwen/Control/ImagePanel.cs index 32a7db9b1c..33d7f7cbd7 100644 --- a/Intersect.Client.Framework/Gwen/Control/ImagePanel.cs +++ b/Intersect.Client.Framework/Gwen/Control/ImagePanel.cs @@ -2,7 +2,6 @@ using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Gwen.ControlInternal; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/Control/Label.cs b/Intersect.Client.Framework/Gwen/Control/Label.cs index 1c0dc1aeaf..a208393293 100644 --- a/Intersect.Client.Framework/Gwen/Control/Label.cs +++ b/Intersect.Client.Framework/Gwen/Control/Label.cs @@ -3,7 +3,6 @@ using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Gwen.Control.EventArguments; using Intersect.Client.Framework.Gwen.ControlInternal; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/Control/LabeledCheckBox.cs b/Intersect.Client.Framework/Gwen/Control/LabeledCheckBox.cs index b0538920ac..796845af7f 100644 --- a/Intersect.Client.Framework/Gwen/Control/LabeledCheckBox.cs +++ b/Intersect.Client.Framework/Gwen/Control/LabeledCheckBox.cs @@ -1,6 +1,5 @@ using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Gwen.Control.EventArguments; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/Control/LabeledHorizontalSlider.cs b/Intersect.Client.Framework/Gwen/Control/LabeledHorizontalSlider.cs index 5d1675f141..7fd8f88f94 100644 --- a/Intersect.Client.Framework/Gwen/Control/LabeledHorizontalSlider.cs +++ b/Intersect.Client.Framework/Gwen/Control/LabeledHorizontalSlider.cs @@ -1,5 +1,4 @@ using Intersect.Client.Framework.GenericClasses; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/Control/Layout/Table.cs b/Intersect.Client.Framework/Gwen/Control/Layout/Table.cs index e794758552..e1f4c2e928 100644 --- a/Intersect.Client.Framework/Gwen/Control/Layout/Table.cs +++ b/Intersect.Client.Framework/Gwen/Control/Layout/Table.cs @@ -1,5 +1,4 @@ using System.Globalization; - using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Gwen.Control.Data; diff --git a/Intersect.Client.Framework/Gwen/Control/ListBox.cs b/Intersect.Client.Framework/Gwen/Control/ListBox.cs index add231fbea..919a086092 100644 --- a/Intersect.Client.Framework/Gwen/Control/ListBox.cs +++ b/Intersect.Client.Framework/Gwen/Control/ListBox.cs @@ -1,10 +1,8 @@ using System.Text.RegularExpressions; - using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Gwen.Control.EventArguments; using Intersect.Client.Framework.Gwen.Control.Layout; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/Control/Menu.cs b/Intersect.Client.Framework/Gwen/Control/Menu.cs index 2f0ee2a4ea..b31ce4a79b 100644 --- a/Intersect.Client.Framework/Gwen/Control/Menu.cs +++ b/Intersect.Client.Framework/Gwen/Control/Menu.cs @@ -1,7 +1,6 @@ using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Gwen.ControlInternal; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/Control/ResizableControl.cs b/Intersect.Client.Framework/Gwen/Control/ResizableControl.cs index f7419ecfca..f2cbf91044 100644 --- a/Intersect.Client.Framework/Gwen/Control/ResizableControl.cs +++ b/Intersect.Client.Framework/Gwen/Control/ResizableControl.cs @@ -1,5 +1,4 @@ using Intersect.Client.Framework.Gwen.ControlInternal; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/Control/RichLabel.cs b/Intersect.Client.Framework/Gwen/Control/RichLabel.cs index 161eef5fc9..a21e57bf9e 100644 --- a/Intersect.Client.Framework/Gwen/Control/RichLabel.cs +++ b/Intersect.Client.Framework/Gwen/Control/RichLabel.cs @@ -1,7 +1,6 @@ using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Graphics; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/Control/ScrollBar.cs b/Intersect.Client.Framework/Gwen/Control/ScrollBar.cs index fe6d03e6f9..90254ad938 100644 --- a/Intersect.Client.Framework/Gwen/Control/ScrollBar.cs +++ b/Intersect.Client.Framework/Gwen/Control/ScrollBar.cs @@ -1,7 +1,6 @@ using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Gwen.ControlInternal; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/Control/ScrollControl.cs b/Intersect.Client.Framework/Gwen/Control/ScrollControl.cs index ab8c87d36c..00f2fa4e9f 100644 --- a/Intersect.Client.Framework/Gwen/Control/ScrollControl.cs +++ b/Intersect.Client.Framework/Gwen/Control/ScrollControl.cs @@ -1,5 +1,4 @@ using Intersect.Client.Framework.GenericClasses; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/Control/Slider.cs b/Intersect.Client.Framework/Gwen/Control/Slider.cs index 3581156d1e..f1066c41f1 100644 --- a/Intersect.Client.Framework/Gwen/Control/Slider.cs +++ b/Intersect.Client.Framework/Gwen/Control/Slider.cs @@ -3,7 +3,6 @@ using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Gwen.ControlInternal; using Intersect.Client.Framework.Gwen.Input; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/Control/TextBox.cs b/Intersect.Client.Framework/Gwen/Control/TextBox.cs index 6ad6175d0d..486118e734 100644 --- a/Intersect.Client.Framework/Gwen/Control/TextBox.cs +++ b/Intersect.Client.Framework/Gwen/Control/TextBox.cs @@ -1,6 +1,7 @@ using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Gwen.Input; -using Intersect.Logging; +using Intersect.Core; +using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; @@ -616,7 +617,14 @@ public virtual void ReplaceText(int startPos, int length, string? replacement, b } catch (Exception exception) { - LegacyLogging.Logger?.Warn(exception); + ApplicationContext.Context.Value?.Logger.LogWarning( + exception, + "Failed to replace {Length} characters in '{Text}' starting at {StartPosition} with '{ReplacementText}", + length, + Text, + startPos, + replacement + ); } } diff --git a/Intersect.Client.Framework/Gwen/Control/WindowControl.cs b/Intersect.Client.Framework/Gwen/Control/WindowControl.cs index 520b57dd1b..3de144fed1 100644 --- a/Intersect.Client.Framework/Gwen/Control/WindowControl.cs +++ b/Intersect.Client.Framework/Gwen/Control/WindowControl.cs @@ -1,10 +1,8 @@ using System.Diagnostics.CodeAnalysis; - using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Gwen.ControlInternal; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.Control; diff --git a/Intersect.Client.Framework/Gwen/ControlInternal/Dragger.cs b/Intersect.Client.Framework/Gwen/ControlInternal/Dragger.cs index 70585e3792..c7aee17db0 100644 --- a/Intersect.Client.Framework/Gwen/ControlInternal/Dragger.cs +++ b/Intersect.Client.Framework/Gwen/ControlInternal/Dragger.cs @@ -2,7 +2,6 @@ using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Gwen.Control; using Intersect.Client.Framework.Gwen.Input; - using Newtonsoft.Json.Linq; namespace Intersect.Client.Framework.Gwen.ControlInternal; diff --git a/Intersect.Client.Framework/Gwen/Input/InputHandler.cs b/Intersect.Client.Framework/Gwen/Input/InputHandler.cs index d96e6a103c..26d3688b1b 100644 --- a/Intersect.Client.Framework/Gwen/Input/InputHandler.cs +++ b/Intersect.Client.Framework/Gwen/Input/InputHandler.cs @@ -1,5 +1,4 @@ using System.Text; - using Intersect.Client.Framework.Gwen.Control; using Intersect.Client.Framework.Gwen.DragDrop; diff --git a/Intersect.Client.Framework/Gwen/Renderer/Base.cs b/Intersect.Client.Framework/Gwen/Renderer/Base.cs index 87d8045acc..aafea1656d 100644 --- a/Intersect.Client.Framework/Gwen/Renderer/Base.cs +++ b/Intersect.Client.Framework/Gwen/Renderer/Base.cs @@ -108,7 +108,7 @@ public virtual void Dispose() #if DIAGNOSTIC ~Base() { - Log.Debug($"IDisposable object finalized: {GetType()}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"IDisposable object finalized: {GetType()}"); } #endif diff --git a/Intersect.Client.Framework/Gwen/Renderer/IntersectRenderer.cs b/Intersect.Client.Framework/Gwen/Renderer/IntersectRenderer.cs index 0a09e3a62d..ae0477fbc3 100644 --- a/Intersect.Client.Framework/Gwen/Renderer/IntersectRenderer.cs +++ b/Intersect.Client.Framework/Gwen/Renderer/IntersectRenderer.cs @@ -1,7 +1,8 @@ -using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Graphics; using Intersect.Configuration; +using Intersect.Core; +using Microsoft.Extensions.Logging; namespace Intersect.Client.Framework.Gwen.Renderer; @@ -340,7 +341,7 @@ public void SetupCacheTexture(Control.Base control) if (!m_RT.ContainsKey(control)) { var keys = m_RT.Keys.Select(key => key.CanonicalName); - GameContentManager.Current?.Logger.Error($"{control.CanonicalName} not found in the list of render targets: {string.Join(", ", keys)}"); + ApplicationContext.Context.Value?.Logger.LogError($"{control.CanonicalName} not found in the list of render targets: {string.Join(", ", keys)}"); } mRenderTarget = m_RT[control]; // make cache current RT mRenderTarget.Begin(); diff --git a/Intersect.Client.Framework/Gwen/Skin/Base.cs b/Intersect.Client.Framework/Gwen/Skin/Base.cs index 94d789f6a0..aa1b06bb91 100644 --- a/Intersect.Client.Framework/Gwen/Skin/Base.cs +++ b/Intersect.Client.Framework/Gwen/Skin/Base.cs @@ -57,7 +57,7 @@ public virtual void Dispose() #if DIAGNOSTIC ~Base() { - Log.Debug($"IDisposable object finalized: {GetType()}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"IDisposable object finalized: {GetType()}"); } #endif diff --git a/Intersect.Client.Framework/Gwen/Skin/TexturedBase.cs b/Intersect.Client.Framework/Gwen/Skin/TexturedBase.cs index e826dc184b..492166f2af 100644 --- a/Intersect.Client.Framework/Gwen/Skin/TexturedBase.cs +++ b/Intersect.Client.Framework/Gwen/Skin/TexturedBase.cs @@ -1,12 +1,10 @@ using System.Diagnostics; - using Intersect.Client.Framework.File_Management; using Intersect.Client.Framework.GenericClasses; using Intersect.Client.Framework.Graphics; using Intersect.Client.Framework.Gwen.Control; using Intersect.Client.Framework.Gwen.ControlInternal; using Intersect.Client.Framework.Gwen.Skin.Texturing; - using Single = Intersect.Client.Framework.Gwen.Skin.Texturing.Single; namespace Intersect.Client.Framework.Gwen.Skin; diff --git a/Intersect.Client.Framework/Gwen/Util.cs b/Intersect.Client.Framework/Gwen/Util.cs index 69142238d0..3a6c6d5185 100644 --- a/Intersect.Client.Framework/Gwen/Util.cs +++ b/Intersect.Client.Framework/Gwen/Util.cs @@ -1,5 +1,4 @@ using System.Text.RegularExpressions; - using Intersect.Client.Framework.GenericClasses; namespace Intersect.Client.Framework.Gwen; diff --git a/Intersect.Editor/Content/ContentManager.cs b/Intersect.Editor/Content/ContentManager.cs index 0a1d4bbac0..24d5b1b370 100644 --- a/Intersect.Editor/Content/ContentManager.cs +++ b/Intersect.Editor/Content/ContentManager.cs @@ -3,9 +3,7 @@ using Intersect.Editor.Networking; using Intersect.GameObjects; using Intersect.IO.Files; -using Intersect.Logging; using Intersect.Utilities; - using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; @@ -222,13 +220,13 @@ public static void LoadTilesets() } catch (Exception exception) { - Log.Error($"Fake methods! ({tileset.Name})"); + ApplicationContext.Context.Value?.Logger.LogError($"Fake methods! ({tileset.Name})"); if (exception.InnerException != null) { - Log.Error(exception.InnerException); + ApplicationContext.Context.Value?.Logger.LogError(exception.InnerException); } - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception); throw; } @@ -469,7 +467,7 @@ public static Effect GetShader(string name) { if (string.IsNullOrWhiteSpace(name)) { - Log.Error("Tried to load shader with null name."); + ApplicationContext.Context.Value?.Logger.LogError("Tried to load shader with null name."); return null; } @@ -486,7 +484,7 @@ public static object GetMusic(string name) { if (string.IsNullOrWhiteSpace(name)) { - Log.Error("Tried to load music with null name."); + ApplicationContext.Context.Value?.Logger.LogError("Tried to load music with null name."); return null; } @@ -503,7 +501,7 @@ public static object GetSound(string name) { if (string.IsNullOrWhiteSpace(name)) { - Log.Error("Tried to load sound with null name."); + ApplicationContext.Context.Value?.Logger.LogError("Tried to load sound with null name."); return null; } diff --git a/Intersect.Editor/Content/Texture.cs b/Intersect.Editor/Content/Texture.cs index 0041d83f8b..79dd8c1b67 100644 --- a/Intersect.Editor/Content/Texture.cs +++ b/Intersect.Editor/Content/Texture.cs @@ -1,9 +1,6 @@ using Intersect.IO.Files; -using Intersect.Logging; using Intersect.Utilities; - using Microsoft.Xna.Framework.Graphics; - using Graphics = Intersect.Editor.Core.Graphics; namespace Intersect.Editor.Content; @@ -33,7 +30,7 @@ public void LoadTexture() mLoadError = true; if (string.IsNullOrWhiteSpace(mPath)) { - Log.Error("Invalid texture path (empty/null)."); + ApplicationContext.Context.Value?.Logger.LogError("Invalid texture path (empty/null)."); return; } @@ -42,7 +39,7 @@ public void LoadTexture() if (!File.Exists(mPath)) { - Log.Error($"Texture does not exist: {relativePath}"); + ApplicationContext.Context.Value?.Logger.LogError($"Texture does not exist: {relativePath}"); return; } @@ -54,7 +51,7 @@ public void LoadTexture() mTexture = Texture2D.FromStream(Graphics.GetGraphicsDevice(), fileStream); if (mTexture == null) { - Log.Error($"Failed to load texture due to unknown error: {relativePath}"); + ApplicationContext.Context.Value?.Logger.LogError($"Failed to load texture due to unknown error: {relativePath}"); return; } @@ -65,7 +62,7 @@ public void LoadTexture() } catch (Exception exception) { - Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( exception, $"Failed to load texture ({FileSystemHelper.FormatSize(fileStream.Length)}): {relativePath}" ); @@ -138,7 +135,7 @@ public void GetDimensions() mLoadError = true; if (string.IsNullOrWhiteSpace(mPath)) { - Log.Error("Invalid texture path (empty/null)."); + ApplicationContext.Context.Value?.Logger.LogError("Invalid texture path (empty/null)."); return; } @@ -147,7 +144,7 @@ public void GetDimensions() if (!File.Exists(mPath)) { - Log.Error($"Texture does not exist: {relativePath}"); + ApplicationContext.Context.Value?.Logger.LogError($"Texture does not exist: {relativePath}"); return; } @@ -159,7 +156,7 @@ public void GetDimensions() var img = System.Drawing.Image.FromStream(fileStream, false, false); if (img == null) { - Log.Error($"Failed to load texture due to unknown error: {relativePath}"); + ApplicationContext.Context.Value?.Logger.LogError($"Failed to load texture due to unknown error: {relativePath}"); return; } @@ -170,7 +167,7 @@ public void GetDimensions() } catch (Exception exception) { - Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( exception, $"Failed to load texture ({FileSystemHelper.FormatSize(fileStream.Length)}): {relativePath}" ); diff --git a/Intersect.Editor/Content/TexturePacker.cs b/Intersect.Editor/Content/TexturePacker.cs index d8ae12be9a..df504d7701 100644 --- a/Intersect.Editor/Content/TexturePacker.cs +++ b/Intersect.Editor/Content/TexturePacker.cs @@ -1,5 +1,4 @@ using System.Drawing.Imaging; - using Intersect.Compression; using Intersect.Editor.Content; using Newtonsoft.Json.Linq; diff --git a/Intersect.Editor/Core/Graphics.cs b/Intersect.Editor/Core/Graphics.cs index c56c57c45f..ac2bfb1b0c 100644 --- a/Intersect.Editor/Core/Graphics.cs +++ b/Intersect.Editor/Core/Graphics.cs @@ -9,9 +9,7 @@ using Intersect.Enums; using Intersect.GameObjects; using Intersect.GameObjects.Maps; -using Intersect.Logging; using Intersect.Utilities; - using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -217,11 +215,11 @@ public static void Render() } catch (Exception exception) { - Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( $"{Globals.MapGrid.Grid.GetLength(0)}x{Globals.MapGrid.Grid.GetLength(1)} -- {x},{y}" ); - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception); } if (map != null) @@ -759,8 +757,8 @@ RenderTarget2D renderTarget2D } catch (Exception exception) { - Log.Error($"map={tmpMap != null},layer{drawLayer}.tiles={tmpMap.Layers[drawLayer] != null}"); - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError($"map={tmpMap != null},layer{drawLayer}.tiles={tmpMap.Layers[drawLayer] != null}"); + ApplicationContext.Context.Value?.Logger.LogError(exception); continue; } diff --git a/Intersect.Editor/Core/Main.cs b/Intersect.Editor/Core/Main.cs index 81ad02ffb0..5783abcb6e 100644 --- a/Intersect.Editor/Core/Main.cs +++ b/Intersect.Editor/Core/Main.cs @@ -156,7 +156,7 @@ private static void UpdateMaps() } catch (Exception ex) { - Logging.Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( ex, "JC's Solution for UpdateMaps collection was modified bug did not work!" ); } diff --git a/Intersect.Editor/Core/Preferences.cs b/Intersect.Editor/Core/Preferences.cs index efd53f3cac..81d242ff10 100644 --- a/Intersect.Editor/Core/Preferences.cs +++ b/Intersect.Editor/Core/Preferences.cs @@ -1,5 +1,4 @@ using Intersect.Configuration; - using Microsoft.Win32; namespace Intersect.Editor.Core; diff --git a/Intersect.Editor/Core/Program.cs b/Intersect.Editor/Core/Program.cs index c19353b8f5..89933809f0 100644 --- a/Intersect.Editor/Core/Program.cs +++ b/Intersect.Editor/Core/Program.cs @@ -1,9 +1,8 @@ using System.Diagnostics; using System.Reflection; - using Intersect.Editor.Forms; using Intersect.Editor.General; -using Intersect.Logging; + namespace Intersect.Editor.Core; @@ -33,7 +32,7 @@ static Program() [STAThread] public static void Main() { - Log.Diagnostic("Starting editor..."); + ApplicationContext.Context.Value?.Logger.LogTrace("Starting editor..."); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.ThreadException += Application_ThreadException; @@ -41,7 +40,7 @@ public static void Main() Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Log.Diagnostic("Unpacking libraries..."); + ApplicationContext.Context.Value?.Logger.LogTrace("Unpacking libraries..."); //Place sqlite3.dll where it's needed. var dllname = Environment.Is64BitProcess ? "sqlite3x64.dll" : "sqlite3x86.dll"; @@ -57,15 +56,15 @@ public static void Main() } } - Log.Diagnostic("Libraries unpacked."); + ApplicationContext.Context.Value?.Logger.LogTrace("Libraries unpacked."); - Log.Diagnostic("Creating forms..."); + ApplicationContext.Context.Value?.Logger.LogTrace("Creating forms..."); Globals.UpdateForm = new FrmUpdate(); Globals.LoginForm = new FrmLogin(); Globals.MainForm = new FrmMain(); - Log.Diagnostic("Forms created."); + ApplicationContext.Context.Value?.Logger.LogTrace("Forms created."); - Log.Diagnostic("Starting application."); + ApplicationContext.Context.Value?.Logger.LogTrace("Starting application."); Application.Run(Globals.UpdateForm); } @@ -77,7 +76,7 @@ private static void Application_ThreadException(object sender, ThreadExceptionEv //Really basic error handler for debugging purposes public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs exception) { - Log.Error((Exception) exception?.ExceptionObject); + ApplicationContext.Context.Value?.Logger.LogError(Exception) exception?.ExceptionObject); MessageBox.Show( @"The Intersect Editor has encountered an error and must close. Error information can be found in logs/errors.log" ); diff --git a/Intersect.Editor/Entities/Animation.cs b/Intersect.Editor/Entities/Animation.cs index 4639aa3193..81cba5aa47 100644 --- a/Intersect.Editor/Entities/Animation.cs +++ b/Intersect.Editor/Entities/Animation.cs @@ -1,7 +1,6 @@ using Intersect.Editor.Content; using Intersect.GameObjects; using Intersect.Utilities; - using Microsoft.Xna.Framework.Graphics; namespace Intersect.Editor.Entities; diff --git a/Intersect.Editor/Forms/Controls/LightEditorCtrl.cs b/Intersect.Editor/Forms/Controls/LightEditorCtrl.cs index 64ec1d6fdf..220cda658e 100644 --- a/Intersect.Editor/Forms/Controls/LightEditorCtrl.cs +++ b/Intersect.Editor/Forms/Controls/LightEditorCtrl.cs @@ -1,7 +1,6 @@ using Intersect.Editor.General; using Intersect.Editor.Localization; using Intersect.GameObjects; - using Graphics = Intersect.Editor.Core.Graphics; namespace Intersect.Editor.Forms.Controls; diff --git a/Intersect.Editor/Forms/Controls/MapAttributeTooltip.Designer.cs b/Intersect.Editor/Forms/Controls/MapAttributeTooltip.Designer.cs index e468e0df5a..074d0e810d 100644 --- a/Intersect.Editor/Forms/Controls/MapAttributeTooltip.Designer.cs +++ b/Intersect.Editor/Forms/Controls/MapAttributeTooltip.Designer.cs @@ -1,6 +1,5 @@ using System.Drawing; using System.Windows.Forms; - using Intersect.Editor.Localization; namespace Intersect.Editor.Forms.Controls diff --git a/Intersect.Editor/Forms/Controls/MapTreeList.cs b/Intersect.Editor/Forms/Controls/MapTreeList.cs index 1acd6f2b41..b77f22994f 100644 --- a/Intersect.Editor/Forms/Controls/MapTreeList.cs +++ b/Intersect.Editor/Forms/Controls/MapTreeList.cs @@ -1,8 +1,7 @@ using System.Runtime.InteropServices; - using Intersect.Editor.Networking; using Intersect.GameObjects.Maps.MapList; -using Intersect.Logging; + namespace Intersect.Editor.Forms.Controls; @@ -258,7 +257,7 @@ private void BeginEdit(TreeNode node) public void UpdateMapList(Guid selectMapId = default, List? restrictMaps = null) { - Log.Info("Updating list"); + ApplicationContext.Context.Value?.Logger.LogInformation("Updating list"); var selectedMapListMap = selectMapId == default ? default : MapList.List.FindMap(selectMapId); if (selectedMapListMap != default && _nodeLookup.TryGetValue(selectedMapListMap, out var treeNode)) { diff --git a/Intersect.Editor/Forms/Controls/SearchableDarkTreeView.cs b/Intersect.Editor/Forms/Controls/SearchableDarkTreeView.cs index 7e925896c5..4e23ee3d46 100644 --- a/Intersect.Editor/Forms/Controls/SearchableDarkTreeView.cs +++ b/Intersect.Editor/Forms/Controls/SearchableDarkTreeView.cs @@ -1,5 +1,4 @@ using DarkUI.Controls; - using Intersect.Collections; using Intersect.Models; diff --git a/Intersect.Editor/Forms/DockingElements/frmMapEditor.cs b/Intersect.Editor/Forms/DockingElements/frmMapEditor.cs index 1a9c150e9b..7f0f0b45e0 100644 --- a/Intersect.Editor/Forms/DockingElements/frmMapEditor.cs +++ b/Intersect.Editor/Forms/DockingElements/frmMapEditor.cs @@ -13,7 +13,6 @@ using Intersect.GameObjects; using Intersect.GameObjects.Events; using Intersect.GameObjects.Maps; -using Intersect.Logging; using Microsoft.Xna.Framework.Graphics; using WeifenLuo.WinFormsUI.Docking; @@ -1004,7 +1003,7 @@ private void picMap_DoubleClick(object sender, EventArgs e) if (currentMap == null) { - Log.Error(new ArgumentNullException(nameof(currentMap))); + ApplicationContext.Context.Value?.Logger.LogError(new ArgumentNullException(nameof(currentMap))); return; } @@ -2397,7 +2396,7 @@ private void RemoveSpriteCursorInGrid() if (!ToolCursor.ToolCursorDict.TryGetValue(editingTool, out var toolCursorInfo)) { var loadedClickPointKeys = string.Join(", ", ToolCursor.ToolCursorDict.Keys); - Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( $"Unable to load click point for {editingTool}, click points only exist for: {loadedClickPointKeys}" ); return null; @@ -2417,7 +2416,7 @@ private void RemoveSpriteCursorInGrid() #endif if (!File.Exists(cursorAbsolutePath)) { - Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( $"Custom cursor texture '{cursorFileName}' does not exist in {ToolCursor.CursorsFolder} resolved to {loggingCursorPath}" ); return null; @@ -2430,7 +2429,7 @@ private void RemoveSpriteCursorInGrid() } catch (Exception exception) { - Log.Error(exception, $"Failed to load custom cursor for {editingTool} resolved to {loggingCursorPath}"); + ApplicationContext.Context.Value?.Logger.LogError(exception, $"Failed to load custom cursor for {editingTool} resolved to {loggingCursorPath}"); return null; } @@ -2456,14 +2455,14 @@ private void RemoveSpriteCursorInGrid() IntPtr bitmapHicon = cursorBitmap.GetHicon(); if (bitmapHicon == IntPtr.Zero) { - Log.Warn($"Failed to get bitmap icon handle for {logName}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Failed to get bitmap icon handle for {logName}"); return null; } IconInfo cursorIconInfo = new IconInfo(); if (!GetIconInfo(bitmapHicon, ref cursorIconInfo)) { - Log.Warn($"Failed to get icon info for {logName}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Failed to get icon info for {logName}"); return null; } @@ -2475,7 +2474,7 @@ private void RemoveSpriteCursorInGrid() // ReSharper disable once InvertIf if (cursorIcon == IntPtr.Zero) { - Log.Warn($"Failed to create cursor icon for {logName}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Failed to create cursor icon for {logName}"); return null; } @@ -2483,7 +2482,7 @@ private void RemoveSpriteCursorInGrid() } catch (Exception exception) { - Log.Error(exception, $"Error while creating cursor for {logName}"); + ApplicationContext.Context.Value?.Logger.LogError(exception, $"Error while creating cursor for {logName}"); return null; } } diff --git a/Intersect.Editor/Forms/DockingElements/frmMapGrid.cs b/Intersect.Editor/Forms/DockingElements/frmMapGrid.cs index d2c2a4d07c..61dc32e396 100644 --- a/Intersect.Editor/Forms/DockingElements/frmMapGrid.cs +++ b/Intersect.Editor/Forms/DockingElements/frmMapGrid.cs @@ -2,11 +2,8 @@ using Intersect.Editor.General; using Intersect.Editor.Localization; using Intersect.Editor.Maps; - using Microsoft.Xna.Framework.Graphics; - using WeifenLuo.WinFormsUI.Docking; - using Graphics = Intersect.Editor.Core.Graphics; namespace Intersect.Editor.Forms.DockingElements; diff --git a/Intersect.Editor/Forms/DockingElements/frmMapLayers.cs b/Intersect.Editor/Forms/DockingElements/frmMapLayers.cs index efe4c49002..e3cec4e5a6 100644 --- a/Intersect.Editor/Forms/DockingElements/frmMapLayers.cs +++ b/Intersect.Editor/Forms/DockingElements/frmMapLayers.cs @@ -9,9 +9,7 @@ using Intersect.GameObjects.Maps.MapList; using Intersect.Localization; using Intersect.Utilities; - using Microsoft.Xna.Framework.Graphics; - using WeifenLuo.WinFormsUI.Docking; using Graphics = System.Drawing.Graphics; diff --git a/Intersect.Editor/Forms/DockingElements/frmMapList.cs b/Intersect.Editor/Forms/DockingElements/frmMapList.cs index c147c94941..fd8399cbeb 100644 --- a/Intersect.Editor/Forms/DockingElements/frmMapList.cs +++ b/Intersect.Editor/Forms/DockingElements/frmMapList.cs @@ -4,7 +4,6 @@ using Intersect.Editor.Localization; using Intersect.Editor.Networking; using Intersect.GameObjects.Maps.MapList; - using WeifenLuo.WinFormsUI.Docking; namespace Intersect.Editor.Forms.DockingElements; diff --git a/Intersect.Editor/Forms/DockingElements/frmMapProperties.cs b/Intersect.Editor/Forms/DockingElements/frmMapProperties.cs index c9ab1e43e0..1f17379302 100644 --- a/Intersect.Editor/Forms/DockingElements/frmMapProperties.cs +++ b/Intersect.Editor/Forms/DockingElements/frmMapProperties.cs @@ -1,7 +1,6 @@ using Intersect.Editor.Core; using Intersect.Editor.Localization; using Intersect.Editor.Maps; - using WeifenLuo.WinFormsUI.Docking; namespace Intersect.Editor.Forms.DockingElements; diff --git a/Intersect.Editor/Forms/Editors/EditorForm.cs b/Intersect.Editor/Forms/Editors/EditorForm.cs index 784c057936..710e3b1d20 100644 --- a/Intersect.Editor/Forms/Editors/EditorForm.cs +++ b/Intersect.Editor/Forms/Editors/EditorForm.cs @@ -1,7 +1,7 @@ using Intersect.Editor.Core; using Intersect.Editor.Networking; using Intersect.Enums; -using Intersect.Logging; + namespace Intersect.Editor.Forms.Editors; @@ -44,7 +44,7 @@ protected void ApplyHooks() } catch (Exception e) { - Log.Debug(e); + ApplicationContext.Context.Value?.Logger.LogDebug(e); } }; diff --git a/Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs b/Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs index 2d84ba5c0f..ceebc0be04 100644 --- a/Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs +++ b/Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs @@ -1,5 +1,4 @@ using System.Text; - using Intersect.Editor.Localization; using Intersect.Editor.Maps; using Intersect.Enums; @@ -8,7 +7,6 @@ using Intersect.GameObjects.Events; using Intersect.GameObjects.Events.Commands; using Intersect.GameObjects.Maps.MapList; -using Intersect.Logging; using VariableMod = Intersect.GameObjects.Events.VariableMod; namespace Intersect.Editor.Forms.Editors.Events; @@ -185,12 +183,12 @@ MapInstance map if ((cnd.BranchIds?.Length ?? 0) < 2) { - Log.Error("Missing branch ids in conditional branch."); + ApplicationContext.Context.Value?.Logger.LogError("Missing branch ids in conditional branch."); } if (!page.CommandLists.TryGetValue(cnd.BranchIds[0], out var branchCommandList)) { - Log.Error($"Missing command list for branch {cnd.BranchIds[0]}"); + ApplicationContext.Context.Value?.Logger.LogError($"Missing command list for branch {cnd.BranchIds[0]}"); } PrintCommandList( @@ -213,7 +211,7 @@ MapInstance map if (!page.CommandLists.TryGetValue(cnd.BranchIds[1], out branchCommandList)) { - Log.Error($"Missing command list for branch {cnd.BranchIds[1]}"); + ApplicationContext.Context.Value?.Logger.LogError($"Missing command list for branch {cnd.BranchIds[1]}"); } PrintCommandList( diff --git a/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Warp.cs b/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Warp.cs index 20198d6f46..e3a9326996 100644 --- a/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Warp.cs +++ b/Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_Warp.cs @@ -1,5 +1,4 @@ using DarkUI.Controls; - using Intersect.Editor.Localization; using Intersect.Enums; using Intersect.GameObjects.Events.Commands; diff --git a/Intersect.Editor/Forms/Editors/Events/frmEvent.cs b/Intersect.Editor/Forms/Editors/Events/frmEvent.cs index 6616277cce..7529cd821d 100644 --- a/Intersect.Editor/Forms/Editors/Events/frmEvent.cs +++ b/Intersect.Editor/Forms/Editors/Events/frmEvent.cs @@ -1,6 +1,5 @@ using DarkUI.Controls; using DarkUI.Forms; - using Intersect.Editor.Content; using Intersect.Editor.Core; using Intersect.Editor.Forms.Editors.Events.Event_Commands; @@ -14,7 +13,6 @@ using Intersect.GameObjects.Events.Commands; using Intersect.GameObjects.Maps; using Intersect.Utilities; - using Newtonsoft.Json; using Graphics = System.Drawing.Graphics; diff --git a/Intersect.Editor/Forms/Editors/Quest/Quest_TaskEditor.cs b/Intersect.Editor/Forms/Editors/Quest/Quest_TaskEditor.cs index 4719c7b429..5c0cf059b5 100644 --- a/Intersect.Editor/Forms/Editors/Quest/Quest_TaskEditor.cs +++ b/Intersect.Editor/Forms/Editors/Quest/Quest_TaskEditor.cs @@ -3,7 +3,7 @@ using Intersect.Editor.Localization; using Intersect.Enums; using Intersect.GameObjects; -using Intersect.Logging; + namespace Intersect.Editor.Forms.Editors.Quest; @@ -23,12 +23,12 @@ public QuestTaskEditor(QuestBase refQuest, QuestBase.QuestTask refTask) { if (refQuest == null) { - Log.Warn($@"{nameof(refQuest)} is null."); + ApplicationContext.Context.Value?.Logger.LogWarning($@"{nameof(refQuest)} is null."); } if (refTask == null) { - Log.Warn($@"{nameof(refTask)} is null."); + ApplicationContext.Context.Value?.Logger.LogWarning($@"{nameof(refTask)} is null."); } InitializeComponent(); @@ -37,7 +37,7 @@ public QuestTaskEditor(QuestBase refQuest, QuestBase.QuestTask refTask) if (mMyTask?.EditingEvent == null) { - Log.Warn($@"{nameof(mMyTask.EditingEvent)} is null."); + ApplicationContext.Context.Value?.Logger.LogWarning($@"{nameof(mMyTask.EditingEvent)} is null."); } mEventBackup = mMyTask?.EditingEvent?.JsonData; diff --git a/Intersect.Editor/Forms/Editors/Quest/frmQuest.cs b/Intersect.Editor/Forms/Editors/Quest/frmQuest.cs index 674c8edf3f..746be55fb5 100644 --- a/Intersect.Editor/Forms/Editors/Quest/frmQuest.cs +++ b/Intersect.Editor/Forms/Editors/Quest/frmQuest.cs @@ -7,7 +7,7 @@ using Intersect.Enums; using Intersect.GameObjects; using Intersect.GameObjects.Events; -using Intersect.Logging; + namespace Intersect.Editor.Forms.Editors.Quest; @@ -126,18 +126,18 @@ private void btnCancel_Click(object sender, EventArgs e) { if (item == null) { - Log.Warn($"Unexpected null: {nameof(FrmQuest)}.{nameof(btnCancel_Click)}() {nameof(item)}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Unexpected null: {nameof(FrmQuest)}.{nameof(btnCancel_Click)}() {nameof(item)}"); } else { if (item.StartEvent == null) { - Log.Warn($"Unexpected null: {nameof(FrmQuest)}.{nameof(btnCancel_Click)}() {nameof(item)}.{nameof(item.StartEvent)}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Unexpected null: {nameof(FrmQuest)}.{nameof(btnCancel_Click)}() {nameof(item)}.{nameof(item.StartEvent)}"); } if (item.EndEvent == null) { - Log.Warn($"Unexpected null: {nameof(FrmQuest)}.{nameof(btnCancel_Click)}() {nameof(item)}.{nameof(item.EndEvent)}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Unexpected null: {nameof(FrmQuest)}.{nameof(btnCancel_Click)}() {nameof(item)}.{nameof(item.EndEvent)}"); } } diff --git a/Intersect.Editor/Forms/Editors/frmAnimation.cs b/Intersect.Editor/Forms/Editors/frmAnimation.cs index daf85d84cc..63865c405f 100644 --- a/Intersect.Editor/Forms/Editors/frmAnimation.cs +++ b/Intersect.Editor/Forms/Editors/frmAnimation.cs @@ -1,8 +1,6 @@ using System.Media; - using DarkUI.Controls; using DarkUI.Forms; - using Intersect.Editor.Content; using Intersect.Editor.Core; using Intersect.Editor.General; @@ -11,7 +9,6 @@ using Intersect.Enums; using Intersect.GameObjects; using Intersect.Utilities; - using Microsoft.Xna.Framework.Graphics; namespace Intersect.Editor.Forms.Editors; diff --git a/Intersect.Editor/Forms/Editors/frmClass.cs b/Intersect.Editor/Forms/Editors/frmClass.cs index d0405f121b..9c66a1c500 100644 --- a/Intersect.Editor/Forms/Editors/frmClass.cs +++ b/Intersect.Editor/Forms/Editors/frmClass.cs @@ -1,5 +1,4 @@ using DarkUI.Forms; - using Intersect.Editor.Content; using Intersect.Editor.Core; using Intersect.Editor.General; diff --git a/Intersect.Editor/Forms/Editors/frmCommonEvent.cs b/Intersect.Editor/Forms/Editors/frmCommonEvent.cs index 1c76dc57f5..97a2bf6cb8 100644 --- a/Intersect.Editor/Forms/Editors/frmCommonEvent.cs +++ b/Intersect.Editor/Forms/Editors/frmCommonEvent.cs @@ -1,5 +1,4 @@ using DarkUI.Forms; - using Intersect.Editor.Forms.Editors.Events; using Intersect.Editor.General; using Intersect.Editor.Localization; diff --git a/Intersect.Editor/Forms/Editors/frmItem.cs b/Intersect.Editor/Forms/Editors/frmItem.cs index 0558e99a9e..79d98bbfdb 100644 --- a/Intersect.Editor/Forms/Editors/frmItem.cs +++ b/Intersect.Editor/Forms/Editors/frmItem.cs @@ -1,6 +1,5 @@ using System.Drawing.Imaging; using DarkUI.Forms; - using Intersect.Editor.Content; using Intersect.Editor.Core; using Intersect.Editor.General; diff --git a/Intersect.Editor/Forms/Editors/frmNpc.cs b/Intersect.Editor/Forms/Editors/frmNpc.cs index 01888a029f..f0cc219c12 100644 --- a/Intersect.Editor/Forms/Editors/frmNpc.cs +++ b/Intersect.Editor/Forms/Editors/frmNpc.cs @@ -1,7 +1,5 @@ using System.Drawing.Imaging; - using DarkUI.Forms; - using Intersect.Editor.Content; using Intersect.Editor.Core; using Intersect.Editor.General; diff --git a/Intersect.Editor/Forms/Editors/frmResource.cs b/Intersect.Editor/Forms/Editors/frmResource.cs index 739cc70ebb..9e6b5994a7 100644 --- a/Intersect.Editor/Forms/Editors/frmResource.cs +++ b/Intersect.Editor/Forms/Editors/frmResource.cs @@ -1,5 +1,4 @@ using DarkUI.Forms; - using Intersect.Editor.Content; using Intersect.Editor.Core; using Intersect.Editor.General; diff --git a/Intersect.Editor/Forms/Editors/frmSpell.cs b/Intersect.Editor/Forms/Editors/frmSpell.cs index e9568008c4..fee42fc787 100644 --- a/Intersect.Editor/Forms/Editors/frmSpell.cs +++ b/Intersect.Editor/Forms/Editors/frmSpell.cs @@ -1,6 +1,5 @@ using DarkUI.Controls; using DarkUI.Forms; - using Intersect.Editor.Content; using Intersect.Editor.Core; using Intersect.Editor.General; diff --git a/Intersect.Editor/Forms/Editors/frmTime.cs b/Intersect.Editor/Forms/Editors/frmTime.cs index 5dc765ffb2..300286c1f8 100644 --- a/Intersect.Editor/Forms/Editors/frmTime.cs +++ b/Intersect.Editor/Forms/Editors/frmTime.cs @@ -1,7 +1,5 @@ using System.Reflection; - using DarkUI.Controls; - using Intersect.Editor.General; using Intersect.Editor.Localization; using Intersect.Editor.Networking; diff --git a/Intersect.Editor/Forms/Helpers/GridHelper.cs b/Intersect.Editor/Forms/Helpers/GridHelper.cs index f3fc33cdf1..44ec0faeb4 100644 --- a/Intersect.Editor/Forms/Helpers/GridHelper.cs +++ b/Intersect.Editor/Forms/Helpers/GridHelper.cs @@ -1,5 +1,4 @@ namespace Intersect.Editor.Forms.Helpers; - using Color = System.Drawing.Color; using Graphics = System.Drawing.Graphics; diff --git a/Intersect.Editor/Forms/frmLogin.cs b/Intersect.Editor/Forms/frmLogin.cs index d03f95dd1c..d592b72065 100644 --- a/Intersect.Editor/Forms/frmLogin.cs +++ b/Intersect.Editor/Forms/frmLogin.cs @@ -2,13 +2,11 @@ using System.Globalization; using System.Security.Cryptography; using System.Text; - using Intersect.Editor.Content; using Intersect.Editor.Core; using Intersect.Editor.General; using Intersect.Editor.Localization; using Intersect.Editor.Networking; -using Intersect.Logging; using Intersect.Network; using Intersect.Utilities; @@ -43,7 +41,7 @@ private void frmLogin_Load(object sender, EventArgs e) } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception); throw; } GameContentManager.CheckForResources(); diff --git a/Intersect.Editor/Forms/frmMain.cs b/Intersect.Editor/Forms/frmMain.cs index 1fca647541..a538c3f4f4 100644 --- a/Intersect.Editor/Forms/frmMain.cs +++ b/Intersect.Editor/Forms/frmMain.cs @@ -1,7 +1,6 @@ using System.Diagnostics; using System.Globalization; using System.Security.Cryptography; - using DarkUI.Controls; using DarkUI.Forms; using Intersect.Compression; @@ -24,7 +23,6 @@ using Intersect.Utilities; using Newtonsoft.Json; using Newtonsoft.Json.Linq; - using WeifenLuo.WinFormsUI.Docking; namespace Intersect.Editor.Forms; diff --git a/Intersect.Editor/Forms/frmUpdate.cs b/Intersect.Editor/Forms/frmUpdate.cs index 61af0f238f..39e56bb2c2 100644 --- a/Intersect.Editor/Forms/frmUpdate.cs +++ b/Intersect.Editor/Forms/frmUpdate.cs @@ -1,12 +1,10 @@ using System.Diagnostics; using System.Globalization; - using Intersect.Configuration; using Intersect.Editor.Content; using Intersect.Editor.Core; using Intersect.Editor.General; using Intersect.Editor.Localization; -using Intersect.Logging; using Intersect.Updater; namespace Intersect.Editor.Forms; @@ -33,7 +31,7 @@ private void frmUpdate_Load(object sender, EventArgs e) } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception); throw; } GameContentManager.CheckForResources(); diff --git a/Intersect.Editor/Localization/Localizer.cs b/Intersect.Editor/Localization/Localizer.cs index e25efc2e75..0da2f9c294 100644 --- a/Intersect.Editor/Localization/Localizer.cs +++ b/Intersect.Editor/Localization/Localizer.cs @@ -1,8 +1,7 @@ using System.Reflection; - using Intersect.GameObjects.Annotations; using Intersect.Localization; -using Intersect.Logging; + namespace Intersect.Editor.Localization; @@ -57,7 +56,7 @@ public static bool TryCreate(PropertyInfo propertyInfo, out EditorProperty edito if (labelAttribute == default || displayAttribute == default) { // TODO: Re-enable this, disabled for spamming the logs - // Log.Warn($"{propertyInfo.DeclaringType.FullName}.{propertyInfo.Name} must have both a label and display attribute."); + // ApplicationContext.Context.Value?.Logger.LogWarning($"{propertyInfo.DeclaringType.FullName}.{propertyInfo.Name} must have both a label and display attribute."); editorProperty = default; return false; } @@ -96,7 +95,7 @@ public void IndexAssembly(Assembly assembly) if (_indexedAssemblies.Contains(assembly)) { - Log.Debug($"Skipping re-index of {assembly.FullName}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Skipping re-index of {assembly.FullName}"); return; } @@ -104,7 +103,7 @@ public void IndexAssembly(Assembly assembly) { if (_indexedTypes.Contains(type)) { - Log.Debug($"Skipping re-index of {type.FullName}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Skipping re-index of {type.FullName}"); continue; } diff --git a/Intersect.Editor/Localization/Strings.cs b/Intersect.Editor/Localization/Strings.cs index 53104109de..9c8736ee53 100644 --- a/Intersect.Editor/Localization/Strings.cs +++ b/Intersect.Editor/Localization/Strings.cs @@ -1,11 +1,9 @@ using System.Reflection; - using Intersect.Enums; using Intersect.Framework.Core.GameObjects.Variables; using Intersect.GameObjects; using Intersect.GameObjects.Events; using Intersect.Localization; -using Intersect.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -550,7 +548,7 @@ public static void Load() var jsonString = (string)serializedValue; if (jsonString == default) { - Log.Warn($"{groupType.Name}.{fieldInfo.Name} is null."); + ApplicationContext.Context.Value?.Logger.LogWarning($"{groupType.Name}.{fieldInfo.Name} is null."); missingStrings.Add($"{groupType.Name}.{fieldInfo.Name} (string)"); serializedGroup[fieldInfo.Name] = (string)localizedString; } @@ -573,7 +571,7 @@ public static void Load() var fieldType = fieldInfo.FieldType; if (!fieldType.IsGenericType || typeof(Dictionary<,>) != fieldType.GetGenericTypeDefinition()) { - Log.Error(new NotSupportedException($"Unsupported localization type for {groupType.Name}.{fieldInfo.Name}: {fieldInfo.FieldType.FullName}")); + ApplicationContext.Context.Value?.Logger.LogError(new NotSupportedException($"Unsupported localization type for {groupType.Name}.{fieldInfo.Name}: {fieldInfo.FieldType.FullName}")); break; } @@ -581,7 +579,7 @@ public static void Load() var localizedParameterType = parameters.Last(); if (localizedParameterType != typeof(LocalizedString)) { - Log.Error(new NotSupportedException($"Unsupported localization dictionary value type for {groupType.Name}.{fieldInfo.Name}: {localizedParameterType.FullName}")); + ApplicationContext.Context.Value?.Logger.LogError(new NotSupportedException($"Unsupported localization dictionary value type for {groupType.Name}.{fieldInfo.Name}: {localizedParameterType.FullName}")); break; } @@ -603,13 +601,13 @@ public static void Load() if (missingStrings.Count > 0) { - Log.Warn($"Missing strings, overwriting strings file:\n\t{string.Join(",\n\t", missingStrings)}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Missing strings, overwriting strings file:\n\t{string.Join(",\n\t", missingStrings)}"); SaveSerialized(serialized); } } catch (Exception exception) { - Log.Warn(exception); + ApplicationContext.Context.Value?.Logger.LogWarning(exception); Save(); } diff --git a/Intersect.Editor/Maps/MapGrid.cs b/Intersect.Editor/Maps/MapGrid.cs index b4aa1bbac9..98697910ad 100644 --- a/Intersect.Editor/Maps/MapGrid.cs +++ b/Intersect.Editor/Maps/MapGrid.cs @@ -1,5 +1,4 @@ using DarkUI.Forms; - using Hjg.Pngcs; using Intersect.Editor.Core; using Intersect.Editor.Forms; @@ -7,9 +6,7 @@ using Intersect.Editor.Localization; using Intersect.Editor.Networking; using Intersect.GameObjects.Maps.MapList; - using Microsoft.Xna.Framework.Graphics; - using Newtonsoft.Json.Linq; namespace Intersect.Editor.Maps; diff --git a/Intersect.Editor/Maps/MapInstance.cs b/Intersect.Editor/Maps/MapInstance.cs index 945c0b4561..8fff52c487 100644 --- a/Intersect.Editor/Maps/MapInstance.cs +++ b/Intersect.Editor/Maps/MapInstance.cs @@ -8,7 +8,6 @@ using Intersect.GameObjects.Events; using Intersect.GameObjects.Maps; using Newtonsoft.Json; - using Graphics = Intersect.Editor.Core.Graphics; namespace Intersect.Editor.Maps; diff --git a/Intersect.Editor/Maps/MapProperties.cs b/Intersect.Editor/Maps/MapProperties.cs index 5c91527e27..aaa7a96d04 100644 --- a/Intersect.Editor/Maps/MapProperties.cs +++ b/Intersect.Editor/Maps/MapProperties.cs @@ -1,5 +1,4 @@ using System.ComponentModel; - using Intersect.Editor.Content; using Intersect.Editor.General; using Intersect.Editor.Localization; @@ -7,7 +6,6 @@ using Intersect.GameObjects; using Intersect.GameObjects.Maps; using Intersect.Utilities; - using Graphics = Intersect.Editor.Core.Graphics; namespace Intersect.Editor.Maps; diff --git a/Intersect.Editor/Networking/Network.cs b/Intersect.Editor/Networking/Network.cs index c81416d3d0..a61960a53c 100644 --- a/Intersect.Editor/Networking/Network.cs +++ b/Intersect.Editor/Networking/Network.cs @@ -1,9 +1,7 @@ using System.Diagnostics; using System.Reflection; - using Intersect.Configuration; using Intersect.Editor.General; -using Intersect.Logging; using Intersect.Network; using Intersect.Network.Events; using Intersect.Core; @@ -83,7 +81,7 @@ public static void Connect() return; } - Log.Warn("Failed to connect to server."); + ApplicationContext.Context.Value?.Logger.LogWarning("Failed to connect to server."); } public static void InitNetwork() @@ -199,7 +197,7 @@ public static void Update() var network = EditorLidgrenNetwork; if (network == default) { - Log.Info("No network created to poll for server status."); + ApplicationContext.Context.Value?.Logger.LogInformation("No network created to poll for server status."); } else { @@ -209,7 +207,7 @@ public static void Update() } else { - Log.Info($"Unable to resolve '{_lastHost}:{_lastPort}'"); + ApplicationContext.Context.Value?.Logger.LogInformation($"Unable to resolve '{_lastHost}:{_lastPort}'"); } if (Globals.LoginForm.LastNetworkStatusChangeTime + ServerStatusPingInterval + ServerStatusPingInterval / 2 < now) diff --git a/Intersect.Editor/Networking/PacketHandler.cs b/Intersect.Editor/Networking/PacketHandler.cs index 32024cd362..9499cf41ee 100644 --- a/Intersect.Editor/Networking/PacketHandler.cs +++ b/Intersect.Editor/Networking/PacketHandler.cs @@ -11,7 +11,6 @@ using Intersect.GameObjects.Events; using Intersect.GameObjects.Maps; using Intersect.GameObjects.Maps.MapList; -using Intersect.Logging; using Intersect.Network; using Intersect.Network.Packets.Server; @@ -84,7 +83,7 @@ public bool HandlePacket(IConnection connection, IPacket packet) if (!Registry.TryGetHandler(packet, out HandlePacketGeneric handler)) { - Logger.Error($"No registered handler for {packet.GetType().FullName}!"); + Logger.LogError($"No registered handler for {packet.GetType().FullName}!"); return false; } @@ -103,7 +102,7 @@ public bool HandlePacket(IConnection connection, IPacket packet) if (!preHooks.All(hook => hook.Handle(VirtualSender, packet))) { // Hooks should not fail, if they do that's an error - Logger.Error($"PreHook handler failed for {packet.GetType().FullName}."); + Logger.LogError($"PreHook handler failed for {packet.GetType().FullName}."); return false; } } @@ -118,7 +117,7 @@ public bool HandlePacket(IConnection connection, IPacket packet) if (!postHooks.All(hook => hook.Handle(VirtualSender, packet))) { // Hooks should not fail, if they do that's an error - Logger.Error($"PostHook handler failed for {packet.GetType().FullName}."); + Logger.LogError($"PostHook handler failed for {packet.GetType().FullName}."); return false; } } @@ -144,7 +143,7 @@ public void HandlePacket(IPacketSender packetSender, ConfigPacket packet) Strings.Load(); } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception); throw; } } @@ -414,14 +413,14 @@ public void HandlePacket(IPacketSender packetSender, GameObjectPacket packet) } catch (Exception exception) { - Log.Error($"Another mystery NPE. [Lookup={AnimationBase.Lookup}]"); + ApplicationContext.Context.Value?.Logger.LogError($"Another mystery NPE. [Lookup={AnimationBase.Lookup}]"); if (exception.InnerException != null) { - Log.Error(exception.InnerException); + ApplicationContext.Context.Value?.Logger.LogError(exception.InnerException); } - Log.Error(exception); - Log.Error($"{nameof(id)}={id},{nameof(anim)}={anim}"); + ApplicationContext.Context.Value?.Logger.LogError(exception); + ApplicationContext.Context.Value?.Logger.LogError($"{nameof(id)}={id},{nameof(anim)}={anim}"); throw; } diff --git a/Intersect.Editor/Networking/UnconnectedPacketHandlers/ServerStatusResponsePacketHandler.cs b/Intersect.Editor/Networking/UnconnectedPacketHandlers/ServerStatusResponsePacketHandler.cs index d0069591c7..797f78273a 100644 --- a/Intersect.Editor/Networking/UnconnectedPacketHandlers/ServerStatusResponsePacketHandler.cs +++ b/Intersect.Editor/Networking/UnconnectedPacketHandlers/ServerStatusResponsePacketHandler.cs @@ -1,5 +1,4 @@ using Intersect.Editor.General; -using Intersect.Logging; using Intersect.Network; using Intersect.Network.Packets.Unconnected.Server; @@ -17,7 +16,7 @@ public override bool Handle(IPacketSender packetSender, ServerStatusResponsePack } catch (Exception exception) { - Log.Debug(exception); + ApplicationContext.Context.Value?.Logger.LogDebug(exception); return false; } } diff --git a/Intersect.Network/ClientNetwork.cs b/Intersect.Network/ClientNetwork.cs index 7d4823a30d..af376cd196 100644 --- a/Intersect.Network/ClientNetwork.cs +++ b/Intersect.Network/ClientNetwork.cs @@ -3,9 +3,9 @@ using System.Net.NetworkInformation; using System.Security.Cryptography; using Intersect.Core; -using Intersect.Logging; using Intersect.Network.Events; using Intersect.Network.LiteNetLib; +using Microsoft.Extensions.Logging; namespace Intersect.Network; @@ -93,26 +93,26 @@ public override bool Send(ICollection connections, IPacket packet, protected virtual void HandleInterfaceOnConnected(INetworkLayerInterface sender, ConnectionEventArgs connectionEventArgs) { - Log.Info($"Connected [{connectionEventArgs.Connection?.Guid}]."); + ApplicationContext.Logger.LogInformation($"Connected [{connectionEventArgs.Connection?.Guid}]."); _isConnected = true; OnConnected?.Invoke(sender, connectionEventArgs); } protected virtual void HandleInterfaceOnConnectonApproved(INetworkLayerInterface sender, ConnectionEventArgs connectionEventArgs) { - Log.Info($"Connection approved [{connectionEventArgs.Connection?.Guid}]."); + ApplicationContext.Logger.LogInformation($"Connection approved [{connectionEventArgs.Connection?.Guid}]."); OnConnectionApproved?.Invoke(sender, connectionEventArgs); } protected virtual void HandleInterfaceOnConnectonDenied(INetworkLayerInterface sender, ConnectionEventArgs connectionEventArgs) { - Log.Info($"Connection denied [{connectionEventArgs.Connection?.Guid}]."); + ApplicationContext.Logger.LogInformation($"Connection denied [{connectionEventArgs.Connection?.Guid}]."); OnConnectionDenied?.Invoke(sender, connectionEventArgs); } protected virtual void HandleInterfaceOnDisconnected(INetworkLayerInterface sender, ConnectionEventArgs connectionEventArgs) { - Log.Info($"Disconnected [{connectionEventArgs.Connection?.Guid ?? Guid.Empty}]."); + ApplicationContext.Logger.LogInformation($"Disconnected [{connectionEventArgs.Connection?.Guid ?? Guid.Empty}]."); _isConnected = false; OnDisconnected?.Invoke(sender, connectionEventArgs); } diff --git a/Intersect.Network/LiteNetLib/AesAlgorithm.cs b/Intersect.Network/LiteNetLib/AesAlgorithm.cs index 73d0d82c31..805aa3cf64 100644 --- a/Intersect.Network/LiteNetLib/AesAlgorithm.cs +++ b/Intersect.Network/LiteNetLib/AesAlgorithm.cs @@ -1,7 +1,9 @@ using System.Buffers; using System.Buffers.Binary; using System.Security.Cryptography; -using Intersect.Logging; +using Intersect.Core; +using Microsoft.Extensions.Logging; + namespace Intersect.Network.LiteNetLib; @@ -103,14 +105,14 @@ public override EncryptionResult TryDecrypt(ReadOnlySpan cipherdata, out R plaindata = plaindataBuffer; #if DIAGNOSTIC - Log.Debug($"Decrypting {plaindata.Length} bytes:\nKey={Convert.ToHexString(aes.Key)} Nonce={Convert.ToHexString(aes.IV)}\nplaindata={Convert.ToHexString(plaindata)}\ncipherdata={Convert.ToHexString(cipherdata)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Decrypting {plaindata.Length} bytes:\nKey={Convert.ToHexString(aes.Key)} Nonce={Convert.ToHexString(aes.IV)}\nplaindata={Convert.ToHexString(plaindata)}\ncipherdata={Convert.ToHexString(cipherdata)}"); #endif return EncryptionResult.Success; } catch (Exception exception) { - Log.Debug(exception); + ApplicationContext.Context.Value?.Logger.LogDebug(exception, "Error decrypting cipherdata"); return EncryptionResult.Error; } } @@ -152,14 +154,14 @@ public override EncryptionResult TryEncrypt(ReadOnlySpan plaindata, out Re cipherdata = memoryStream.ToArray(); #if DIAGNOSTIC - Log.Debug($"Encrypting {plaindata.Length} bytes:\nKey={Convert.ToHexString(aes.Key)} Nonce={Convert.ToHexString(aes.IV)}\nplaindata={Convert.ToHexString(plaindata)}\ncipherdata={Convert.ToHexString(cipherdata[^plaindata.Length..])}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Encrypting {plaindata.Length} bytes:\nKey={Convert.ToHexString(aes.Key)} Nonce={Convert.ToHexString(aes.IV)}\nplaindata={Convert.ToHexString(plaindata)}\ncipherdata={Convert.ToHexString(cipherdata[^plaindata.Length..])}"); #endif return EncryptionResult.Success; } catch (Exception exception) { - Log.Debug(exception); + ApplicationContext.Context.Value?.Logger.LogDebug(exception, "Error encrypting plaindata"); return EncryptionResult.Error; } } diff --git a/Intersect.Network/LiteNetLib/AesGcmAlgorithm.cs b/Intersect.Network/LiteNetLib/AesGcmAlgorithm.cs index 063b891fe3..5244bcaf90 100644 --- a/Intersect.Network/LiteNetLib/AesGcmAlgorithm.cs +++ b/Intersect.Network/LiteNetLib/AesGcmAlgorithm.cs @@ -1,7 +1,8 @@ using System.Buffers; using System.Buffers.Binary; using System.Security.Cryptography; -using Intersect.Logging; +using Intersect.Core; +using Microsoft.Extensions.Logging; namespace Intersect.Network.LiteNetLib; @@ -130,14 +131,14 @@ public override EncryptionResult TryDecrypt(ReadOnlySpan cipherdata, out R catch (Exception exception) { #if DIAGNOSTIC - Log.Debug($"cipherdata({cipherdata.Length})=[nonce={Convert.ToHexString(nonce)}, tag={Convert.ToHexString(tag)}]"); - Log.Debug($"cipherdataView({cipherdataView.Length})={Convert.ToHexString(cipherdataView)}"); - Log.Debug($"key={Convert.ToHexString(_key.Span)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"cipherdata({cipherdata.Length})=[nonce={Convert.ToHexString(nonce)}, tag={Convert.ToHexString(tag)}]"); + ApplicationContext.Context.Value?.Logger.LogDebug($"cipherdataView({cipherdataView.Length})={Convert.ToHexString(cipherdataView)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"key={Convert.ToHexString(_key.Span)}"); #endif - var configuredLogLevel = Options.Instance?.Logging.Level ?? LogLevel.Diagnostic; + var configuredLogLevel = Options.Instance?.Logging.Level ?? LogLevel.Trace; if (configuredLogLevel >= LogLevel.Debug) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error decrypting cipherdata"); } plaindata = default; return EncryptionResult.Error; @@ -201,9 +202,9 @@ public override EncryptionResult TryEncrypt(ReadOnlySpan plaindata, out Re #if DIAGNOSTIC if (plaindata.Length > 1000) { - Log.Debug($"cipherdata({cipherdata.Length})=[nonce={Convert.ToHexString(nonce)}, tag={Convert.ToHexString(tag)}]"); - Log.Debug($"cipherdataView({cipherdataView.Length})={Convert.ToHexString(cipherdataView)}"); - Log.Debug($"key={Convert.ToHexString(_key.Span)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"cipherdata({cipherdata.Length})=[nonce={Convert.ToHexString(nonce)}, tag={Convert.ToHexString(tag)}]"); + ApplicationContext.Context.Value?.Logger.LogDebug($"cipherdataView({cipherdataView.Length})={Convert.ToHexString(cipherdataView)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"key={Convert.ToHexString(_key.Span)}"); } #endif @@ -211,10 +212,10 @@ public override EncryptionResult TryEncrypt(ReadOnlySpan plaindata, out Re } catch (Exception exception) { - var configuredLogLevel = Options.Instance?.Logging.Level ?? LogLevel.Diagnostic; + var configuredLogLevel = Options.Instance?.Logging.Level ?? LogLevel.Trace; if (configuredLogLevel >= LogLevel.Debug) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error encrypting plaindata"); } cipherdata = default; return EncryptionResult.Error; diff --git a/Intersect.Network/LiteNetLib/LiteNetLibConnection.cs b/Intersect.Network/LiteNetLib/LiteNetLibConnection.cs index 51aea56903..95b67a55d2 100644 --- a/Intersect.Network/LiteNetLib/LiteNetLibConnection.cs +++ b/Intersect.Network/LiteNetLib/LiteNetLibConnection.cs @@ -1,12 +1,13 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Security.Cryptography; +using Intersect.Core; using Intersect.Framework.Reflection; -using Intersect.Logging; using Intersect.Memory; using Intersect.Network.Packets; using LiteNetLib; using LiteNetLib.Utils; +using Microsoft.Extensions.Logging; namespace Intersect.Network.LiteNetLib; @@ -35,7 +36,7 @@ ReadOnlySpan symmetricKey _peer = peer; _peer.Tag = Guid; _symmetric = SymmetricAlgorithm.PickForVersion(symmetricVersion, symmetricKey); - Log.Debug($"Created {_symmetric.GetFullishName()} for {_peer} ({Guid})"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Created {_symmetric.GetFullishName()} for {_peer} ({Guid})"); } internal LiteNetLibConnection(INetwork network, NetManager manager, RSA interfaceAsymmetric) @@ -48,20 +49,20 @@ internal LiteNetLibConnection(INetwork network, NetManager manager, RSA interfac var connectionData = NetDataWriter.FromBytes(hail.Data, false); - Log.Info($"Connecting to {network.Configuration.Host}:{network.Configuration.Port}..."); + ApplicationContext.Context.Value?.Logger.LogInformation($"Connecting to {network.Configuration.Host}:{network.Configuration.Port}..."); #if DIAGNOSTIC if (Debugger.IsAttached) { - Log.Info($"Connection packet data: {Convert.ToHexString(hail.Data)}"); - Log.Info($"Connection packet data: {Convert.ToHexString(connectionData.Data)}"); + ApplicationContext.Context.Value?.Logger.LogInformation($"Connection packet data: {Convert.ToHexString(hail.Data)}"); + ApplicationContext.Context.Value?.Logger.LogInformation($"Connection packet data: {Convert.ToHexString(connectionData.Data)}"); } #endif _peer = manager.Connect(network.Configuration.Host, network.Configuration.Port, connectionData); _peer.Tag = Guid; _symmetric = SymmetricAlgorithm.PickForPlatform(); - Log.Debug($"Created {_symmetric.GetFullishName()} for {_peer} ({Guid})"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Created {_symmetric.GetFullishName()} for {_peer} ({Guid})"); } public override string Ip => _peer.Address.ToString(); @@ -78,7 +79,7 @@ ApprovalPacket approvalPacket return _symmetric.SetKey(approvalPacket.AesKey); } - Log.Error("Failed to decrypt approval response packet."); + ApplicationContext.Context.Value?.Logger.LogError("Failed to decrypt approval response packet."); return false; } @@ -99,7 +100,7 @@ internal bool TryProcessInboundMessage( } #if DIAGNOSTIC - Log.Debug($"TryProcessInboundMessage() cipherdata({cipherdata.Length})={Convert.ToHexString(cipherdata)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"TryProcessInboundMessage() cipherdata({cipherdata.Length})={Convert.ToHexString(cipherdata)}"); #endif var decryptionResult = _symmetric.TryDecrypt(cipherdata, out var plaindata); @@ -114,7 +115,7 @@ internal bool TryProcessInboundMessage( case EncryptionResult.EmptyInput: case EncryptionResult.SizeMismatch: case EncryptionResult.Error: - Log.Warn($"RIEP: {Guid} {decryptionResult}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"RIEP: {Guid} {decryptionResult}"); return false; default: throw new UnreachableException(); @@ -140,7 +141,7 @@ public override bool Send(IPacket packet, TransmissionMode transmissionMode = Tr case EncryptionResult.EmptyInput: case EncryptionResult.SizeMismatch: case EncryptionResult.Error: - Log.Warn($"RIEP: {Guid} {encryptionResult}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"RIEP: {Guid} {encryptionResult}"); return false; default: @@ -148,7 +149,7 @@ public override bool Send(IPacket packet, TransmissionMode transmissionMode = Tr } #if DIAGNOSTIC - Log.Debug($"Send({transmissionMode}) cipherdata({cipherdata.Length})={Convert.ToHexString(cipherdata)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Send({transmissionMode}) cipherdata({cipherdata.Length})={Convert.ToHexString(cipherdata)}"); #endif NetDataWriter data = new(false, cipherdata.Length + sizeof(byte)); data.Put((byte)1); @@ -165,7 +166,7 @@ public bool Send(NetDataWriter data, TransmissionMode transmissionMode = Transmi } catch (Exception exception) { - Log.Verbose(exception); + ApplicationContext.Context.Value?.Logger.LogDebug(exception, "Failed to send data to {Endpoint}", _peer); return false; } } diff --git a/Intersect.Network/LiteNetLib/LiteNetLibInterface.cs b/Intersect.Network/LiteNetLib/LiteNetLibInterface.cs index 93c97c15b7..9962e31cf4 100644 --- a/Intersect.Network/LiteNetLib/LiteNetLibInterface.cs +++ b/Intersect.Network/LiteNetLib/LiteNetLibInterface.cs @@ -4,14 +4,15 @@ using System.Net.Sockets; using System.Security.Cryptography; using System.Text; +using Intersect.Core; using Intersect.Framework.Reflection; -using Intersect.Logging; using Intersect.Memory; using Intersect.Network.Events; using Intersect.Network.Packets; using Intersect.Utilities; using LiteNetLib; using LiteNetLib.Utils; +using Microsoft.Extensions.Logging; using NetPeer = LiteNetLib.NetPeer; namespace Intersect.Network.LiteNetLib; @@ -99,7 +100,7 @@ public bool SendPacket( return connection.Send(packet, transmissionMode); } - Log.Debug("No active connections."); + ApplicationContext.Context.Value?.Logger.LogDebug("No active connections."); return false; } @@ -130,7 +131,7 @@ public void Start() { if (!_manager.Start()) { - Log.Error("Failed to make the initial connection attempt."); + ApplicationContext.Context.Value?.Logger.LogError("Failed to make the initial connection attempt."); } } else if (!_manager.Start(_network.Configuration.Port)) { @@ -140,7 +141,7 @@ public void Start() public void Stop(string reason = "stopping") { - Log.Verbose($"Stopping {nameof(LiteNetLibInterface)} (\"{reason}\")..."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Stopping {nameof(LiteNetLibInterface)} (\"{reason}\")..."); var reasonData = Encoding.UTF8.GetBytes(reason); _manager.DisconnectAll(reasonData, 0, reasonData.Length); } @@ -164,7 +165,7 @@ public bool Connect() return true; } - Log.Error("Failed to add connection to list."); + ApplicationContext.Context.Value?.Logger.LogError("Failed to add connection to list."); connection.Dispose(); return false; @@ -183,16 +184,16 @@ public void Disconnect(ICollection connections, string? message) public void OnPeerConnected(NetPeer peer) { - Log.Debug($"CONN {peer}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"CONN {peer}"); if (peer.Tag is not Guid guid) { - Log.Diagnostic("Peer tag is not a guid"); + ApplicationContext.Context.Value?.Logger.LogTrace("Peer tag is not a guid"); return; } if (!_connectionIdLookup.TryAdd(peer.Id, guid)) { - Log.Diagnostic($"Failed to add connection ID {guid} for peer {peer.Id}"); + ApplicationContext.Context.Value?.Logger.LogTrace($"Failed to add connection ID {guid} for peer {peer.Id}"); return; } @@ -207,7 +208,7 @@ public void OnPeerDisconnected(NetPeer peer, DisconnectInfo disconnectInfo) { if (disconnectInfo.Reason == DisconnectReason.Reconnect) { - Log.Debug($"RECONNECT: {peer}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"RECONNECT: {peer}"); return; } @@ -220,31 +221,31 @@ public void OnPeerDisconnected(NetPeer peer, DisconnectInfo disconnectInfo) { message = disconnectInfo.AdditionalData.GetString(); } - Log.Debug( + ApplicationContext.Context.Value?.Logger.LogDebug( $"DCON: {peer} \"{disconnectInfo.Reason}\" ({disconnectInfo.SocketErrorCode}): {message ?? "N/A"}" ); } catch (Exception exception) { - Log.Debug($"DCON[ERR]: {peer} \"{disconnectInfo.Reason}\" ({disconnectInfo.SocketErrorCode}): {exception.Message}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"DCON[ERR]: {peer} \"{disconnectInfo.Reason}\" ({disconnectInfo.SocketErrorCode}): {exception.Message}"); } } if (!_connectionIdLookup.TryRemove(peer.Id, out var connectionId)) { - Log.Diagnostic($"No connection found for peer ID {peer.Id} ({_network.Connections.Count})"); + ApplicationContext.Context.Value?.Logger.LogTrace($"No connection found for peer ID {peer.Id} ({_network.Connections.Count})"); return; } if (_network.FindConnection(connectionId) is not LiteNetLibConnection connection) { - Log.Diagnostic($"No connection found for {connectionId} ({_network.Connections.Count})"); + ApplicationContext.Context.Value?.Logger.LogTrace($"No connection found for {connectionId} ({_network.Connections.Count})"); return; } if (!_network.RemoveConnection(connection)) { - Log.Warn( + ApplicationContext.Context.Value?.Logger.LogWarning( $"Failed to remove connection {connection.Guid}, was this already removed? ({_network.Connections.Count})" ); return; @@ -268,7 +269,7 @@ public void OnPeerDisconnected(NetPeer peer, DisconnectInfo disconnectInfo) public void OnNetworkError(IPEndPoint endPoint, SocketError socketError) { - Log.Error($"NERR: {socketError} from {endPoint}"); + ApplicationContext.Context.Value?.Logger.LogError($"NERR: {socketError} from {endPoint}"); } public void OnNetworkReceive( @@ -280,14 +281,14 @@ DeliveryMethod deliveryMethod { if (!_connectionIdLookup.TryGetValue(peer.Id, out var connectionId)) { - Log.Warn($"RNIP: {peer} ({channelNumber}, {deliveryMethod})"); + ApplicationContext.Context.Value?.Logger.LogWarning($"RNIP: {peer} ({channelNumber}, {deliveryMethod})"); return; } var genericConnection = _network.FindConnection(connectionId); if (genericConnection is not LiteNetLibConnection connection) { - Log.Warn( + ApplicationContext.Context.Value?.Logger.LogWarning( $"RNCP: {peer} ({channelNumber}, {deliveryMethod}) ({genericConnection?.Guid} / {genericConnection?.GetFullishName()}" ); return; @@ -295,14 +296,14 @@ DeliveryMethod deliveryMethod if (!reader.TryGetByte(out var packetCode)) { - Log.Warn($"No packet code from {peer} / {connection.Guid}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"No packet code from {peer} / {connection.Guid}"); return; } // ReSharper disable once ConvertIfStatementToSwitchStatement if (packetCode > 1) { - Log.Warn($"Invalid packet code from {peer} / {connection.Guid}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Invalid packet code from {peer} / {connection.Guid}"); return; } @@ -323,7 +324,7 @@ DeliveryMethod deliveryMethod } else { - Log.Warn($"Failed to process approval from {peer} / {connection.Guid}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Failed to process approval from {peer} / {connection.Guid}"); } return; @@ -331,7 +332,7 @@ DeliveryMethod deliveryMethod if (!connection.TryProcessInboundMessage(peer, reader, channelNumber, deliveryMethod, out var buffer)) { - Log.Warn($"FPIM: {peer} / {connection.Guid}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"FPIM: {peer} / {connection.Guid}"); return; } @@ -362,12 +363,12 @@ public bool SendUnconnectedPacket(IPEndPoint target, UnconnectedPacket packet) var encryptedPacketData = encryptedPacket.EncryptedData; if (encryptedPacketData == default) { - Log.Debug($"Failed to encrypt data for {packet.GetFullishName()}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Failed to encrypt data for {packet.GetFullishName()}"); return false; } #if DIAGNOSTIC - Log.Debug($"{nameof(SendUnconnectedPacket)} {nameof(encryptedPacketData)}({encryptedPacketData.Length})={Convert.ToHexString(encryptedPacketData)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"{nameof(SendUnconnectedPacket)} {nameof(encryptedPacketData)}({encryptedPacketData.Length})={Convert.ToHexString(encryptedPacketData)}"); #endif NetDataWriter data = new(false, encryptedPacketData.Length + 1); @@ -395,31 +396,31 @@ UnconnectedMessageType messageType var innerPacket = encryptedPacket.InnerPacket; if (innerPacket == default) { - Log.Debug("Inner packet is null."); + ApplicationContext.Context.Value?.Logger.LogDebug("Inner packet is null."); return; } if (innerPacket is not UnconnectedPacket unconnectedPacket) { - Log.Debug($"Inner packet is not of type {typeof(UnconnectedPacket)}: {innerPacket.GetFullishName()}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Inner packet is not of type {typeof(UnconnectedPacket)}: {innerPacket.GetFullishName()}"); return; } if (!_network.Helper.HandlerRegistry.TryGetHandler(innerPacket, out var handlerInstance)) { - Log.Warn($"No handler for {innerPacket.GetFullishName()}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"No handler for {innerPacket.GetFullishName()}"); return; } var packetSender = new LiteNetLibUnconnectedPacketSender(this, remoteEndPoint, _network); if (!handlerInstance.Invoke(packetSender, unconnectedPacket)) { - Log.Warn($"Packet handler failed for {innerPacket.GetFullishName()}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Packet handler failed for {innerPacket.GetFullishName()}"); } } catch (Exception exception) { - Log.Debug(exception); + ApplicationContext.Context.Value?.Logger.LogDebug(exception, $"Failure in {nameof(HandleAsymmetricEncryptedUnconnectedPacket)}"); } } @@ -454,7 +455,7 @@ public void OnNetworkReceiveUnconnected(IPEndPoint remoteEndPoint, NetPacketRead } catch (Exception exception) { - Log.Debug(exception); + ApplicationContext.Context.Value?.Logger.LogDebug(exception, $"Failure in {nameof(OnNetworkReceiveUnconnected)}"); } } @@ -467,7 +468,7 @@ public void OnNetworkLatencyUpdate(NetPeer peer, int latency) } #endif - Log.Verbose($"LTNC {peer} {latency}ms"); + ApplicationContext.Context.Value?.Logger.LogDebug($"LTNC {peer} {latency}ms"); } public void OnConnectionRequest(ConnectionRequest request) @@ -478,7 +479,7 @@ public void OnConnectionRequest(ConnectionRequest request) var deserializedBuffer = MessagePacker.Instance.Deserialize(inboundBuffer); if (deserializedBuffer is not HailPacket hail || !hail.Decrypt(_asymmetricServer)) { - Log.Debug($"Rejecting (bad hail) {request.RemoteEndPoint}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Rejecting (bad hail) {request.RemoteEndPoint}"); response.Put((ushort)400); request.Reject(response); return; @@ -488,20 +489,20 @@ public void OnConnectionRequest(ConnectionRequest request) Debug.Assert(hail.VersionData != null, "hail.VersionData != null"); if (!SharedConstants.VersionData.SequenceEqual(hail.VersionData)) { - Log.Debug($"Rejecting (bad version) {request.RemoteEndPoint}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Rejecting (bad version) {request.RemoteEndPoint}"); response.Put((ushort)400); response.Put(NetworkStatus.VersionMismatch.ToString()); request.Reject(response); return; } - Log.Debug($"hail Time={hail.Adjusted / TimeSpan.TicksPerMillisecond} Offset={hail.Offset / TimeSpan.TicksPerMillisecond} Real={hail.UTC / TimeSpan.TicksPerMillisecond}"); - Log.Debug($"local Time={Timing.Global.Milliseconds} Offset={(long)Timing.Global.MillisecondsOffset} Real={Timing.Global.MillisecondsUtc}"); - Log.Debug($"real delta={(Timing.Global.TicksUtc - hail.UTC) / TimeSpan.TicksPerMillisecond}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"hail Time={hail.Adjusted / TimeSpan.TicksPerMillisecond} Offset={hail.Offset / TimeSpan.TicksPerMillisecond} Real={hail.UTC / TimeSpan.TicksPerMillisecond}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"local Time={Timing.Global.Milliseconds} Offset={(long)Timing.Global.MillisecondsOffset} Real={Timing.Global.MillisecondsUtc}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"real delta={(Timing.Global.TicksUtc - hail.UTC) / TimeSpan.TicksPerMillisecond}"); if (_network.ConnectionCount >= Options.Instance.MaxClientConnections) { - Log.Debug($"Rejecting (full) {request.RemoteEndPoint}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Rejecting (full) {request.RemoteEndPoint}"); response.Put((ushort)503); response.Put(NetworkStatus.ServerFull.ToString()); request.Reject(response); @@ -509,14 +510,14 @@ public void OnConnectionRequest(ConnectionRequest request) } var peer = request.Accept(); - Log.Debug($"NCPing={peer.Ping}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"NCPing={peer.Ping}"); var symmetricKey = RandomNumberGenerator.GetBytes(32); var connection = new LiteNetLibConnection(peer, hail.RsaParameters, hail.SymmetricVersion, symmetricKey); if (!(OnConnectionRequested?.Invoke(this, connection) ?? true)) { - Log.Debug($"Rejecting (ban) {peer} ({connection.Guid})"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Rejecting (ban) {peer} ({connection.Guid})"); response.Put((ushort)403); response.Put(NetworkStatus.Failed.ToString()); peer.Disconnect(response); @@ -525,7 +526,7 @@ public void OnConnectionRequest(ConnectionRequest request) if (!_network.AddConnection(connection)) { - Log.Debug($"Rejecting (error connection map) {peer} ({connection.Guid})"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Rejecting (error connection map) {peer} ({connection.Guid})"); response.Put((ushort)500); response.Put(NetworkStatus.Failed.ToString()); peer.Disconnect(response); @@ -534,7 +535,7 @@ public void OnConnectionRequest(ConnectionRequest request) if (!_connectionIdLookup.TryAdd(peer.Id, connection.Guid)) { - Log.Debug($"Rejecting (error connection id lookup) {peer} ({connection.Guid})"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Rejecting (error connection id lookup) {peer} ({connection.Guid})"); response.Put((ushort)500); response.Put(NetworkStatus.Failed.ToString()); peer.Disconnect(response); @@ -549,8 +550,8 @@ public void OnConnectionRequest(ConnectionRequest request) connectionData.Put((byte)0); connectionData.Put(approvalData); #if DIAGNOSTIC - Log.Debug($"OnConnectionRequest approvalData({approvalData.Length})={Convert.ToHexString(approvalData)}"); - Log.Debug($"OnConnectionRequest connectionData({connectionData.Length})={Convert.ToHexString(connectionData.Data)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"OnConnectionRequest approvalData({approvalData.Length})={Convert.ToHexString(approvalData)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"OnConnectionRequest connectionData({connectionData.Length})={Convert.ToHexString(connectionData.Data)}"); #endif peer.Send(connectionData, DeliveryMethod.ReliableOrdered); @@ -569,6 +570,6 @@ public void OnConnectionRequest(ConnectionRequest request) } ); - Log.Debug($"Approved {peer} ({connection.Guid})"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Approved {peer} ({connection.Guid})"); } } \ No newline at end of file diff --git a/Intersect.Network/LiteNetLib/LiteNetLibLogger.cs b/Intersect.Network/LiteNetLib/LiteNetLibLogger.cs index c3ac5d2191..2d86ff4905 100644 --- a/Intersect.Network/LiteNetLib/LiteNetLibLogger.cs +++ b/Intersect.Network/LiteNetLib/LiteNetLibLogger.cs @@ -1,9 +1,12 @@ -using Intersect.Logging; + +using Intersect.Core; using LiteNetLib; +using Microsoft.Extensions.Logging; namespace Intersect.Network.LiteNetLib; public sealed class LiteNetLibLogger : INetLogger { - public void WriteNet(NetLogLevel level, string str, params object[] args) => Log.Write(level.ToIntersectLogLevel(), str, args); + public void WriteNet(NetLogLevel level, string format, params object[] args) => + ApplicationContext.Context.Value?.Logger.Log(level.ToLogLevel(), format, args); } \ No newline at end of file diff --git a/Intersect.Network/LiteNetLib/LiteNetLibUnconnectedPacketSender.cs b/Intersect.Network/LiteNetLib/LiteNetLibUnconnectedPacketSender.cs index a638d9483e..9a13b07bef 100644 --- a/Intersect.Network/LiteNetLib/LiteNetLibUnconnectedPacketSender.cs +++ b/Intersect.Network/LiteNetLib/LiteNetLibUnconnectedPacketSender.cs @@ -1,6 +1,7 @@ using System.Net; using Intersect.Core; -using Intersect.Logging; +using Microsoft.Extensions.Logging; + namespace Intersect.Network.LiteNetLib; @@ -32,7 +33,7 @@ public bool Send(IPacket packet) return _networkLayerInterface.SendUnconnectedPacket(_endPoint, unconnectedPacket); } - Log.Error($"Expected a {nameof(UnconnectedPacket)} but tried to send a {packet.GetType().FullName}"); + ApplicationContext.Logger.LogError($"Expected a {nameof(UnconnectedPacket)} but tried to send a {packet.GetType().FullName}"); return false; } diff --git a/Intersect.Network/LiteNetLib/NetLogLevelExtensions.cs b/Intersect.Network/LiteNetLib/NetLogLevelExtensions.cs index 5b8c689180..6c8f586dba 100644 --- a/Intersect.Network/LiteNetLib/NetLogLevelExtensions.cs +++ b/Intersect.Network/LiteNetLib/NetLogLevelExtensions.cs @@ -1,18 +1,18 @@ using System.Diagnostics; -using Intersect.Logging; using LiteNetLib; +using Microsoft.Extensions.Logging; namespace Intersect.Network.LiteNetLib; public static class NetLogLevelExtensions { - public static LogLevel ToIntersectLogLevel(this NetLogLevel netLogLevel) => + public static LogLevel ToLogLevel(this NetLogLevel netLogLevel) => netLogLevel switch { - NetLogLevel.Warning => LogLevel.Warn, + NetLogLevel.Warning => LogLevel.Warning, NetLogLevel.Error => LogLevel.Error, NetLogLevel.Trace => LogLevel.Trace, - NetLogLevel.Info => LogLevel.Info, + NetLogLevel.Info => LogLevel.Information, _ => throw new UnreachableException(), }; } \ No newline at end of file diff --git a/Intersect.Server.Core/Core/Bootstrapper.cs b/Intersect.Server.Core/Core/Bootstrapper.cs index 0610546382..0a50b4d978 100644 --- a/Intersect.Server.Core/Core/Bootstrapper.cs +++ b/Intersect.Server.Core/Core/Bootstrapper.cs @@ -3,11 +3,11 @@ using System.Resources; using System.Runtime.InteropServices; using CommandLine; +using Intersect.Core; using Intersect.Factories; using Intersect.GameObjects; using Intersect.GameObjects.Events; using Intersect.GameObjects.Maps; -using Intersect.Logging; using Intersect.Network; using Intersect.Plugins; using Intersect.Plugins.Contexts; @@ -21,6 +21,10 @@ using Intersect.Server.Networking; using Intersect.Threading; using Intersect.Utilities; +using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Events; +using Serilog.Extensions.Logging; namespace Intersect.Server.Core; @@ -58,11 +62,27 @@ public static void Start(params string[] args) Console.WriteLine("Pre-context setup finished."); - var logger = Log.Default; + var executableName = Path.GetFileNameWithoutExtension( + Process.GetCurrentProcess().MainModule?.FileName ?? Assembly.GetExecutingAssembly().GetName().Name + ); + var loggerConfiguration = new LoggerConfiguration().MinimumLevel + .Is(LevelConvert.ToSerilogLevel(Options.Instance.Logging.Level)) + .Enrich.FromLogContext().WriteTo + .Console().WriteTo.File( + Path.Combine( + "logs", + $"{executableName}-{Process.GetCurrentProcess().StartTime:yyyy_MM_dd-HH_mm_ss_fff}.log" + ) + ).WriteTo.File( + Path.Combine("logs", $"errors-{executableName}.log"), + restrictedToMinimumLevel: LogEventLevel.Error + ); + + var logger = new SerilogLoggerFactory(loggerConfiguration.CreateLogger()).CreateLogger("Client"); var packetTypeRegistry = new PacketTypeRegistry(logger, typeof(SharedConstants).Assembly); if (!packetTypeRegistry.TryRegisterBuiltIn()) { - logger.Error("[FATAL] Failed to load built-in packet types."); + logger.LogCritical("[FATAL] Failed to load built-in packet types."); return; } @@ -108,7 +128,7 @@ public static void Start(params string[] args) action.Invoke(); } - Log.Diagnostic("Bootstrapper exited."); + ApplicationContext.Context.Value?.Logger.LogTrace("Bootstrapper exited."); // At this point dbs should be saved and all threads should be killed. Give a message saying that the server has shutdown and to press any key to exit. // Having the message and the console.readline() allows the server to exit properly if the console has crashed, and it allows us to know that the server context has shutdown. @@ -190,8 +210,6 @@ private static bool PreContextSetup(params string[] args) return false; } - Log.Default.Configuration.LogLevel = Options.Instance.Logging.Level; - if (ServerContext.IsDefaultResourceDirectory) { if (!Directory.Exists(Path.Combine(ServerContext.ResourceDirectory, "notifications"))) @@ -436,7 +454,7 @@ private static void ExportDependencies(params string[] args) return; } - Log.Error($"Failed to extract {sqliteFileName} library, terminating startup."); + ApplicationContext.Context.Value?.Logger.LogError($"Failed to extract {sqliteFileName} library, terminating startup."); Environment.Exit(-0x1000); } diff --git a/Intersect.Server.Core/Core/CommandParsing/CommandParserErrorsNamespace.cs b/Intersect.Server.Core/Core/CommandParsing/CommandParserErrorsNamespace.cs index a22d71bff3..2c2cbd78af 100644 --- a/Intersect.Server.Core/Core/CommandParsing/CommandParserErrorsNamespace.cs +++ b/Intersect.Server.Core/Core/CommandParsing/CommandParserErrorsNamespace.cs @@ -1,5 +1,4 @@ using Intersect.Localization; - using Newtonsoft.Json; namespace Intersect.Server.Core.CommandParsing; diff --git a/Intersect.Server.Core/Core/CommandParsing/CommandParserFormattingNamespace.cs b/Intersect.Server.Core/Core/CommandParsing/CommandParserFormattingNamespace.cs index 294cb24922..1e3cf7e244 100644 --- a/Intersect.Server.Core/Core/CommandParsing/CommandParserFormattingNamespace.cs +++ b/Intersect.Server.Core/Core/CommandParsing/CommandParserFormattingNamespace.cs @@ -1,5 +1,4 @@ using Intersect.Localization; - using Newtonsoft.Json; namespace Intersect.Server.Core.CommandParsing; diff --git a/Intersect.Server.Core/Core/ExperimentalFeatures/Experiments.cs b/Intersect.Server.Core/Core/ExperimentalFeatures/Experiments.cs deleted file mode 100644 index a3f28833f4..0000000000 --- a/Intersect.Server.Core/Core/ExperimentalFeatures/Experiments.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Intersect.Core.ExperimentalFeatures; - -using Newtonsoft.Json; - -namespace Intersect.Server.Core.ExperimentalFeatures; - - -public sealed partial class Experiments : CommonExperiments -{ - - private static readonly Guid NamespaceId = Guid.Parse("4a6db511-7d5c-4a23-a096-5d61baa58cd7"); - - static Experiments() - { - Instance = new Experiments(); - Instance.Load(); - } - - private Experiments() - { - PostgreSQL = new ExperimentalFlag(nameof(PostgreSQL), NamespaceId, parentFlag: All); - } - - public static Experiments Instance - { - get => CommonExperiments.Instance; - private set => CommonExperiments.Instance = value; - } - - [JsonProperty( - DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate, - ObjectCreationHandling = ObjectCreationHandling.Reuse - )] - public ExperimentalFlag PostgreSQL { get; private set; } - -} diff --git a/Intersect.Server.Core/Core/MapInstancing/InstanceProcessor.cs b/Intersect.Server.Core/Core/MapInstancing/InstanceProcessor.cs index d3ecabd5dd..d1f9060e34 100644 --- a/Intersect.Server.Core/Core/MapInstancing/InstanceProcessor.cs +++ b/Intersect.Server.Core/Core/MapInstancing/InstanceProcessor.cs @@ -1,6 +1,8 @@ +using Intersect.Core; using Intersect.Server.Core.MapInstancing.Controllers; using Intersect.Server.Entities; using Intersect.Server.Maps; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Core.MapInstancing; public static class InstanceProcessor @@ -24,7 +26,7 @@ private static void CleanupOrphanedControllers(IEnumerable activeInstanceI foreach (var id in processingInstances) { InstanceControllers.Remove(id); - Logging.Log.Debug($"Removing instance controller {id}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Removing instance controller {id}"); } } diff --git a/Intersect.Server.Core/Core/ServerContext.cs b/Intersect.Server.Core/Core/ServerContext.cs index eecfa00a9d..143e6add9c 100644 --- a/Intersect.Server.Core/Core/ServerContext.cs +++ b/Intersect.Server.Core/Core/ServerContext.cs @@ -1,5 +1,4 @@ using Intersect.Core; -using Intersect.Logging; using Intersect.Network; using Intersect.Server.Core.Services; using Intersect.Server.Database; @@ -13,6 +12,7 @@ using Intersect.Plugins.Interfaces; using Intersect.Rsa; using Intersect.Server.Database.PlayerData.Players; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Core; @@ -37,7 +37,7 @@ internal partial class ServerContext : ApplicationContext(); foreach (var user in Database.PlayerData.User.OnlineList.ToArray()) @@ -122,7 +122,7 @@ protected override void Dispose(bool disposing) Task.WaitAll(savingTasks.ToArray()); - Log.Info("Saving loaded guilds...."); + ApplicationContext.Context.Value?.Logger.LogInformation("Saving loaded guilds...."); savingTasks.Clear(); //Should we send out guild updates? @@ -134,7 +134,7 @@ protected override void Dispose(bool disposing) Task.WaitAll(savingTasks.ToArray()); // TODO: This probably also needs to not be a global, but will require more work to clean up. - Log.Info("Online users/players saved." + $" ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation("Online users/players saved." + $" ({stopwatch.ElapsedMilliseconds}ms)"); //Disconnect All Clients @@ -157,7 +157,7 @@ protected override void Dispose(bool disposing) if (ThreadLogic?.IsAlive ?? false) { - Log.Info("Shutting down the logic thread..." + $" ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation("Shutting down the logic thread..." + $" ({stopwatch.ElapsedMilliseconds}ms)"); if (!ThreadLogic.Join(10000)) { try @@ -166,7 +166,7 @@ protected override void Dispose(bool disposing) } catch (ThreadAbortException threadAbortException) { - Log.Error(threadAbortException, $"{nameof(ThreadLogic)} aborted."); + ApplicationContext.Context.Value?.Logger.LogError(threadAbortException, $"{nameof(ThreadLogic)} aborted."); } } } @@ -174,9 +174,9 @@ protected override void Dispose(bool disposing) PacketHelper.HandlerRegistry.Dispose(); } - Log.Info("Base dispose." + $" ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation("Base dispose." + $" ({stopwatch.ElapsedMilliseconds}ms)"); base.Dispose(disposing); - Log.Info("Finished disposing server context." + $" ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation("Finished disposing server context." + $" ({stopwatch.ElapsedMilliseconds}ms)"); if (DisposeWithoutExiting) { @@ -248,7 +248,7 @@ protected virtual void InternalStartNetworking() if (!Network.Listen()) { - Log.Error("An error occurred while attempting to connect."); + ApplicationContext.Context.Value?.Logger.LogError("An error occurred while attempting to connect."); } else { diff --git a/Intersect.Server.Core/Core/ServerContextFactory.cs b/Intersect.Server.Core/Core/ServerContextFactory.cs index 83a3c3467a..e7cae87b28 100644 --- a/Intersect.Server.Core/Core/ServerContextFactory.cs +++ b/Intersect.Server.Core/Core/ServerContextFactory.cs @@ -1,10 +1,11 @@ -using Intersect.Logging; + using Intersect.Plugins.Interfaces; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Core; internal delegate IServerContext ServerContextFactory( ServerCommandLineOptions startupOptions, - Logger logger, + ILogger logger, IPacketHelper packetHelper ); \ No newline at end of file diff --git a/Intersect.Server.Core/Database/DataMigrations/Sqlite/SqliteNetCoreGuidPatch.cs b/Intersect.Server.Core/Database/DataMigrations/Sqlite/SqliteNetCoreGuidPatch.cs index 5d4daa8cc6..7f1623ed57 100644 --- a/Intersect.Server.Core/Database/DataMigrations/Sqlite/SqliteNetCoreGuidPatch.cs +++ b/Intersect.Server.Core/Database/DataMigrations/Sqlite/SqliteNetCoreGuidPatch.cs @@ -1,10 +1,11 @@ using System.Diagnostics; using Dapper; using Intersect.Config; -using Intersect.Logging; +using Intersect.Core; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.Extensions.Logging; using SqlKata.Execution; namespace Intersect.Server.Database.DataMigrations.Sqlite; @@ -217,7 +218,7 @@ public static void ApplyTo(TContext context) { if (skippedKeys.Contains(columnName)) { - Log.Warn($"Dropping '{columnName}' as a query constraint while updating '{entityTable}'"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Dropping '{columnName}' as a query constraint while updating '{entityTable}'"); continue; } @@ -226,9 +227,9 @@ public static void ApplyTo(TContext context) var result = query.Update(convertedRow, transaction: transaction); - if (Log.Default.Configuration.LogLevel >= LogLevel.Debug) + if (Debugger.IsAttached) { - Log.Debug($"Processed row {convertedRowCount++}/{numberOfRows} in '{entityTable}' (segment {segmentConvertedRowCount++}/{convertedRows.Length}), {result} rows changed."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Processed row {convertedRowCount++}/{numberOfRows} in '{entityTable}' (segment {segmentConvertedRowCount++}/{convertedRows.Length}), {result} rows changed."); } } catch @@ -241,22 +242,22 @@ public static void ApplyTo(TContext context) transaction.Commit(); dbConnection.Close(); - if (Log.Default.Configuration.LogLevel >= LogLevel.Debug) + if (Debugger.IsAttached) { - Log.Debug( + ApplicationContext.Context.Value?.Logger.LogDebug( $"Completed updating segment {segmentNumber}/{numberOfSegments} in {(DateTime.UtcNow - startTimeSegment).TotalMilliseconds}ms ('{entityTable}', {convertedRows.Length} rows updated)" ); } } else { - Log.Debug($"Skipped segment {segmentNumber}/{numberOfSegments} because it has no changed rows ('{entityTable}')"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Skipped segment {segmentNumber}/{numberOfSegments} because it has no changed rows ('{entityTable}')"); } } - Log.Verbose($"Completed updating table in {(DateTime.UtcNow - startTimeTable).TotalMilliseconds}ms ('{entityTable}', {convertedRowCount} rows updated)"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Completed updating table in {(DateTime.UtcNow - startTimeTable).TotalMilliseconds}ms ('{entityTable}', {convertedRowCount} rows updated)"); } - Log.Verbose($"Completed updating database in {(DateTime.UtcNow - startTimeDatabase).TotalMilliseconds}ms"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Completed updating database in {(DateTime.UtcNow - startTimeDatabase).TotalMilliseconds}ms"); } } diff --git a/Intersect.Server.Core/Database/DataMigrations/UserVariablePopulateNewColumnId.cs b/Intersect.Server.Core/Database/DataMigrations/UserVariablePopulateNewColumnId.cs index 5814f1da7d..a189a7e8af 100644 --- a/Intersect.Server.Core/Database/DataMigrations/UserVariablePopulateNewColumnId.cs +++ b/Intersect.Server.Core/Database/DataMigrations/UserVariablePopulateNewColumnId.cs @@ -1,8 +1,9 @@ using System.Diagnostics; using Intersect.Config; -using Intersect.Logging; +using Intersect.Core; using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using SqlKata.Execution; using SqlKata.Extensions; @@ -39,7 +40,7 @@ public void Up(DatabaseContextOptions databaseContextOptions) if (numberOfTables < 1) { - Log.Warn($"No 'User_Variables' table."); + ApplicationContext.Context.Value?.Logger.LogWarning($"No 'User_Variables' table."); return; } @@ -81,9 +82,9 @@ public void Up(DatabaseContextOptions databaseContextOptions) var result = query.Update(convertedRow, transaction: transaction); - if (Log.Default.Configuration.LogLevel >= LogLevel.Debug) + if (Debugger.IsAttached) { - Log.Debug( + ApplicationContext.Context.Value?.Logger.LogDebug( $"Processed row {++convertedRowCount}/{numberOfRows} in '{tableName}' (segment {indexInSegment++}/{rowsToConvert.Length}), {result} rows changed." ); } @@ -98,15 +99,15 @@ public void Up(DatabaseContextOptions databaseContextOptions) transaction.Commit(); dbConnection.Close(); - if (Log.Default.Configuration.LogLevel >= LogLevel.Debug) + if (Debugger.IsAttached) { - Log.Debug( + ApplicationContext.Context.Value?.Logger.LogDebug( $"Completed updating segment {segmentNumber}/{numberOfSegments} in {(DateTime.UtcNow - startTimeSegment).TotalMilliseconds}ms ('{tableName}', {rowsToConvert.Length} rows updated)" ); } } - Log.Verbose($"Completed updating table in {(DateTime.UtcNow - startTimeTable).TotalMilliseconds}ms ('{tableName}', {convertedRowCount} rows updated)"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Completed updating table in {(DateTime.UtcNow - startTimeTable).TotalMilliseconds}ms ('{tableName}', {convertedRowCount} rows updated)"); } private sealed class PseudoUserVariable diff --git a/Intersect.Server.Core/Database/DatabaseTypeMigrationService.cs b/Intersect.Server.Core/Database/DatabaseTypeMigrationService.cs index 047025bc4b..cef78bcdb2 100644 --- a/Intersect.Server.Core/Database/DatabaseTypeMigrationService.cs +++ b/Intersect.Server.Core/Database/DatabaseTypeMigrationService.cs @@ -1,10 +1,11 @@ using System.Reflection; +using Intersect.Core; using Intersect.Extensions; -using Intersect.Logging; -using Intersect.Reflection; +using Intersect.Framework.Reflection; using Microsoft.EntityFrameworkCore; using Intersect.Server.Localization; using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Database; @@ -31,11 +32,11 @@ private async Task CheckIfNotEmpty(DatabaseContextOptions option } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Failed to migrate {ContextType}", typeof(TContext).GetName(qualified: true)); return true; } - Log.Error(Strings.Migration.MySqlNotEmpty); + ApplicationContext.Context.Value?.Logger.LogError(Strings.Migration.MySqlNotEmpty); return true; } @@ -159,7 +160,7 @@ public async Task TryMigrate(DatabaseContextOptions fromOptions, foreach (var dbSetInfo in sortedDbSetInfos) { - Log.Info(Strings.Migration.MigratingDbSet.ToString(dbSetInfo.Name)); + ApplicationContext.Context.Value?.Logger.LogInformation(Strings.Migration.MigratingDbSet.ToString(dbSetInfo.Name)); try { @@ -174,7 +175,12 @@ public async Task TryMigrate(DatabaseContextOptions fromOptions, } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Failed to migrate DBSet {DBSetName} in {ContextType}", + dbSetInfo.Name, + dbSetInfo.DeclaringType?.GetName(qualified: true) + ); throw; } } @@ -183,7 +189,11 @@ public async Task TryMigrate(DatabaseContextOptions fromOptions, } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error migrating {ContextType}", + typeof(TContext).GetName(qualified: true) + ); throw; } } @@ -232,7 +242,12 @@ PropertyInfo dbSetInfo } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error migrating DbSet<{T}> in {ContextType}", + typeof(T).GetName(qualified: true), + typeof(TContext).GetName(qualified: true) + ); throw; } } diff --git a/Intersect.Server.Core/Database/DbInterface.cs b/Intersect.Server.Core/Database/DbInterface.cs index 5a46895d00..b9c831b79c 100644 --- a/Intersect.Server.Core/Database/DbInterface.cs +++ b/Intersect.Server.Core/Database/DbInterface.cs @@ -1,5 +1,4 @@ using System.Collections.Concurrent; -using System.Collections.Immutable; using System.Data.Common; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; @@ -9,6 +8,7 @@ using Amib.Threading; using Intersect.Collections; using Intersect.Config; +using Intersect.Core; using Intersect.Enums; using Intersect.Framework.Core.GameObjects.Variables; using Intersect.Framework.Reflection; @@ -17,8 +17,6 @@ using Intersect.GameObjects.Events; using Intersect.GameObjects.Maps; using Intersect.GameObjects.Maps.MapList; -using Intersect.Logging; -using Intersect.Logging.Output; using Intersect.Models; using Intersect.Server.Core; using Intersect.Server.Database.GameData; @@ -31,12 +29,10 @@ using Intersect.Server.Localization; using Intersect.Server.Maps; using Intersect.Server.Networking; - using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; - +using Microsoft.Extensions.Logging; using MySqlConnector; -using LogLevel = Intersect.Logging.LogLevel; namespace Intersect.Server.Database; @@ -64,9 +60,9 @@ public static partial class DbInterface private static string PlayersDbFilename => Path.Combine(ServerContext.ResourceDirectory, "playerdata.db"); - private static Logger _gameDatabaseLogger { get; set; } + private static ILogger _gameDatabaseLogger { get; set; } - private static Logger _playerDatabaseLogger { get; set; } + private static ILogger _playerDatabaseLogger { get; set; } public static Dictionary ServerVariableEventTextLookup = new(); @@ -161,30 +157,12 @@ public static void InitializeDbLoggers() { if (Options.Instance.GameDatabase.LogLevel > LogLevel.None) { - _gameDatabaseLogger = new Logger( - new LogConfiguration - { - Tag = "GAMEDB", - LogLevel = Options.Instance.GameDatabase.LogLevel, - Outputs = ImmutableList.Create( - new FileOutput(Log.SuggestFilename(null, "gamedb"), LogLevel.Debug) - ) - } - ); + _gameDatabaseLogger = new IntersectLoggerFactory(nameof(GameContext)).CreateLogger(); } if (Options.Instance.PlayerDatabase.LogLevel > LogLevel.None) { - _playerDatabaseLogger = new Logger( - new LogConfiguration - { - Tag = "PLAYERDB", - LogLevel = Options.Instance.PlayerDatabase.LogLevel, - Outputs = ImmutableList.Create( - new FileOutput(Log.SuggestFilename(null, "playerdb"), LogLevel.Debug) - ) - } - ); + _playerDatabaseLogger = new IntersectLoggerFactory(nameof(PlayerContext)).CreateLogger(); } } @@ -250,18 +228,18 @@ private static void ProcessMigrations(TContext context) { if (!context.HasPendingMigrations) { - Log.Verbose($"No pending migrations for {context.GetType().GetName(qualified: true)}, skipping..."); + ApplicationContext.Context.Value?.Logger.LogDebug($"No pending migrations for {context.GetType().GetName(qualified: true)}, skipping..."); return; } - Log.Verbose($"Pending schema migrations for {typeof(TContext).Name}:\n\t{string.Join("\n\t", context.PendingSchemaMigrations)}"); - Log.Verbose($"Pending data migrations for {typeof(TContext).Name}:\n\t{string.Join("\n\t", context.PendingDataMigrationNames)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Pending schema migrations for {typeof(TContext).Name}:\n\t{string.Join("\n\t", context.PendingSchemaMigrations)}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Pending data migrations for {typeof(TContext).Name}:\n\t{string.Join("\n\t", context.PendingDataMigrationNames)}"); var migrationScheduler = new MigrationScheduler(context); - Log.Verbose("Scheduling pending migrations..."); + ApplicationContext.Context.Value?.Logger.LogDebug("Scheduling pending migrations..."); migrationScheduler.SchedulePendingMigrations(); - Log.Verbose("Applying scheduled migrations..."); + ApplicationContext.Context.Value?.Logger.LogDebug("Applying scheduled migrations..."); migrationScheduler.ApplyScheduledMigrations(); var remainingPendingSchemaMigrations = context.PendingSchemaMigrations.ToList(); @@ -274,7 +252,7 @@ private static void ProcessMigrations(TContext context) private static bool EnsureUpdated(IServerContext serverContext) { var gameDatabaseOptions = Options.Instance.GameDatabase; - Log.Info($"Creating game context using {gameDatabaseOptions.Type}..."); + ApplicationContext.Context.Value?.Logger.LogInformation($"Creating game context using {gameDatabaseOptions.Type}..."); using var gameContext = GameContext.Create(new DatabaseContextOptions { ConnectionStringBuilder = gameDatabaseOptions.Type.CreateConnectionStringBuilder( @@ -288,7 +266,7 @@ private static bool EnsureUpdated(IServerContext serverContext) }); var playerDatabaseOptions = Options.Instance.PlayerDatabase; - Log.Info($"Creating player context using {playerDatabaseOptions.Type}..."); + ApplicationContext.Context.Value?.Logger.LogInformation($"Creating player context using {playerDatabaseOptions.Type}..."); using var playerContext = PlayerContext.Create(new DatabaseContextOptions { ConnectionStringBuilder = playerDatabaseOptions.Type.CreateConnectionStringBuilder( @@ -302,7 +280,7 @@ private static bool EnsureUpdated(IServerContext serverContext) }); var loggingDatabaseOptions = Options.Instance.LoggingDatabase; - Log.Info($"Creating logging context using {loggingDatabaseOptions.Type}..."); + ApplicationContext.Context.Value?.Logger.LogInformation($"Creating logging context using {loggingDatabaseOptions.Type}..."); using var loggingContext = LoggingContext.Create(new DatabaseContextOptions { ConnectionStringBuilder = loggingDatabaseOptions.Type.CreateConnectionStringBuilder( @@ -357,7 +335,9 @@ private static bool EnsureUpdated(IServerContext serverContext) if (serverContext.StartupOptions.MigrateAutomatically) { Console.WriteLine(Strings.Database.MigratingAutomatically); - Log.Default.Write("Skipping user prompt for database migration..."); + ApplicationContext.Context.Value?.Logger.LogInformation( + "Skipping user prompt for database migration..." + ); } else { @@ -531,7 +511,12 @@ public static Player GetUserCharacter(User user, Guid playerId, bool explicitLoa catch (Exception exception) { Debugger.Break(); - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Failed to load relationships for user {UserId}'s player {PlayerId}", + user.Id, + playerId + ); throw new Exception($"Error during explicit load of player {BitConverter.ToString(playerId.ToByteArray()).Replace("-", string.Empty)}", exception); } @@ -575,7 +560,11 @@ public static bool TryRegister( } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error while registering '{Username}'", + username + ); user = default; return false; } @@ -893,9 +882,13 @@ private static void LoadGameObjects(GameObjectType gameObjectType) } } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error while loading game objects of type {GameObjectType}", + gameObjectType + ); throw; } } @@ -1133,9 +1126,13 @@ public static IDatabaseObject AddGameObject(GameObjectType gameObjectType, IData return dbObj; } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error adding a {GameObjectType}", + gameObjectType + ); throw; } } @@ -1272,9 +1269,15 @@ public static void DeleteGameObject(IDatabaseObject gameObject) context.SaveChanges(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error deleting {GameObjectType} {GameObjectId} '{GameObjectName}'", + gameObject.Type, + gameObject.Id, + gameObject.Name + ); throw; } } @@ -1412,9 +1415,15 @@ public static void SaveGameObject(IDatabaseObject gameObject) context.SaveChanges(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error saving {GameObjectType} {GameObjectId} '{GameObjectName}'", + gameObject.Type, + gameObject.Id, + gameObject.Name + ); throw; } } @@ -1693,9 +1702,9 @@ private static void LoadMapFolders() } } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error loading map folders"); throw; } @@ -1722,9 +1731,9 @@ public static void SaveMapList() context.SaveChanges(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error saving map list"); throw; } } @@ -1750,9 +1759,9 @@ private static void LoadTime() } Time.Init(); } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error loading time objects"); throw; } } @@ -1768,9 +1777,9 @@ public static void SaveTime() context.SaveChanges(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error saving time objects"); throw; } } @@ -1910,7 +1919,11 @@ public static void HandleMigrationCommand() } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error processing migration for {SelectedContextType}", + selectedContextType + ); throw; } } @@ -2022,7 +2035,7 @@ public static async Task Migrate(DatabaseOptions fromDatabaseOptions, } catch (Exception exception) { - Log.Error(Strings.Migration.MySqlConnectionError.ToString(exception)); + ApplicationContext.Context.Value?.Logger.LogError(Strings.Migration.MySqlConnectionError.ToString(exception)); Console.WriteLine(); Console.WriteLine(Strings.Migration.MySqlTryAgain); var input = Console.ReadLine(); @@ -2040,7 +2053,7 @@ public static async Task Migrate(DatabaseOptions fromDatabaseOptions, continue; } - Log.Info(Strings.Migration.MigrationCanceled); + ApplicationContext.Context.Value?.Logger.LogInformation(Strings.Migration.MigrationCanceled); return; } } @@ -2073,13 +2086,13 @@ public static async Task Migrate(DatabaseOptions fromDatabaseOptions, { // If it does, check if it is OK to overwrite Console.WriteLine(); - Log.Error(Strings.Migration.DatabaseFileAlreadyExists.ToString(dbFileName)); + ApplicationContext.Context.Value?.Logger.LogError(Strings.Migration.DatabaseFileAlreadyExists.ToString(dbFileName)); var input = Console.ReadLine(); var key = input.Length > 0 ? input[0] : ' '; Console.WriteLine(); if (key.ToString() != Strings.Migration.ConfirmCharacter) { - Log.Info(Strings.Migration.MigrationCanceled); + ApplicationContext.Context.Value?.Logger.LogInformation(Strings.Migration.MigrationCanceled); return; } @@ -2104,7 +2117,7 @@ public static async Task Migrate(DatabaseOptions fromDatabaseOptions, } // Shut down server, start migration. - Log.Info(Strings.Migration.StoppingServer); + ApplicationContext.Context.Value?.Logger.LogInformation(Strings.Migration.StoppingServer); //This variable will end the server loop and save any pending changes ServerContext.Instance.DisposeWithoutExiting = true; @@ -2115,7 +2128,7 @@ public static async Task Migrate(DatabaseOptions fromDatabaseOptions, Thread.Sleep(100); } - Log.Info(Strings.Migration.StartingMigration); + ApplicationContext.Context.Value?.Logger.LogInformation(Strings.Migration.StartingMigration); var migrationService = new DatabaseTypeMigrationService(); if (await migrationService.TryMigrate(fromContextOptions, toContextOptions)) { @@ -2138,13 +2151,13 @@ public static async Task Migrate(DatabaseOptions fromDatabaseOptions, Options.SaveToDisk(); - Log.Info(Strings.Migration.MigrationComplete); + ApplicationContext.Context.Value?.Logger.LogInformation(Strings.Migration.MigrationComplete); Bootstrapper.Context.WaitForConsole(); ServerContext.Exit(0); } else { - Log.Error($"Error migrating context type: {typeof(TContext).FullName}"); + ApplicationContext.Context.Value?.Logger.LogError($"Error migrating context type: {typeof(TContext).FullName}"); ServerContext.Exit(1); } } diff --git a/Intersect.Server.Core/Database/DbLogger.cs b/Intersect.Server.Core/Database/DbLogger.cs deleted file mode 100644 index d605ba71be..0000000000 --- a/Intersect.Server.Core/Database/DbLogger.cs +++ /dev/null @@ -1,65 +0,0 @@ -using Microsoft.Extensions.Logging; - -namespace Intersect.Server.Database; - -public partial class DbLogger : ILogger -{ - private readonly Intersect.Logging.Logger _intersectLogger; - - public DbLogger(Intersect.Logging.Logger intersectLogger) - { - _intersectLogger = intersectLogger; - } - - public IDisposable BeginScope(TState state) => null; - - public bool IsEnabled(LogLevel logLevel) => true; - - public void Log( - LogLevel logLevel, - EventId eventId, - TState state, - Exception exception, - Func formatter - ) - { - if (!IsEnabled(logLevel)) - { - return; - } - - var msg = $"{eventId.Id} - {formatter(state, exception)}"; - switch (logLevel) - { - case LogLevel.Trace: - _intersectLogger.Trace(msg); - break; - - case LogLevel.Debug: - _intersectLogger.Debug(msg); - break; - - case LogLevel.Information: - _intersectLogger.Info(msg); - break; - - case LogLevel.Warning: - _intersectLogger.Warn(msg); - break; - - case LogLevel.Error: - _intersectLogger.Error(msg); - break; - - case LogLevel.Critical: - _intersectLogger.Error(msg); - break; - - case LogLevel.None: - break; - - default: - throw new ArgumentOutOfRangeException(nameof(logLevel), logLevel, null); - } - } -} \ No newline at end of file diff --git a/Intersect.Server.Core/Database/DbLoggerProvider.cs b/Intersect.Server.Core/Database/DbLoggerProvider.cs deleted file mode 100644 index ec2107ebb6..0000000000 --- a/Intersect.Server.Core/Database/DbLoggerProvider.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.Extensions.Logging; - -namespace Intersect.Server.Database; - -public sealed partial class DbLoggerProvider : ILoggerProvider -{ - private readonly Intersect.Logging.Logger _intersectLogger; - - private DbLogger? _logger; - - public DbLoggerProvider(Intersect.Logging.Logger intersectLogger) - { - _intersectLogger = intersectLogger; - } - - public ILogger CreateLogger(string categoryName) => _logger ??= new DbLogger(_intersectLogger); - - public void Dispose() - { - GC.SuppressFinalize(this); - _logger = default; - } -} \ No newline at end of file diff --git a/Intersect.Server.Core/Database/DbUpdateConcurrencyExceptionExtensions.cs b/Intersect.Server.Core/Database/DbUpdateConcurrencyExceptionExtensions.cs index 1f752aae0b..e5d8dc11dc 100644 --- a/Intersect.Server.Core/Database/DbUpdateConcurrencyExceptionExtensions.cs +++ b/Intersect.Server.Core/Database/DbUpdateConcurrencyExceptionExtensions.cs @@ -1,8 +1,8 @@ using System.Text; - -using Intersect.Logging; +using Intersect.Core; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Database; @@ -31,6 +31,6 @@ public static void LogError(this DbUpdateConcurrencyException concurrencyExcepti .AppendLine() .AppendLine(); } - Log.Error(concurrencyErrors.ToString()); + ApplicationContext.Context.Value?.Logger.LogError(concurrencyErrors.ToString()); } } diff --git a/Intersect.Server.Core/Database/GameData/IGameContext.cs b/Intersect.Server.Core/Database/GameData/IGameContext.cs index 6ab99d0a61..ad467c5e84 100644 --- a/Intersect.Server.Core/Database/GameData/IGameContext.cs +++ b/Intersect.Server.Core/Database/GameData/IGameContext.cs @@ -4,7 +4,6 @@ using Intersect.GameObjects.Events; using Intersect.GameObjects.Maps.MapList; using Intersect.Server.Maps; - using Microsoft.EntityFrameworkCore; namespace Intersect.Server.Database.GameData; diff --git a/Intersect.Server.Core/Database/GameData/Migrations/Beta6Migration.cs b/Intersect.Server.Core/Database/GameData/Migrations/Beta6Migration.cs index ddbaa0d5b7..2e0c0fa692 100644 --- a/Intersect.Server.Core/Database/GameData/Migrations/Beta6Migration.cs +++ b/Intersect.Server.Core/Database/GameData/Migrations/Beta6Migration.cs @@ -1,14 +1,11 @@ using System.IO.Compression; - using Intersect.Enums; using Intersect.Framework.Core.Serialization; using Intersect.GameObjects.Events; using Intersect.GameObjects.Events.Commands; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; - using MySqlConnector; - using Newtonsoft.Json; using Newtonsoft.Json.Linq; using MapAttribute = Intersect.GameObjects.Maps.MapAttribute; diff --git a/Intersect.Server.Core/Database/GameData/Migrations/FixQuestTaskCompletionEventsMigration.cs b/Intersect.Server.Core/Database/GameData/Migrations/FixQuestTaskCompletionEventsMigration.cs index 26fe820243..656aaef7e2 100644 --- a/Intersect.Server.Core/Database/GameData/Migrations/FixQuestTaskCompletionEventsMigration.cs +++ b/Intersect.Server.Core/Database/GameData/Migrations/FixQuestTaskCompletionEventsMigration.cs @@ -1,5 +1,6 @@ -using Intersect.Logging; +using Intersect.Core; using Intersect.GameObjects.Events; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Database.GameData.Migrations; @@ -13,7 +14,7 @@ public static void Run(GameContext context) public static void FixQuestTaskCompletionEvents(GameContext context) { - Log.Info("Checking for broken Quest Task Completion Events, this process might take several minutes depending on your quest count!"); + ApplicationContext.Context.Value?.Logger.LogInformation("Checking for broken Quest Task Completion Events, this process might take several minutes depending on your quest count!"); // Go through each and every quest to check if all the tasks have valid events. foreach (var quest in context.Quests) @@ -34,14 +35,14 @@ public static void FixQuestTaskCompletionEvents(GameContext context) EventBase.Lookup.Set(ev.Id, ev); task.CompletionEventId = task.Id; - Log.Info($"Fixed quest {quest.Name} ({quest.Id}) task {task.Id}, created new event {task.Id}."); + ApplicationContext.Context.Value?.Logger.LogInformation($"Fixed quest {quest.Name} ({quest.Id}) task {task.Id}, created new event {task.Id}."); } // if the Event ID is incorrect but we CAN find the event, link it! else if (incorrectEventId && foundEvent != null) { task.CompletionEventId = foundEvent.Id; - Log.Info($"Fixed quest {quest.Name} ({quest.Id}) task {task.Id}, linked up old event {foundEvent.Id}."); + ApplicationContext.Context.Value?.Logger.LogInformation($"Fixed quest {quest.Name} ({quest.Id}) task {task.Id}, linked up old event {foundEvent.Id}."); } } } diff --git a/Intersect.Server.Core/Database/IntersectDbContext.cs b/Intersect.Server.Core/Database/IntersectDbContext.cs index 7a2a2052b4..ac3884d1a1 100644 --- a/Intersect.Server.Core/Database/IntersectDbContext.cs +++ b/Intersect.Server.Core/Database/IntersectDbContext.cs @@ -3,8 +3,8 @@ using System.Diagnostics; using System.Text; using Intersect.Config; +using Intersect.Core; using Intersect.Framework.Reflection; -using Intersect.Logging; using Intersect.Server.Core; #if DIAGNOSTIC using Intersect.Server.Database.PlayerData; @@ -15,6 +15,7 @@ using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Database; @@ -213,13 +214,13 @@ public override int SaveChanges(bool acceptAllChangesOnSuccess) try { #if DEBUG - Log.Debug($"DBOP-A SaveChanges({acceptAllChangesOnSuccess}) #{currentExecutionId}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"DBOP-A SaveChanges({acceptAllChangesOnSuccess}) #{currentExecutionId}"); #endif var rowsChanged = base.SaveChanges(acceptAllChangesOnSuccess); #if DEBUG - Log.Debug($"DBOP-B SaveChanges({acceptAllChangesOnSuccess}) #{currentExecutionId}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"DBOP-B SaveChanges({acceptAllChangesOnSuccess}) #{currentExecutionId}"); #endif return rowsChanged; @@ -283,11 +284,11 @@ public override int SaveChanges(bool acceptAllChangesOnSuccess) concurrencyErrors.AppendLine(Environment.StackTrace); - Log.Error(concurrencyException, $"Jackpot! Concurrency Bug For {string.Join(", ", entityTypeNames)} {suffix}"); - Log.Error(concurrencyErrors.ToString()); + ApplicationContext.Context.Value?.Logger.LogError(concurrencyException, $"Jackpot! Concurrency Bug For {string.Join(", ", entityTypeNames)} {suffix}"); + ApplicationContext.Context.Value?.Logger.LogError(concurrencyErrors.ToString()); #if DEBUG - Log.Debug($"DBOP-C SaveChanges({acceptAllChangesOnSuccess}) #{currentExecutionId}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"DBOP-C SaveChanges({acceptAllChangesOnSuccess}) #{currentExecutionId}"); #endif if (ContextOptions.KillServerOnConcurrencyException) @@ -298,7 +299,7 @@ public override int SaveChanges(bool acceptAllChangesOnSuccess) } else { - Log.Error($"{nameof(DbUpdateConcurrencyException)} occurred, please review the logs for more information."); + ApplicationContext.Context.Value?.Logger.LogError($"{nameof(DbUpdateConcurrencyException)} occurred, please review the logs for more information."); } return -1; diff --git a/Intersect.Server.Core/Database/IntersectLoggerFactory.cs b/Intersect.Server.Core/Database/IntersectLoggerFactory.cs index 5e9d31df80..b2b5b11238 100644 --- a/Intersect.Server.Core/Database/IntersectLoggerFactory.cs +++ b/Intersect.Server.Core/Database/IntersectLoggerFactory.cs @@ -1,51 +1,45 @@ -using System.Collections.Immutable; using System.Diagnostics; +using Intersect.Core; using Intersect.Framework.Reflection; -using Intersect.Logging; -using Intersect.Logging.Formatting; -using Intersect.Logging.Output; using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Core; +using Serilog.Events; +using Serilog.Extensions.Logging; using ILogger = Microsoft.Extensions.Logging.ILogger; -using IntersectLogLevel = Intersect.Logging.LogLevel; namespace Intersect.Server.Database; internal sealed class IntersectLoggerFactory : ILoggerFactory { - private static readonly Dictionary> _cachedOutputs = new(); + private static readonly Dictionary LoggersByName = new(); - private readonly DbLoggerProvider _loggerProvider; + private readonly ILoggerFactory _loggerFactory; internal IntersectLoggerFactory(string name) { - if (!_cachedOutputs.TryGetValue(name, out var outputs)) + if (!LoggersByName.TryGetValue(name, out var logger)) { - outputs = ImmutableArray.Create( - new FileOutput(Log.SuggestFilename(prefix: $"db-{name}-")), - new FileOutput(Log.SuggestFilename(prefix: $"db_errors-{name}-"), IntersectLogLevel.Error), - new ConciseConsoleOutput(Debugger.IsAttached ? IntersectLogLevel.Warn : IntersectLogLevel.Error) - ); - _cachedOutputs[name] = outputs; + var configuration = new LoggerConfiguration().Enrich.FromLogContext().WriteTo + .Console(restrictedToMinimumLevel: Debugger.IsAttached ? LogEventLevel.Warning : LogEventLevel.Error) + .WriteTo.File(path: $"db-{name}.log").WriteTo.File( + path: $"db-errors-{name}.log", + restrictedToMinimumLevel: LogEventLevel.Error + ); + LoggersByName[name] = configuration.CreateLogger(); } - _loggerProvider = new DbLoggerProvider( - new Logger( - new LogConfiguration - { - Formatters = ImmutableList.Create(new DefaultFormatter()), - LogLevel = IntersectLogLevel.Debug, - Outputs = outputs, - } - ) - ); + _loggerFactory = new SerilogLoggerFactory(logger); } public void AddProvider(ILoggerProvider provider) { - Log.Warn($"Tried to add provider but this is not implemented: {provider.GetFullishName()}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Tried to add provider but this is not implemented: {provider.GetFullishName()}"); } - public ILogger CreateLogger(string categoryName) => _loggerProvider.CreateLogger(categoryName); + public ILogger CreateLogger() => _loggerFactory.CreateLogger(); + + public ILogger CreateLogger(string categoryName) => _loggerFactory.CreateLogger(categoryName); public void Dispose() { diff --git a/Intersect.Server.Core/Database/Logging/ILoggingContext.cs b/Intersect.Server.Core/Database/Logging/ILoggingContext.cs index 6ec2a51b5b..64d41f92aa 100644 --- a/Intersect.Server.Core/Database/Logging/ILoggingContext.cs +++ b/Intersect.Server.Core/Database/Logging/ILoggingContext.cs @@ -1,5 +1,4 @@ using Intersect.Server.Database.Logging.Entities; - using Microsoft.EntityFrameworkCore; namespace Intersect.Server.Database.Logging; diff --git a/Intersect.Server.Core/Database/Logging/LoggingContext.cs b/Intersect.Server.Core/Database/Logging/LoggingContext.cs index 1f2994ff2b..0c7bfb4e85 100644 --- a/Intersect.Server.Core/Database/Logging/LoggingContext.cs +++ b/Intersect.Server.Core/Database/Logging/LoggingContext.cs @@ -1,9 +1,7 @@ using Intersect.Server.Database.Logging.Entities; using Intersect.Server.Database.Logging.Seed; - using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; - using System.Data.Common; namespace Intersect.Server.Database.Logging; diff --git a/Intersect.Server.Core/Database/Logging/RequestLog.cs b/Intersect.Server.Core/Database/Logging/RequestLog.cs index 2330411663..35ea276eb8 100644 --- a/Intersect.Server.Core/Database/Logging/RequestLog.cs +++ b/Intersect.Server.Core/Database/Logging/RequestLog.cs @@ -1,13 +1,11 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using Intersect.Utilities; - using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; - +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Converters; -using LogLevel = Intersect.Logging.LogLevel; namespace Intersect.Server.Database.Logging; diff --git a/Intersect.Server.Core/Database/Logging/Seed/SeedTrades.cs b/Intersect.Server.Core/Database/Logging/Seed/SeedTrades.cs index a4eb36d77e..3492faf8e2 100644 --- a/Intersect.Server.Core/Database/Logging/Seed/SeedTrades.cs +++ b/Intersect.Server.Core/Database/Logging/Seed/SeedTrades.cs @@ -1,5 +1,4 @@ using Intersect.Server.Database.Logging.Entities; - using Microsoft.EntityFrameworkCore; namespace Intersect.Server.Database.Logging.Seed; diff --git a/Intersect.Server.Core/Database/MigrationBuilderExtensions.cs b/Intersect.Server.Core/Database/MigrationBuilderExtensions.cs index fc6023aec6..f1076f4b0e 100644 --- a/Intersect.Server.Core/Database/MigrationBuilderExtensions.cs +++ b/Intersect.Server.Core/Database/MigrationBuilderExtensions.cs @@ -1,5 +1,4 @@ using Intersect.Config; - using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations.Operations; using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders; diff --git a/Intersect.Server.Core/Database/MigrationScheduler.cs b/Intersect.Server.Core/Database/MigrationScheduler.cs index bb476890c0..394ada1a33 100644 --- a/Intersect.Server.Core/Database/MigrationScheduler.cs +++ b/Intersect.Server.Core/Database/MigrationScheduler.cs @@ -1,7 +1,8 @@ +using Intersect.Core; using Intersect.Framework.Reflection; -using Intersect.Logging; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Database; @@ -36,9 +37,9 @@ public void ApplyScheduledMigrations() if (SqliteNetCoreGuidPatch.ShouldBeAppliedTo(_context)) { - Log.Verbose("Applying .NET Core patch..."); + ApplicationContext.Context.Value?.Logger.LogDebug("Applying .NET Core patch..."); SqliteNetCoreGuidPatch.ApplyTo(_context); - Log.Verbose("Finished applying .NET Core patch."); + ApplicationContext.Context.Value?.Logger.LogDebug("Finished applying .NET Core patch."); } var migrator = _context.Database.GetService(); diff --git a/Intersect.Server.Core/Database/PlayerData/Api/RefreshToken.cs b/Intersect.Server.Core/Database/PlayerData/Api/RefreshToken.cs index a97cba309a..a9e2106fd1 100644 --- a/Intersect.Server.Core/Database/PlayerData/Api/RefreshToken.cs +++ b/Intersect.Server.Core/Database/PlayerData/Api/RefreshToken.cs @@ -2,10 +2,10 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Diagnostics.CodeAnalysis; -using Intersect.Logging; +using Intersect.Core; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; - +using Microsoft.Extensions.Logging; using Newtonsoft.Json; namespace Intersect.Server.Database.PlayerData.Api; @@ -111,9 +111,9 @@ public static bool TryFind(Guid id, out RefreshToken refreshToken) refreshToken = context?.RefreshTokens?.Where(token => token.Id == id).Include(token => token.User).FirstOrDefault(); return refreshToken != default; } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error loading refresh token {TokenId}", id); refreshToken = default; return false; } @@ -152,7 +152,7 @@ public static bool TryFindForTicket( } catch (Exception exception) { - Log.Error(exception, $"Failed to load RefreshToken for {ticketId}"); + ApplicationContext.Context.Value?.Logger.LogError(exception, $"Failed to load RefreshToken for {ticketId}"); } refreshToken = null; @@ -175,9 +175,13 @@ public static IEnumerable FindForClient(Guid clientId) return tokenQuery.AsEnumerable()?.ToList(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error loading tokens for client {ClientId}", + clientId + ); return null; } } @@ -198,9 +202,13 @@ public static IEnumerable FindExpiredForClient(Guid clientId) return tokenQuery.AsEnumerable()?.ToList(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error loading expired tokens for client {ClientId}", + clientId + ); return null; } } @@ -221,9 +229,13 @@ public static IEnumerable FindForUser(Guid userId) return tokenQuery.AsEnumerable()?.ToList(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error loading tokens for user {UserId}", + userId + ); return null; } } @@ -249,9 +261,13 @@ public static IEnumerable FindExpiredForUser(Guid userId) return tokenQuery.AsEnumerable()?.ToList(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error loading expired tokens for user {UserId}", + userId + ); return null; } } @@ -272,9 +288,13 @@ public static RefreshToken FindOneForUser(Guid userId) return token; } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error loading token for user {UserId}", + userId + ); return null; } } @@ -295,7 +315,11 @@ public static bool HasTokens(Guid userId) } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error checking if user {UserId} has tokens", + userId + ); throw; } } @@ -319,7 +343,7 @@ public static async Task RemoveAllAsync(IList tokens, Cancel return false; } - Log.Diagnostic($"Attempted to remove {tokens.Count} tokens but only {unblockedTokens.Length} were available to remove."); + ApplicationContext.Context.Value?.Logger.LogTrace($"Attempted to remove {tokens.Count} tokens but only {unblockedTokens.Length} were available to remove."); using (var context = DbInterface.CreatePlayerContext(readOnly: false)) { diff --git a/Intersect.Server.Core/Database/PlayerData/Ban.cs b/Intersect.Server.Core/Database/PlayerData/Ban.cs index 3cebb00365..0ea3abdc46 100644 --- a/Intersect.Server.Core/Database/PlayerData/Ban.cs +++ b/Intersect.Server.Core/Database/PlayerData/Ban.cs @@ -1,12 +1,11 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Diagnostics.CodeAnalysis; using System.Net; -using Intersect.Logging; +using Intersect.Core; using Intersect.Server.Localization; using Intersect.Server.Networking; - using Microsoft.EntityFrameworkCore; - +using Microsoft.Extensions.Logging; using Newtonsoft.Json; // ReSharper disable UnusedAutoPropertyAccessor.Local @@ -83,7 +82,7 @@ public static bool Add(Ban ban) } catch (Exception ex) { - Log.Error(ex, "Failed to add ban for user " + ban.User?.Name); + ApplicationContext.Context.Value?.Logger.LogError(ex, "Failed to add ban for user " + ban.User?.Name); //ServerContext.DispatchUnhandledException(new Exception("Failed to save user, shutting down to prevent rollbacks!"), true); } return false; @@ -134,7 +133,7 @@ public static bool Remove(Ban ban) } catch (Exception ex) { - Log.Error(ex, "Failed to remove ban " + ban?.Id); + ApplicationContext.Context.Value?.Logger.LogError(ex, "Failed to remove ban " + ban?.Id); //ServerContext.DispatchUnhandledException(new Exception("Failed to save user, shutting down to prevent rollbacks!"), true); } return false; @@ -163,7 +162,7 @@ public static bool Remove(string ip, bool expired = true) } catch (Exception ex) { - Log.Error(ex, "Failed to remove bans for ip " + ip); + ApplicationContext.Context.Value?.Logger.LogError(ex, "Failed to remove bans for ip " + ip); //ServerContext.DispatchUnhandledException(new Exception("Failed to save user, shutting down to prevent rollbacks!"), true); } return false; @@ -192,7 +191,7 @@ public static bool Remove(Guid userId, bool expired = true) } catch (Exception ex) { - Log.Error(ex, "Failed to remove bans for user with id " + userId); + ApplicationContext.Context.Value?.Logger.LogError(ex, "Failed to remove bans for user with id " + userId); //ServerContext.DispatchUnhandledException(new Exception("Failed to save user, shutting down to prevent rollbacks!"), true); } return false; @@ -245,7 +244,7 @@ public static bool IsBanned(IPAddress ipAddress, [NotNullWhen(true)] out string? message = CheckBan(ipAddress.ToString()); return message != default; } - + public static string CheckBan(string ip) => CheckBan(null, ip); public static Ban Find(User user) => Find(user.Id); @@ -259,9 +258,9 @@ public static Ban Find(Guid userId) return ByUser(context, userId)?.FirstOrDefault(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error loading ban for {UserId}", userId); return null; } } @@ -280,9 +279,9 @@ public static Ban Find(string ip) return ByIp(context, ip)?.FirstOrDefault(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error loading ban for {IPAddress}", ip); return null; } } diff --git a/Intersect.Server.Core/Database/PlayerData/IPlayerContext.cs b/Intersect.Server.Core/Database/PlayerData/IPlayerContext.cs index 6d61880e93..bed232c98f 100644 --- a/Intersect.Server.Core/Database/PlayerData/IPlayerContext.cs +++ b/Intersect.Server.Core/Database/PlayerData/IPlayerContext.cs @@ -1,7 +1,6 @@ using Intersect.Server.Database.PlayerData.Api; using Intersect.Server.Database.PlayerData.Players; using Intersect.Server.Entities; - using Microsoft.EntityFrameworkCore; namespace Intersect.Server.Database.PlayerData; diff --git a/Intersect.Server.Core/Database/PlayerData/Migrations/GuildBankMaxSlotMigration.cs b/Intersect.Server.Core/Database/PlayerData/Migrations/GuildBankMaxSlotMigration.cs index 2ea6fa6af5..3ad598ede0 100644 --- a/Intersect.Server.Core/Database/PlayerData/Migrations/GuildBankMaxSlotMigration.cs +++ b/Intersect.Server.Core/Database/PlayerData/Migrations/GuildBankMaxSlotMigration.cs @@ -1,4 +1,5 @@ -using Intersect.Logging; +using Intersect.Core; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Database.PlayerData.Migrations; @@ -11,14 +12,14 @@ public static void Run(PlayerContext context) public static void CapGuildBankSize(PlayerContext context) { - Log.Info("Checking to see if there are any guilds exceeding the configured max bank size..."); + ApplicationContext.Context.Value?.Logger.LogInformation("Checking to see if there are any guilds exceeding the configured max bank size..."); // Go through each and every quest to check if all the tasks have valid events. foreach (var guild in context.Guilds) { if (guild.BankSlotsCount > Options.Instance.Bank.MaxSlots) { - Log.Info($"Too many bank slots ({guild.BankSlotsCount}) for guild {guild.Name}. Setting to {Options.Instance.Bank.MaxSlots}."); + ApplicationContext.Context.Value?.Logger.LogInformation($"Too many bank slots ({guild.BankSlotsCount}) for guild {guild.Name}. Setting to {Options.Instance.Bank.MaxSlots}."); guild.BankSlotsCount = Options.Instance.Bank.MaxSlots; } } diff --git a/Intersect.Server.Core/Database/PlayerData/Mute.cs b/Intersect.Server.Core/Database/PlayerData/Mute.cs index 973eadaaa7..b2db9ebe2f 100644 --- a/Intersect.Server.Core/Database/PlayerData/Mute.cs +++ b/Intersect.Server.Core/Database/PlayerData/Mute.cs @@ -1,10 +1,9 @@ using System.ComponentModel.DataAnnotations.Schema; -using Intersect.Logging; +using Intersect.Core; using Intersect.Server.Localization; using Intersect.Server.Networking; - using Microsoft.EntityFrameworkCore; - +using Microsoft.Extensions.Logging; using Newtonsoft.Json; // ReSharper disable UnusedAutoPropertyAccessor.Local @@ -88,7 +87,7 @@ public static bool Add(Mute mute) } catch (Exception ex) { - Log.Error(ex, "Failed to add mute for user " + mute.User?.Name); + ApplicationContext.Context.Value?.Logger.LogError(ex, "Failed to add mute for user " + mute.User?.Name); } return false; } @@ -137,7 +136,7 @@ public static bool Remove(Mute mute) } catch (Exception ex) { - Log.Error(ex, "Failed to delete mute for user " + mute.User?.Name); + ApplicationContext.Context.Value?.Logger.LogError(ex, "Failed to delete mute for user " + mute.User?.Name); } return false; } @@ -163,7 +162,7 @@ public static bool Remove(string ip, bool expired = true) } catch (Exception ex) { - Log.Error(ex, "Failed to remove mutes for ip " + ip); + ApplicationContext.Context.Value?.Logger.LogError(ex, "Failed to remove mutes for ip " + ip); } return false; } @@ -191,7 +190,7 @@ public static bool Remove(Guid userId, bool expired = true) } catch (Exception ex) { - Log.Error(ex, "Failed to remove mutes user with id " + userId); + ApplicationContext.Context.Value?.Logger.LogError(ex, "Failed to remove mutes user with id " + userId); } return false; } @@ -211,7 +210,7 @@ public static bool Remove(User user) } catch (Exception ex) { - Log.Error(ex, "Failed to remove mutes user " + user?.Id); + ApplicationContext.Context.Value?.Logger.LogError(ex, "Failed to remove mutes user " + user?.Id); } return false; } @@ -238,9 +237,14 @@ string ip ? null : Strings.Account.MuteStatus.ToString(mute.StartTime, mute.Muter, mute.EndTime, mute.Reason); } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Failed to find/remove mute for {UserId} for {IPAddress}", + userId, + ip + ); return null; } } @@ -272,9 +276,14 @@ string ip ? null : Strings.Account.MuteStatus.ToString(mute.StartTime, mute.Muter, mute.EndTime, mute.Reason); } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error during removal of stale mute reason for {UserId} for {IPAddress}", + user.Id, + ip + ); return null; } } @@ -290,9 +299,9 @@ public static Mute Find(Guid userId) return ByUser(context, userId)?.FirstOrDefault(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error loading Mute for {UserId}", userId); return null; } } @@ -311,9 +320,9 @@ public static Mute Find(string ip) return ByIp(context, ip)?.FirstOrDefault(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error loading mute for {IPAddress}", ip); return null; } } diff --git a/Intersect.Server.Core/Database/PlayerData/Players/Bag.cs b/Intersect.Server.Core/Database/PlayerData/Players/Bag.cs index b94133e493..775d45ec5a 100644 --- a/Intersect.Server.Core/Database/PlayerData/Players/Bag.cs +++ b/Intersect.Server.Core/Database/PlayerData/Players/Bag.cs @@ -1,9 +1,9 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Diagnostics.CodeAnalysis; +using Intersect.Core; using Intersect.GameObjects; -using Intersect.Logging; using Microsoft.EntityFrameworkCore; - +using Microsoft.Extensions.Logging; using Newtonsoft.Json; // ReSharper disable UnusedAutoPropertyAccessor.Local @@ -103,9 +103,9 @@ public void Save (bool create = false) context.SaveChanges(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Failed to save bag {BagId}", Id); } } @@ -195,9 +195,9 @@ public static bool TryGetBag(Guid bagId, [NotNullWhen(true)] out Bag? bag) return true; } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Failed to get bag {BagId}", bagId); bag = null; return false; } diff --git a/Intersect.Server.Core/Database/PlayerData/Players/BankSlot.cs b/Intersect.Server.Core/Database/PlayerData/Players/BankSlot.cs index 75e3ccd520..79048d0100 100644 --- a/Intersect.Server.Core/Database/PlayerData/Players/BankSlot.cs +++ b/Intersect.Server.Core/Database/PlayerData/Players/BankSlot.cs @@ -1,7 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; using Intersect.Collections.Slotting; using Intersect.Server.Entities; - using Newtonsoft.Json; // ReSharper disable UnusedAutoPropertyAccessor.Local diff --git a/Intersect.Server.Core/Database/PlayerData/Players/Friend.cs b/Intersect.Server.Core/Database/PlayerData/Players/Friend.cs index 020658ac0e..dae0395176 100644 --- a/Intersect.Server.Core/Database/PlayerData/Players/Friend.cs +++ b/Intersect.Server.Core/Database/PlayerData/Players/Friend.cs @@ -1,7 +1,5 @@ using System.ComponentModel.DataAnnotations.Schema; - using Intersect.Server.Entities; - using Newtonsoft.Json; // ReSharper disable AutoPropertyCanBeMadeGetOnly.Local diff --git a/Intersect.Server.Core/Database/PlayerData/Players/Guild.cs b/Intersect.Server.Core/Database/PlayerData/Players/Guild.cs index f61d20b625..9d45136231 100644 --- a/Intersect.Server.Core/Database/PlayerData/Players/Guild.cs +++ b/Intersect.Server.Core/Database/PlayerData/Players/Guild.cs @@ -1,22 +1,22 @@ using System.ComponentModel.DataAnnotations.Schema; using Newtonsoft.Json; - using Intersect.Enums; using Intersect.Server.Entities; using Intersect.Server.Networking; using System.Collections.Concurrent; using System.Diagnostics.CodeAnalysis; using Intersect.Collections.Slotting; +using Intersect.Core; using Intersect.Framework.Core.GameObjects.Variables; using Microsoft.EntityFrameworkCore; using Intersect.Network.Packets.Server; using Intersect.GameObjects; using Intersect.GameObjects.Maps; -using Intersect.Logging; using Intersect.Utilities; using Intersect.Server.Localization; using static Intersect.Server.Database.Logging.Entities.GuildHistory; using Intersect.Server.Collections.Sorting; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Database.PlayerData.Players; @@ -284,7 +284,7 @@ public bool TryAddMember(Player player, int rank, Player? initiator = null) } catch (Exception exception) { - Log.Error(exception, $"Failed to save guild {Id} before adding player {player.Id}"); + ApplicationContext.Context.Value?.Logger.LogError(exception, $"Failed to save guild {Id} before adding player {player.Id}"); return false; } @@ -295,7 +295,7 @@ public bool TryAddMember(Player player, int rank, Player? initiator = null) } catch (Exception exception) { - Log.Error(exception, $"Failed to save player {player.Id} before adding them to guild {Id}"); + ApplicationContext.Context.Value?.Logger.LogError(exception, $"Failed to save player {player.Id} before adding them to guild {Id}"); return false; } @@ -346,7 +346,7 @@ public bool TryRemoveMember(Guid targetId, Player targetPlayer, Player? initiato if (targetPlayer == null) { - Log.Warn($"Failed to remove non-existent player {targetId} from the guild {Id}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Failed to remove non-existent player {targetId} from the guild {Id}"); return false; } @@ -406,16 +406,16 @@ internal void NotifyPlayerDisposed(Player player) if (Guilds.TryRemove(Id, out _)) { - Log.Info($"[Guild][{Id}] Removed self from {nameof(Guilds)} after player {player.Id} logged out"); + ApplicationContext.Context.Value?.Logger.LogInformation($"[Guild][{Id}] Removed self from {nameof(Guilds)} after player {player.Id} logged out"); } else { - Log.Warn($"[Guild][{Id}] Failed to remove self from {nameof(Guilds)} after player {player.Id} logged out"); + ApplicationContext.Context.Value?.Logger.LogWarning($"[Guild][{Id}] Failed to remove self from {nameof(Guilds)} after player {player.Id} logged out"); } } else { - Log.Info($"[Guild][{Id}] Player {player.Id} logged out but there are {onlineCount} members still online"); + ApplicationContext.Context.Value?.Logger.LogInformation($"[Guild][{Id}] Player {player.Id} logged out but there are {onlineCount} members still online"); } } @@ -452,7 +452,7 @@ public void SetPlayerRank(Guid targetId, Player targetPlayer, int rank, Player i if (targetPlayer == null) { - Log.Warn($"Unable to set guild rank to {rank} for non-existent player {targetId} in guild {Id}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Unable to set guild rank to {rank} for non-existent player {targetId} in guild {Id}"); return; } @@ -932,9 +932,9 @@ public static IList> List(string query, string sortBy, g => new KeyValuePair(g, context.Players.Count(p => p.Guild.Id == g.Id)) ).ToList(); } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Failed to list guilds"); total = 0; return null; } diff --git a/Intersect.Server.Core/Database/PlayerData/Players/HotbarSlot.cs b/Intersect.Server.Core/Database/PlayerData/Players/HotbarSlot.cs index 25303e23a3..9de2871d37 100644 --- a/Intersect.Server.Core/Database/PlayerData/Players/HotbarSlot.cs +++ b/Intersect.Server.Core/Database/PlayerData/Players/HotbarSlot.cs @@ -3,7 +3,6 @@ using Intersect.Enums; using Intersect.Server.Entities; using Intersect.Utilities; - using Newtonsoft.Json; // ReSharper disable UnusedAutoPropertyAccessor.Local diff --git a/Intersect.Server.Core/Database/PlayerData/Players/InventorySlot.cs b/Intersect.Server.Core/Database/PlayerData/Players/InventorySlot.cs index e95997c61d..4771a7a135 100644 --- a/Intersect.Server.Core/Database/PlayerData/Players/InventorySlot.cs +++ b/Intersect.Server.Core/Database/PlayerData/Players/InventorySlot.cs @@ -1,7 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; using Intersect.Collections.Slotting; using Intersect.Server.Entities; - using Newtonsoft.Json; // ReSharper disable UnusedAutoPropertyAccessor.Local diff --git a/Intersect.Server.Core/Database/PlayerData/Players/PlayerVariable.cs b/Intersect.Server.Core/Database/PlayerData/Players/PlayerVariable.cs index b756adb922..9ac45b3d9e 100644 --- a/Intersect.Server.Core/Database/PlayerData/Players/PlayerVariable.cs +++ b/Intersect.Server.Core/Database/PlayerData/Players/PlayerVariable.cs @@ -1,7 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; using Intersect.Framework.Core.GameObjects.Variables; using Intersect.Server.Entities; - using Newtonsoft.Json; namespace Intersect.Server.Database.PlayerData.Players; diff --git a/Intersect.Server.Core/Database/PlayerData/Players/Quest.cs b/Intersect.Server.Core/Database/PlayerData/Players/Quest.cs index 199fc45142..791e939ab5 100644 --- a/Intersect.Server.Core/Database/PlayerData/Players/Quest.cs +++ b/Intersect.Server.Core/Database/PlayerData/Players/Quest.cs @@ -1,7 +1,5 @@ using System.ComponentModel.DataAnnotations.Schema; - using Intersect.Server.Entities; - using Newtonsoft.Json; // ReSharper disable UnusedAutoPropertyAccessor.Local diff --git a/Intersect.Server.Core/Database/PlayerData/Players/SpellSlot.cs b/Intersect.Server.Core/Database/PlayerData/Players/SpellSlot.cs index 99754b6253..5295224bb8 100644 --- a/Intersect.Server.Core/Database/PlayerData/Players/SpellSlot.cs +++ b/Intersect.Server.Core/Database/PlayerData/Players/SpellSlot.cs @@ -1,7 +1,6 @@ using System.ComponentModel.DataAnnotations.Schema; using Intersect.Collections.Slotting; using Intersect.Server.Entities; - using Newtonsoft.Json; // ReSharper disable UnusedAutoPropertyAccessor.Local diff --git a/Intersect.Server.Core/Database/PlayerData/Players/Switch.cs b/Intersect.Server.Core/Database/PlayerData/Players/Switch.cs index 51589264ad..bedc14321e 100644 --- a/Intersect.Server.Core/Database/PlayerData/Players/Switch.cs +++ b/Intersect.Server.Core/Database/PlayerData/Players/Switch.cs @@ -1,7 +1,5 @@ using System.ComponentModel.DataAnnotations.Schema; - using Intersect.Server.Entities; - using Newtonsoft.Json; // ReSharper disable UnusedAutoPropertyAccessor.Local diff --git a/Intersect.Server.Core/Database/PlayerData/Security/UserRights.cs b/Intersect.Server.Core/Database/PlayerData/Security/UserRights.cs index a7c2117bca..ab5aa97c50 100644 --- a/Intersect.Server.Core/Database/PlayerData/Security/UserRights.cs +++ b/Intersect.Server.Core/Database/PlayerData/Security/UserRights.cs @@ -1,8 +1,6 @@ using System.Collections.Immutable; using System.Reflection; - using Intersect.Enums; - using Newtonsoft.Json; namespace Intersect.Server.Database.PlayerData.Security; diff --git a/Intersect.Server.Core/Database/PlayerData/SeedData/SeedUsers.cs b/Intersect.Server.Core/Database/PlayerData/SeedData/SeedUsers.cs index 075abf9774..84fadf9ac0 100644 --- a/Intersect.Server.Core/Database/PlayerData/SeedData/SeedUsers.cs +++ b/Intersect.Server.Core/Database/PlayerData/SeedData/SeedUsers.cs @@ -1,10 +1,8 @@ using System.Security.Cryptography; using System.Text; - using Intersect.Enums; using Intersect.Server.Database.PlayerData.Security; using Intersect.Server.Entities; - using Microsoft.EntityFrameworkCore; namespace Intersect.Server.Database.PlayerData.SeedData; diff --git a/Intersect.Server.Core/Database/PlayerData/User.cs b/Intersect.Server.Core/Database/PlayerData/User.cs index 0ec5f923ef..b8c09f0042 100644 --- a/Intersect.Server.Core/Database/PlayerData/User.cs +++ b/Intersect.Server.Core/Database/PlayerData/User.cs @@ -5,10 +5,10 @@ using System.Net; using System.Security.Cryptography; using System.Text; +using Intersect.Core; using Intersect.Enums; using Intersect.Framework.Core.GameObjects.Variables; using Intersect.Framework.Reflection; -using Intersect.Logging; using Intersect.Security; using Intersect.Server.Collections.Indexing; using Intersect.Server.Collections.Sorting; @@ -23,6 +23,7 @@ using Intersect.Server.Networking; using Intersect.Utilities; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using VariableValue = Intersect.Framework.Core.GameObjects.Variables.VariableValue; @@ -216,7 +217,7 @@ public bool TryAddCharacter(Player? newCharacter) } catch (Exception ex) { - Log.Error(ex, $"Failed to save user while adding character: {Name}"); + ApplicationContext.Context.Value?.Logger.LogError(ex, $"Failed to save user while adding character: {Name}"); ServerContext.DispatchUnhandledException( new Exception("Failed to save user, shutting down to prevent rollbacks!") ); @@ -249,7 +250,7 @@ public bool TryDeleteCharacter(Player deleteCharacter) } catch (Exception ex) { - Log.Error(ex, "Failed to save user while deleting character: " + Name); + ApplicationContext.Context.Value?.Logger.LogError(ex, "Failed to save user while deleting character: " + Name); return false; } } @@ -277,7 +278,7 @@ public bool TryDelete() } catch (Exception ex) { - Log.Error(ex, "Failed to delete user: " + Name); + ApplicationContext.Context.Value?.Logger.LogError(ex, "Failed to delete user: " + Name); return false; } } @@ -294,7 +295,7 @@ public void SaveWithDebounce(long debounceMs = 5000) { if (_lastSave < debounceMs + Timing.Global.MillisecondsUtc) { - Log.Debug("Skipping save due to debounce"); + ApplicationContext.Context.Value?.Logger.LogDebug("Skipping save due to debounce"); return; } } @@ -346,13 +347,13 @@ public UserSaveResult Save(PlayerContext? playerContext, bool force = false, boo if (!lockTaken) { #if DIAGNOSTIC - Log.Debug($"Failed to take lock {Environment.StackTrace}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Failed to take lock {Environment.StackTrace}"); #endif return UserSaveResult.SkippedCouldNotTakeLock; } #if DIAGNOSTIC - Log.Debug($"DBOP-A Save({playerContext}, {force}, {create}) #{currentExecutionId} {Name} ({Id})"); + ApplicationContext.Context.Value?.Logger.LogDebug($"DBOP-A Save({playerContext}, {force}, {create}) #{currentExecutionId} {Name} ({Id})"); #endif if (playerContext == null) @@ -381,7 +382,7 @@ public UserSaveResult Save(PlayerContext? playerContext, bool force = false, boo try { playerContext.Users.Update(this); - Log.Warn(invalidOperationException, $"Successfully recovered from {nameof(InvalidOperationException)}"); + ApplicationContext.Context.Value?.Logger.LogWarning(invalidOperationException, $"Successfully recovered from {nameof(InvalidOperationException)}"); } catch (Exception exception) { @@ -419,7 +420,7 @@ public UserSaveResult Save(PlayerContext? playerContext, bool force = false, boo } #if DIAGNOSTIC - Log.Debug($"DBOP-B Save({playerContext}, {force}, {create}) #{currentExecutionId} {Name} ({Id})"); + ApplicationContext.Context.Value?.Logger.LogDebug($"DBOP-B Save({playerContext}, {force}, {create}) #{currentExecutionId} {Name} ({Id})"); #endif var client = Globals.ClientLookup.Values.FirstOrDefault(c => c.User.Id == Id); @@ -457,11 +458,11 @@ public UserSaveResult Save(PlayerContext? playerContext, bool force = false, boo #if DIAGNOSTIC suffix = $"#{currentExecutionId}"; #endif - Log.Error(ex, $"Jackpot! Concurrency Bug For {Name} in {(createdContext == default ? "Existing" : "Created")} Context {suffix}"); - Log.Error(concurrencyErrors.ToString()); + ApplicationContext.Context.Value?.Logger.LogError(ex, $"Jackpot! Concurrency Bug For {Name} in {(createdContext == default ? "Existing" : "Created")} Context {suffix}"); + ApplicationContext.Context.Value?.Logger.LogError(concurrencyErrors.ToString()); #if DIAGNOSTIC - Log.Debug($"DBOP-C Save({playerContext}, {force}, {create}) #{currentExecutionId} {Name} ({Id})"); + ApplicationContext.Context.Value?.Logger.LogDebug($"DBOP-C Save({playerContext}, {force}, {create}) #{currentExecutionId} {Name} ({Id})"); #endif var client = Globals.ClientLookup.Values.FirstOrDefault(c => c.User.Id == Id); @@ -478,10 +479,10 @@ public UserSaveResult Save(PlayerContext? playerContext, bool force = false, boo } catch (Exception ex) { - Log.Error(ex, "Failed to save user: " + Name); + ApplicationContext.Context.Value?.Logger.LogError(ex, "Failed to save user: " + Name); #if DIAGNOSTIC - Log.Debug($"DBOP-C Save({playerContext}, {force}, {create}) #{currentExecutionId} {Name} ({Id})"); + ApplicationContext.Context.Value?.Logger.LogDebug($"DBOP-C Save({playerContext}, {force}, {create}) #{currentExecutionId} {Name} ({Id})"); #endif var client = Globals.ClientLookup.Values.FirstOrDefault(c => c.User.Id == Id); @@ -611,7 +612,7 @@ public static bool TryAuthenticate(string username, string password, [NotNullWhe } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Failed to authenticate {Username}", username); } return user != default; @@ -632,7 +633,7 @@ out LoginFailureReason failureReason var hashedPassword = SaltPasswordHash(ptPassword, user.Salt); if (!string.Equals(user.Password, hashedPassword, StringComparison.Ordinal)) { - Log.Debug($"Login to {username} failed due invalid credentials"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Login to {username} failed due invalid credentials"); user = default; failureReason = new LoginFailureReason(LoginFailureType.InvalidCredentials); return false; @@ -641,7 +642,7 @@ out LoginFailureReason failureReason var result = user.Save(); if (result != UserSaveResult.Completed) { - Log.Error($"Login to {username} failed due to pre-logged in User save failure: {result}"); + ApplicationContext.Context.Value?.Logger.LogError($"Login to {username} failed due to pre-logged in User save failure: {result}"); user = default; failureReason = new LoginFailureReason(LoginFailureType.ServerError); return false; @@ -653,7 +654,7 @@ out LoginFailureReason failureReason return true; } - Log.Error($"Login to {username} failed due to {nameof(PostLoad)}() returning null."); + ApplicationContext.Context.Value?.Logger.LogError($"Login to {username} failed due to {nameof(PostLoad)}() returning null."); user = default; failureReason = new LoginFailureReason(LoginFailureType.ServerError); return false; @@ -667,7 +668,7 @@ out LoginFailureReason failureReason { if (UserExists(username)) { - Log.Error($"Login to {username} failed because the salt is empty."); + ApplicationContext.Context.Value?.Logger.LogError($"Login to {username} failed because the salt is empty."); failureReason = new LoginFailureReason(LoginFailureType.ServerError); } else @@ -686,7 +687,7 @@ out LoginFailureReason failureReason } catch (Exception exception) { - Log.Error(exception, $"Login to {username} failed due to an exception"); + ApplicationContext.Context.Value?.Logger.LogError(exception, $"Login to {username} failed due to an exception"); user = default; failureReason = new LoginFailureReason(LoginFailureType.ServerError); return false; @@ -741,7 +742,7 @@ public static bool TryFindByName(string username, PlayerContext playerContext, [ } catch (Exception exception) { - Log.Error(exception, $"Failed to find user by name '{username}'"); + ApplicationContext.Context.Value?.Logger.LogError(exception, $"Failed to find user by name '{username}'"); } return false; @@ -774,7 +775,7 @@ public static bool TryFindById(Guid userId, PlayerContext playerContext, [NotNul } catch (Exception exception) { - Log.Error(exception, $"Failed to find user by id '{userId}'"); + ApplicationContext.Context.Value?.Logger.LogError(exception, $"Failed to find user by id '{userId}'"); } return user != default; @@ -802,9 +803,9 @@ public static User Find(string username) var queriedUser = QueryUserByNameShallow(context, username); return queriedUser; } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Failed to find {Username}", username); return null; } } @@ -839,9 +840,13 @@ public static User FindByNameOrEmail(string nameOrEmail, PlayerContext playerCon var queriedUser = QueryUserByNameOrEmailShallow(playerContext, nameOrEmail); return queriedUser; } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Failed to load user by name or email '{UsernameOrEmail}'", + nameOrEmail + ); return null; } } @@ -870,9 +875,13 @@ public static User FindByEmail(string email, PlayerContext playerContext) { return QueryUserByEmailShallow(playerContext, email); } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Failed to load user for email address '{Email}'", + email + ); return null; } } @@ -895,9 +904,13 @@ public static string GetUserSalt(string userName) using var context = DbInterface.CreatePlayerContext(); return SaltByName(context, userName); } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error getting salt for '{Username}'", + userName + ); return null; } } @@ -928,9 +941,13 @@ public static bool UserExists(string nameOrEmail) return AnyUserByNameOrEmail(context, nameOrEmail); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error checking if user known by '{NameOrEmail}' exists", + nameOrEmail + ); return false; } } @@ -1201,9 +1218,9 @@ out int total return users; } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error listing users"); total = 0; return null; } diff --git a/Intersect.Server.Core/Database/SqliteNetCoreGuidPatch.cs b/Intersect.Server.Core/Database/SqliteNetCoreGuidPatch.cs index 447737dcc4..bc11150b1a 100644 --- a/Intersect.Server.Core/Database/SqliteNetCoreGuidPatch.cs +++ b/Intersect.Server.Core/Database/SqliteNetCoreGuidPatch.cs @@ -1,10 +1,12 @@ +using System.Diagnostics; using Dapper; using Intersect.Config; +using Intersect.Core; using Intersect.Framework.Reflection; -using Intersect.Logging; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.Extensions.Logging; using SqlKata.Execution; namespace Intersect.Server.Database; @@ -196,7 +198,7 @@ public static void ApplyTo(TContext context) // Only debug logging below here in this loop // If more logic needs to be added this should be inverted // and the logging logic put back inside the if statement - if (Log.Default.Configuration.LogLevel < LogLevel.Debug) + if (!Debugger.IsAttached) { continue; } @@ -215,22 +217,24 @@ public static void ApplyTo(TContext context) searchValues.Select(searchValue => searchValue?.GetFullishName()) ); - Log.Debug($"Processed row {convertedRowCount++}/{numberOfRows} in '{entityTable}' (segment {segmentConvertedRowCount++}/{convertedRows.Count}) ({searchValuesString} was {searchValuesTypeString}), {result} rows changed."); + ApplicationContext.Context.Value?.Logger.LogDebug( + $"Processed row {convertedRowCount++}/{numberOfRows} in '{entityTable}' (segment {segmentConvertedRowCount++}/{convertedRows.Count}) ({searchValuesString} was {searchValuesTypeString}), {result} rows changed." + ); } transaction.Commit(); dbConnection.Close(); - if (Log.Default.Configuration.LogLevel >= LogLevel.Debug) + if (Debugger.IsAttached) { - Log.Debug( + ApplicationContext.Context.Value?.Logger.LogDebug( $"Completed updating segment in {(DateTime.UtcNow - startTimeSegment).TotalMilliseconds}ms ('{entityTable}', {convertedRows.Count} rows updated)" ); } } - Log.Verbose($"Completed updating table in {(DateTime.UtcNow - startTimeTable).TotalMilliseconds}ms ('{entityTable}', {numberOfRows} rows updated)"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Completed updating table in {(DateTime.UtcNow - startTimeTable).TotalMilliseconds}ms ('{entityTable}', {numberOfRows} rows updated)"); } - Log.Verbose($"Completed updating database in {(DateTime.UtcNow - startTimeDatabase).TotalMilliseconds}ms"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Completed updating database in {(DateTime.UtcNow - startTimeDatabase).TotalMilliseconds}ms"); } } diff --git a/Intersect.Server.Core/Entities/BankInterface.cs b/Intersect.Server.Core/Entities/BankInterface.cs index 2488e19688..cf3842ee1e 100644 --- a/Intersect.Server.Core/Entities/BankInterface.cs +++ b/Intersect.Server.Core/Entities/BankInterface.cs @@ -7,7 +7,8 @@ using Intersect.Server.Networking; using System.Diagnostics; using Intersect.Collections.Slotting; -using Log = Intersect.Logging.Log; +using Intersect.Core; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Entities; @@ -200,7 +201,7 @@ out slotIndicesToRemoveFrom { if (slotIndicesToRemoveFrom.Length <= nextSlotIndexToRemoveFrom) { - Log.Warn($"Ran out of slots to remove from for {_player.Id}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Ran out of slots to remove from for {_player.Id}"); break; } } @@ -237,7 +238,7 @@ out slotIndicesToRemoveFrom if (itemDescriptor.ItemType == ItemType.Equipment || maximumStack <= 1) { - Log.Warn($"{nameof(Item.FindCompatibleSlotsForItem)}() returned incompatible slots for {nameof(ItemBase)} {itemDescriptor.Id}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"{nameof(Item.FindCompatibleSlotsForItem)}() returned incompatible slots for {nameof(ItemBase)} {itemDescriptor.Id}"); break; } @@ -258,7 +259,7 @@ out slotIndicesToRemoveFrom { if (remainingQuantityToRemove < 1) { - Log.Error($"Potential inventory corruption for {_player.Id}"); + ApplicationContext.Context.Value?.Logger.LogError($"Potential inventory corruption for {_player.Id}"); } var slotToRemoveFrom = sourceSlots[slotIndexToRemoveFrom]; @@ -284,21 +285,21 @@ out slotIndicesToRemoveFrom // ReSharper disable once ConvertIfStatementToSwitchStatement if (remainingQuantity < 0) { - Log.Error($"{_player.Id} was accidentally given {-remainingQuantity}x extra {itemDescriptor.Id}"); + ApplicationContext.Context.Value?.Logger.LogError($"{_player.Id} was accidentally given {-remainingQuantity}x extra {itemDescriptor.Id}"); } else if (remainingQuantity > 0) { - Log.Error($"{_player.Id} was not given {remainingQuantity}x {itemDescriptor.Id}"); + ApplicationContext.Context.Value?.Logger.LogError($"{_player.Id} was not given {remainingQuantity}x {itemDescriptor.Id}"); } // ReSharper disable once ConvertIfStatementToSwitchStatement if (remainingQuantityToRemove < 0) { - Log.Error($"{_player.Id} was scammed {-remainingQuantity}x {itemDescriptor.Id}"); + ApplicationContext.Context.Value?.Logger.LogError($"{_player.Id} was scammed {-remainingQuantity}x {itemDescriptor.Id}"); } else if (remainingQuantityToRemove > 0) { - Log.Error($"{_player.Id} did not have {remainingQuantity}x {itemDescriptor.Id} taken"); + ApplicationContext.Context.Value?.Logger.LogError($"{_player.Id} did not have {remainingQuantity}x {itemDescriptor.Id} taken"); } if (sendUpdate) @@ -436,7 +437,7 @@ out var slotIndicesToRemoveFrom { if (slotIndicesToRemoveFrom.Length <= nextSlotIndexToRemoveFrom) { - Log.Warn($"Ran out of slots to remove from for {_player.Id}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Ran out of slots to remove from for {_player.Id}"); break; } @@ -470,7 +471,7 @@ out var slotIndicesToRemoveFrom if (itemDescriptor.ItemType == ItemType.Equipment || maximumStack <= 1) { - Log.Warn($"{nameof(Item.FindCompatibleSlotsForItem)}() returned incompatible slots for {nameof(ItemBase)} {itemDescriptor.Id}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"{nameof(Item.FindCompatibleSlotsForItem)}() returned incompatible slots for {nameof(ItemBase)} {itemDescriptor.Id}"); break; } @@ -484,7 +485,7 @@ out var slotIndicesToRemoveFrom { if (remainingQuantityToRemove < 1) { - Log.Error($"Potential bank corruption for {_player.Id}"); + ApplicationContext.Context.Value?.Logger.LogError($"Potential bank corruption for {_player.Id}"); } var slotToRemoveFrom = sourceSlots[slotIndexToRemoveFrom]; @@ -502,21 +503,21 @@ out var slotIndicesToRemoveFrom // ReSharper disable once ConvertIfStatementToSwitchStatement if (remainingQuantity < 0) { - Log.Error($"{_player.Id} was accidentally given {-remainingQuantity}x extra {itemDescriptor.Id}"); + ApplicationContext.Context.Value?.Logger.LogError($"{_player.Id} was accidentally given {-remainingQuantity}x extra {itemDescriptor.Id}"); } else if (remainingQuantity > 0) { - Log.Error($"{_player.Id} was not given {remainingQuantity}x {itemDescriptor.Id}"); + ApplicationContext.Context.Value?.Logger.LogError($"{_player.Id} was not given {remainingQuantity}x {itemDescriptor.Id}"); } // ReSharper disable once ConvertIfStatementToSwitchStatement if (remainingQuantityToRemove < 0) { - Log.Error($"{_player.Id} was scammed {-remainingQuantity}x {itemDescriptor.Id}"); + ApplicationContext.Context.Value?.Logger.LogError($"{_player.Id} was scammed {-remainingQuantity}x {itemDescriptor.Id}"); } else if (remainingQuantityToRemove > 0) { - Log.Error($"{_player.Id} did not have {remainingQuantity}x {itemDescriptor.Id} taken"); + ApplicationContext.Context.Value?.Logger.LogError($"{_player.Id} did not have {remainingQuantity}x {itemDescriptor.Id} taken"); } foreach (var slotIndexToUpdate in slotIndicesToFill) @@ -549,7 +550,7 @@ public void SwapBankItems(int slotFrom, int slotTo) var bank = _bank; if (bank == null) { - Log.Error($"SwapBankItems() called on invalid bank for {_player.Id}"); + ApplicationContext.Context.Value?.Logger.LogError($"SwapBankItems() called on invalid bank for {_player.Id}"); return; } @@ -561,7 +562,7 @@ public void SwapBankItems(int slotFrom, int slotTo) ChatMessageType.Bank, CustomColors.Alerts.Error ); - Log.Error($"Invalid slot indices SwapBankItems({slotFrom}, {slotTo}) ({bank.Capacity}, {_player.Id})"); + ApplicationContext.Context.Value?.Logger.LogError($"Invalid slot indices SwapBankItems({slotFrom}, {slotTo}) ({bank.Capacity}, {_player.Id})"); return; } @@ -595,14 +596,14 @@ public void SwapBankItems(int slotFrom, int slotTo) { if (sourceSlot.ItemId == default) { - Log.Warn($"SwapBankItems({slotFrom}, {slotTo}) for {_player.Id} with empty item ID"); + ApplicationContext.Context.Value?.Logger.LogWarning($"SwapBankItems({slotFrom}, {slotTo}) for {_player.Id} with empty item ID"); return; } /* Items are the same, move the maximum quantity */ if (!ItemBase.TryGet(sourceSlot.ItemId, out var itemDescriptor)) { - Log.Error($"SwapBankItems({slotFrom}, {slotTo}) for {_player.Id} failed due to missing item {sourceSlot.ItemId}"); + ApplicationContext.Context.Value?.Logger.LogError($"SwapBankItems({slotFrom}, {slotTo}) for {_player.Id} failed due to missing item {sourceSlot.ItemId}"); return; } @@ -638,7 +639,7 @@ public void SwapBankItems(int slotFrom, int slotTo) } catch (Exception exception) { - Log.Error(exception, $"Error in SwapBankItems({slotFrom}, {slotTo}) for {_player.Id}"); + ApplicationContext.Context.Value?.Logger.LogError(exception, $"Error in SwapBankItems({slotFrom}, {slotTo}) for {_player.Id}"); return; } diff --git a/Intersect.Server.Core/Entities/Combat/Dash.cs b/Intersect.Server.Core/Entities/Combat/Dash.cs index bdefaf486c..d9683d9ae5 100644 --- a/Intersect.Server.Core/Entities/Combat/Dash.cs +++ b/Intersect.Server.Core/Entities/Combat/Dash.cs @@ -1,7 +1,8 @@ +using Intersect.Core; using Intersect.Enums; -using Intersect.Logging; using Intersect.Server.Networking; using Intersect.Utilities; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Entities.Combat; @@ -54,11 +55,12 @@ public void CalculateRange( Range = 0; if (en == default) { - Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( new ArgumentNullException( nameof(en), "Entity was null when calling CalcuateRange(), this isn't supported." - ) + ), + "Error calculating range" ); return; } @@ -72,7 +74,7 @@ public void CalculateRange( { case MovementBlockerType.OutOfBounds: return; - + case MovementBlockerType.MapAttribute: if (!blockPass) { @@ -80,7 +82,7 @@ public void CalculateRange( } break; - + case MovementBlockerType.ZDimension: if (!zDimensionPass) { @@ -88,7 +90,7 @@ public void CalculateRange( } break; - + case MovementBlockerType.Entity: switch (blockingEntityType) { diff --git a/Intersect.Server.Core/Entities/Entity.cs b/Intersect.Server.Core/Entities/Entity.cs index f48e6f4d73..cabbec0a10 100644 --- a/Intersect.Server.Core/Entities/Entity.cs +++ b/Intersect.Server.Core/Entities/Entity.cs @@ -2,11 +2,11 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Diagnostics.CodeAnalysis; using Intersect.Collections.Slotting; +using Intersect.Core; using Intersect.Enums; using Intersect.GameObjects; using Intersect.GameObjects.Events; using Intersect.GameObjects.Maps; -using Intersect.Logging; using Intersect.Network.Packets.Server; using Intersect.Server.Database; using Intersect.Server.Database.PlayerData.Players; @@ -19,6 +19,7 @@ using Intersect.Server.Maps; using Intersect.Server.Networking; using Intersect.Utilities; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Stat = Intersect.Enums.Stat; @@ -357,7 +358,7 @@ public virtual void Update(long timeMs) if (stat == default) { var allStats = string.Join(",\n", Stat.Select(s => s == default ? "\tnull" : $"\t{s}")); - Log.Error($"Stat[{i}] == default for '{GetType().FullName}', Stat=[\n{allStats}\n]"); + ApplicationContext.Context.Value?.Logger.LogError($"Stat[{i}] == default for '{GetType().FullName}', Stat=[\n{allStats}\n]"); } statsUpdated |= stat.Update(statTime); } @@ -1108,8 +1109,13 @@ public virtual void Move(Direction moveDir, Player forPlayer, bool doNotUpdate = break; default: - Log.Warn( - new ArgumentOutOfRangeException(nameof(moveDir), $@"Bogus move attempt in direction {moveDir}.") + ApplicationContext.Context.Value?.Logger.LogWarning( + new ArgumentOutOfRangeException( + nameof(moveDir), + $@"Bogus move attempt in direction {moveDir}." + ), + "Invalid move in {Direction}", + moveDir ); return; diff --git a/Intersect.Server.Core/Entities/Events/Event.cs b/Intersect.Server.Core/Entities/Events/Event.cs index 6059ba8676..387a04d057 100644 --- a/Intersect.Server.Core/Entities/Events/Event.cs +++ b/Intersect.Server.Core/Entities/Events/Event.cs @@ -1,11 +1,12 @@ +using Intersect.Core; using Intersect.Enums; using Intersect.GameObjects.Events; using Intersect.GameObjects.Events.Commands; -using Intersect.Logging; using Intersect.Server.Localization; using Intersect.Server.Maps; using Intersect.Server.Networking; using Intersect.Utilities; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Entities.Events; @@ -126,11 +127,11 @@ public void Update(long timeMs, MapController map) var curStack = CallStack.Peek(); if (curStack == null) { - Log.Error("Curstack variable in event update is null.. not sure how nor how to recover so just gonna let this crash now.."); + ApplicationContext.Context.Value?.Logger.LogError("Curstack variable in event update is null.. not sure how nor how to recover so just gonna let this crash now.."); } if (Player == null) { - Log.Error("Player variable in event update is null.. not sure how nor how to recover so just gonna let this crash now.."); + ApplicationContext.Context.Value?.Logger.LogError("Player variable in event update is null.. not sure how nor how to recover so just gonna let this crash now.."); } if (curStack.WaitingForResponse == CommandInstance.EventResponse.Shop && Player.InShop == null) { @@ -248,7 +249,7 @@ public void Update(long timeMs, MapController map) CallStack.Clear(); //Killing this event, we're over it. if (this.BaseEvent.MapId == Guid.Empty) { - Log.Error(Strings.Events.WatchdogKillCommon.ToString(BaseEvent.Name)); + ApplicationContext.Context.Value?.Logger.LogError(Strings.Events.WatchdogKillCommon.ToString(BaseEvent.Name)); if (Player.Power.IsModerator) { PacketSender.SendChatMsg( @@ -258,7 +259,7 @@ public void Update(long timeMs, MapController map) } else { - Log.Error(Strings.Events.WatchdogKill.ToString(map.Name, BaseEvent.Name)); + ApplicationContext.Context.Value?.Logger.LogError(Strings.Events.WatchdogKill.ToString(map.Name, BaseEvent.Name)); if (Player.Power.IsModerator) { PacketSender.SendChatMsg( diff --git a/Intersect.Server.Core/Entities/Npc.cs b/Intersect.Server.Core/Entities/Npc.cs index a14ea57920..e274954148 100644 --- a/Intersect.Server.Core/Entities/Npc.cs +++ b/Intersect.Server.Core/Entities/Npc.cs @@ -1,7 +1,7 @@ using System.Collections.Concurrent; +using Intersect.Core; using Intersect.Enums; using Intersect.GameObjects; -using Intersect.Logging; using Intersect.Network.Packets.Server; using Intersect.Server.Database; using Intersect.Server.Database.PlayerData.Players; @@ -13,6 +13,7 @@ using Intersect.Server.Maps; using Intersect.Server.Networking; using Intersect.Utilities; +using Microsoft.Extensions.Logging; using Stat = Intersect.Enums.Stat; namespace Intersect.Server.Entities; @@ -665,7 +666,7 @@ private void TryCastSpells() if (spellBase.Combat == null) { - Log.Warn($"Combat data missing for {spellBase.Id}."); + ApplicationContext.Context.Value?.Logger.LogWarning($"Combat data missing for {spellBase.Id}."); } //TODO: try cast spell to find out hidden targets? @@ -975,7 +976,7 @@ public override void Update(long timeMs) { if (CanAttack(blockingEntity, default)) { - Log.Debug($"Trying to attack {blockingEntity.Name} because they're blocking the path to {Target.Name}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Trying to attack {blockingEntity.Name} because they're blocking the path to {Target.Name}"); ChangeDir(nextPathDirection); TryAttack(blockingEntity); blockerAttacked = true; diff --git a/Intersect.Server.Core/Entities/Pathfinding/Pathfinder.cs b/Intersect.Server.Core/Entities/Pathfinding/Pathfinder.cs index 051de406e3..a55a7f1ca6 100644 --- a/Intersect.Server.Core/Entities/Pathfinding/Pathfinder.cs +++ b/Intersect.Server.Core/Entities/Pathfinding/Pathfinder.cs @@ -1,9 +1,10 @@ using System.Diagnostics; +using Intersect.Core; using Intersect.Enums; -using Intersect.Logging; using Intersect.Server.Database; using Intersect.Server.Entities.Events; using Intersect.Server.Maps; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Entities.Pathfinding; @@ -390,7 +391,12 @@ public PathfinderResult Update(long timeMs) } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error updating pathfinder for '{Name}' ({Id})", + mEntity.Name, + mEntity.Id + ); } return returnVal; diff --git a/Intersect.Server.Core/Entities/Player.Database.cs b/Intersect.Server.Core/Entities/Player.Database.cs index afe3bb8cc9..a271e01d50 100644 --- a/Intersect.Server.Core/Entities/Player.Database.cs +++ b/Intersect.Server.Core/Entities/Player.Database.cs @@ -1,18 +1,17 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Diagnostics.CodeAnalysis; -using Intersect.Logging; +using Intersect.Core; using Intersect.Server.Database; using Intersect.Server.Database.PlayerData; using Intersect.Server.General; using Intersect.Server.Networking; using Intersect.Server.Database.PlayerData.Players; using Intersect.Utilities; - using Microsoft.EntityFrameworkCore; - using Newtonsoft.Json; using Intersect.Server.Collections.Indexing; using Intersect.Server.Collections.Sorting; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Entities; @@ -114,9 +113,9 @@ public static Player Find(Guid playerId) _ = Validate(player); return player; } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error while finding player {Id}", playerId); return null; } } @@ -145,9 +144,13 @@ public static Player Find(string playerName, bool loadRelationships = false, boo _ = Validate(player); return player; } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error while finding player '{PlayerName}'", + playerName + ); return null; } } @@ -172,9 +175,13 @@ public static bool PlayerExists(string name) return AnyPlayerByName(context, name); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Error while checking if player '{PlayerName}' exists", + name + ); return false; } } @@ -269,7 +276,7 @@ public void LoadFriends() } catch (Exception ex) { - Log.Error(ex, $"Failed to load friends for {Name}."); + ApplicationContext.Context.Value?.Logger.LogError(ex, $"Failed to load friends for {Name}."); //ServerContext.DispatchUnhandledException(new Exception("Failed to save user, shutting down to prevent rollbacks!"), true); } } @@ -307,7 +314,7 @@ public bool TryAddFriend(Player friend) } catch (Exception ex) { - Log.Error(ex, "Failed to add friend " + friend.Name + " to " + Name + "'s friends list."); + ApplicationContext.Context.Value?.Logger.LogError(ex, "Failed to add friend " + friend.Name + " to " + Name + "'s friends list."); return false; } } @@ -342,7 +349,7 @@ public static bool TryRemoveFriendship(Guid id, Guid otherId) } catch (Exception ex) { - Log.Error(ex, $"Failed to remove friendship between {id} and {otherId}."); + ApplicationContext.Context.Value?.Logger.LogError(ex, $"Failed to remove friendship between {id} and {otherId}."); return false; } } @@ -393,7 +400,7 @@ public void Save(PlayerContext? playerContext = null) } catch (Exception exception) { - Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( exception, $"Error occurred while saving player {Id} ({nameof(playerContext)}={(createdPlayerContext == null ? "not null" : "null")}" ); @@ -417,9 +424,9 @@ public static int Count() return context.Players.Count(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error counting players"); return 0; } } @@ -462,9 +469,9 @@ public static int Count() return compiledQuery.Skip(skip).Take(take).ToList(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error listing players"); total = 0; return null; } @@ -487,9 +494,9 @@ SortDirection sortDirection return results?.ToList(); } } - catch (Exception ex) + catch (Exception exception) { - Log.Error(ex); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error ranking players"); return null; } } diff --git a/Intersect.Server.Core/Entities/Player.cs b/Intersect.Server.Core/Entities/Player.cs index 3d8e7d81f5..ed4e9956de 100644 --- a/Intersect.Server.Core/Entities/Player.cs +++ b/Intersect.Server.Core/Entities/Player.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using Intersect.Collections.Slotting; +using Intersect.Core; using Intersect.Enums; using Intersect.Framework.Core.GameObjects.Variables; using Intersect.GameObjects; @@ -11,7 +12,6 @@ using Intersect.GameObjects.Events; using Intersect.GameObjects.Events.Commands; using Intersect.GameObjects.Maps; -using Intersect.Logging; using Intersect.Network; using Intersect.Network.Packets.Server; using Intersect.Server.Core.MapInstancing; @@ -28,7 +28,7 @@ using Intersect.Server.Maps; using Intersect.Server.Networking; using Intersect.Utilities; - +using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Stat = Intersect.Enums.Stat; @@ -620,39 +620,39 @@ public void CompleteLogout( { if (logoutOperationId != default) { - Log.Debug($"Completing logout {logoutOperationId}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Completing logout {logoutOperationId}"); } if (stackTrace != default) { - Log.Debug(stackTrace); + ApplicationContext.Context.Value?.Logger.LogDebug(stackTrace); } #if DIAGNOSTIC var currentExecutionId = _logoutCounter++; - Log.Debug($"Started {nameof(CompleteLogout)}() #{currentExecutionId} on {Name} ({User?.Name})"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Started {nameof(CompleteLogout)}() #{currentExecutionId} on {Name} ({User?.Name})"); #endif try { - Log.Diagnostic($"Starting save for logout {logoutOperationId}"); + ApplicationContext.Context.Value?.Logger.LogTrace($"Starting save for logout {logoutOperationId}"); var saveResult = User?.Save(); switch (saveResult) { case UserSaveResult.Completed: - Log.Diagnostic($"Completed save for logout {logoutOperationId}"); + ApplicationContext.Context.Value?.Logger.LogTrace($"Completed save for logout {logoutOperationId}"); break; case UserSaveResult.SkippedCouldNotTakeLock: - Log.Debug($"Skipped save for logout {logoutOperationId}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Skipped save for logout {logoutOperationId}"); break; case UserSaveResult.Failed: - Log.Warn($"Save failed for logout {logoutOperationId}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Save failed for logout {logoutOperationId}"); break; case UserSaveResult.DatabaseFailure: Client?.LogAndDisconnect(Id, stackTrace ?? nameof(CompleteLogout)); break; case null: - Log.Warn($"Skipped save because {nameof(User)} is null."); + ApplicationContext.Context.Value?.Logger.LogWarning($"Skipped save because {nameof(User)} is null."); break; default: throw new UnreachableException(); @@ -660,7 +660,7 @@ public void CompleteLogout( } catch (Exception exception) { - Log.Warn($"Crashed while saving for logout {logoutOperationId}"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Crashed while saving for logout {logoutOperationId}"); logoutCompletionSource?.TrySetException(exception); throw; } @@ -668,7 +668,7 @@ public void CompleteLogout( lock (_savingLock) { var logoutType = softLogout ? "soft" : "hard"; - Log.Info($"[Player.CompleteLogout] Done saving {Name} ({logoutType} logout, {Id})"); + ApplicationContext.Context.Value?.Logger.LogInformation($"[Player.CompleteLogout] Done saving {Name} ({logoutType} logout, {Id})"); _saving = false; if (!softLogout) @@ -685,7 +685,7 @@ public void CompleteLogout( } #if DIAGNOSTIC - Log.Debug($"Finished {nameof(CompleteLogout)}() #{currentExecutionId} on {Name} ({User?.Name})"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Finished {nameof(CompleteLogout)}() #{currentExecutionId} on {Name} ({User?.Name})"); #endif } @@ -707,7 +707,7 @@ public override void Update(long timeMs) { if (CombatTimer < Timing.Global.Milliseconds) { - Log.Debug($"Combat timer expired for player {Id}, logging out."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Combat timer expired for player {Id}, logging out."); Logout(); return; } @@ -721,7 +721,7 @@ public override void Update(long timeMs) { if (Client.IsEditor) { - Log.Debug($"Editor saving user: {user.Name}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Editor saving user: {user.Name}"); } DbInterface.Pool.QueueWorkItem(user.Save, false); @@ -2032,7 +2032,7 @@ public override void Warp(Guid newMapId, // An instance of the map MUST exist. Otherwise, head to spawn. if (newMapInstance == null) { - Log.Error($"Player {Name} requested a new map Instance with ID {MapInstanceId} and failed to get it."); + ApplicationContext.Context.Value?.Logger.LogError($"Player {Name} requested a new map Instance with ID {MapInstanceId} and failed to get it."); WarpToSpawn(); return; @@ -2380,8 +2380,8 @@ private void SendToNewMapInstance(MapController newMap) EventTileLookup.Clear(); EventLookup.Clear(); EventBaseIdLookup.Clear(); - Log.Debug($"Player {Name} has joined instance {MapInstanceId} of map: {newMap.Name}"); - Log.Info($"Previous instance was {PreviousMapInstanceId}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Player {Name} has joined instance {MapInstanceId} of map: {newMap.Name}"); + ApplicationContext.Context.Value?.Logger.LogInformation($"Previous instance was {PreviousMapInstanceId}"); // We changed maps AND instance layers - remove from the old instance PacketSender.SendEntityLeaveInstanceOfMap(this, oldMap?.Id ?? MapId, PreviousMapInstanceId); // Remove any trace of our player from the old instance's processing @@ -2443,7 +2443,7 @@ public Guid CreateNewInstanceIdFromType(MapInstanceType? mapInstanceType, bool f } else { - Log.Error($"Player {Name} requested a guild warp with no guild, and proceeded to warp to map anyway"); + ApplicationContext.Context.Value?.Logger.LogError($"Player {Name} requested a guild warp with no guild, and proceeded to warp to map anyway"); newMapLayerId = Guid.Empty; } break; @@ -2506,7 +2506,7 @@ public Guid CreateNewInstanceIdFromType(MapInstanceType? mapInstanceType, bool f break; default: - Log.Error($"Player {Name} requested an instance type that is not supported. Their map instance settings will not change."); + ApplicationContext.Context.Value?.Logger.LogError($"Player {Name} requested an instance type that is not supported. Their map instance settings will not change."); break; } @@ -2734,7 +2734,7 @@ public bool TryGetSlot(int slotIndex, out InventorySlot slot, bool createSlotIfN if (default == slot && createSlotIfNull) { var createdSlot = new InventorySlot(slotIndex); - Log.Error("Creating inventory slot " + slotIndex + " for player " + Name + Environment.NewLine + Environment.StackTrace); + ApplicationContext.Context.Value?.Logger.LogError("Creating inventory slot " + slotIndex + " for player " + Name + Environment.NewLine + Environment.StackTrace); Items[slotIndex] = createdSlot; slot = createdSlot; } @@ -3227,7 +3227,7 @@ public bool TryDropItemFrom(int slotIndex, int amount) if (!MapController.TryGetInstanceFromMap(MapId, MapInstanceId, out var mapInstance)) { - Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( Map == default ? $"Could not find map {MapId} for player '{Name}'." : $"Could not find map instance {MapInstanceId} for player '{Name}' on map {Map.Name}." @@ -4068,12 +4068,12 @@ public void BuyItem(int slot, int amount) if (!TryTakeItem(itemSlot, quantityToRemove)) { success = false; - Log.Warn(Strings.Shops.FailedToRemoveItem.ToString(itemSlot, Id, quantityToRemove, "BuyItem(int slot, int amount)")); + ApplicationContext.Context.Value?.Logger.LogWarning(Strings.Shops.FailedToRemoveItem.ToString(itemSlot, Id, quantityToRemove, "BuyItem(int slot, int amount)")); break; } removedItems.Add(itemSlot.Id, quantityToRemove); - Log.Warn(Strings.Shops.SuccessfullyRemovedItem.ToString(quantityToRemove, itemSlot, Id, "BuyItem(int slot, int amount)")); + ApplicationContext.Context.Value?.Logger.LogWarning(Strings.Shops.SuccessfullyRemovedItem.ToString(quantityToRemove, itemSlot, Id, "BuyItem(int slot, int amount)")); remainingCost -= quantityToRemove; if (remainingCost <= 0) @@ -4301,7 +4301,7 @@ public bool ShouldCancelCrafting() if (!ItemBase.TryGet(craftDescriptor.ItemId, out var craftItem)) { PacketSender.SendChatMsg(this, Strings.Errors.UnknownErrorTryAgain, ChatMessageType.Error, CustomColors.Alerts.Error); - Log.Error($"Unable to find item descriptor {craftItem?.Id} for craft {craftDescriptor?.Id}."); + ApplicationContext.Context.Value?.Logger.LogError($"Unable to find item descriptor {craftItem?.Id} for craft {craftDescriptor?.Id}."); return true; } diff --git a/Intersect.Server.Core/Extensions/QueryableExtensions.cs b/Intersect.Server.Core/Extensions/QueryableExtensions.cs index 5ee4dcbf76..5d02491308 100644 --- a/Intersect.Server.Core/Extensions/QueryableExtensions.cs +++ b/Intersect.Server.Core/Extensions/QueryableExtensions.cs @@ -1,5 +1,4 @@ using Intersect.Server.Collections.Sorting; - using Microsoft.EntityFrameworkCore; namespace Intersect.Server.Extensions; diff --git a/Intersect.Server.Core/General/Formulas.cs b/Intersect.Server.Core/General/Formulas.cs index 92e35a773d..b175d318c6 100644 --- a/Intersect.Server.Core/General/Formulas.cs +++ b/Intersect.Server.Core/General/Formulas.cs @@ -3,9 +3,7 @@ using Intersect.Server.Entities; using Intersect.Server.Localization; using Intersect.Utilities; - using NCalc; - using Newtonsoft.Json; namespace Intersect.Server.General; diff --git a/Intersect.Server.Core/General/Time.cs b/Intersect.Server.Core/General/Time.cs index 11b841e893..f24ad50b47 100644 --- a/Intersect.Server.Core/General/Time.cs +++ b/Intersect.Server.Core/General/Time.cs @@ -1,7 +1,8 @@ +using Intersect.Core; using Intersect.GameObjects; -using Intersect.Logging; using Intersect.Server.Networking; using Intersect.Utilities; +using Microsoft.Extensions.Logging; namespace Intersect.Server.General; @@ -67,7 +68,7 @@ public static void Update() catch (ArgumentOutOfRangeException exception) { // Log the error with the value of timeBase.Rate and pass the exception - Log.Error(exception, $"Failed to update game time. Time was {timeWas}, Added Rate was {timeRate}, Added time span was {addedTime}"); + ApplicationContext.Context.Value?.Logger.LogError(exception, $"Failed to update game time. Time was {timeWas}, Added Rate was {timeRate}, Added time span was {addedTime}"); // Rethrow the exception to crash the server o_o !!! throw; } diff --git a/Intersect.Server.Core/Localization/CommandsNamespace.cs b/Intersect.Server.Core/Localization/CommandsNamespace.cs index eaabab6ead..d0da354ccd 100644 --- a/Intersect.Server.Core/Localization/CommandsNamespace.cs +++ b/Intersect.Server.Core/Localization/CommandsNamespace.cs @@ -93,14 +93,6 @@ public sealed partial class CommandsNamespace : LocaleCommandNamespace [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public readonly LocalizedString ExperimentalFlagNotFound = @"Experimental flag '{00}' was not found!"; - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public readonly LocaleCommand Experiments = new LocaleCommand - { - Name = @"experiments", - Description = @"Sets the enablement of an experimental feature. true is enabled, false is disabled", - Help = @"enables or disables an experimental feature" - }; - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public readonly LocalizedString FlagInfo = @"(flag)"; [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] diff --git a/Intersect.Server.Core/Localization/Strings.cs b/Intersect.Server.Core/Localization/Strings.cs index 914e96eb2b..e595929947 100644 --- a/Intersect.Server.Core/Localization/Strings.cs +++ b/Intersect.Server.Core/Localization/Strings.cs @@ -1,9 +1,10 @@ using System.Text; using Intersect.Config; +using Intersect.Core; using Intersect.Localization; -using Intersect.Logging; using Intersect.Server.Core; using Intersect.Server.Networking.Helpers; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; namespace Intersect.Server.Localization; @@ -1356,7 +1357,7 @@ public static bool Load() ); } - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Failed to deserialize strings"); return false; } @@ -1378,7 +1379,7 @@ public static bool Save() } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Failed to save strings"); return false; } diff --git a/Intersect.Server.Core/Maps/MapController.cs b/Intersect.Server.Core/Maps/MapController.cs index 9a68d2de47..e59e8971a6 100644 --- a/Intersect.Server.Core/Maps/MapController.cs +++ b/Intersect.Server.Core/Maps/MapController.cs @@ -2,15 +2,15 @@ using System.ComponentModel.DataAnnotations.Schema; using System.Diagnostics.CodeAnalysis; using Intersect.Compression; +using Intersect.Core; using Intersect.Enums; using Intersect.GameObjects; using Intersect.GameObjects.Maps; -using Intersect.Logging; using Intersect.Network.Packets.Server; using Intersect.Server.Database; using Intersect.Server.Entities; using Intersect.Server.Networking; - +using Microsoft.Extensions.Logging; using Newtonsoft.Json; namespace Intersect.Server.Maps; @@ -423,7 +423,7 @@ public bool TryCreateInstance(Guid instanceId, out MapInstance newLayer, Player { if (!mInstances.ContainsKey(instanceId)) { - Log.Debug($"Creating new instance with ID {instanceId} for map {Name}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Creating new instance with ID {instanceId} for map {Name}"); newLayer = new MapInstance(this, instanceId, creator); newLayer.Initialize(); mInstances[instanceId] = newLayer; @@ -472,7 +472,7 @@ public void DisposeInstanceWithId(Guid mapInstanceId) if (mInstances.TryRemove(mapInstanceId, out var removedInstance)) { removedInstance.Dispose(); - Log.Debug($"Cleaning up Instance {mapInstanceId} for map: {Name}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Cleaning up Instance {mapInstanceId} for map: {Name}"); } } } diff --git a/Intersect.Server.Core/Maps/MapGrid.cs b/Intersect.Server.Core/Maps/MapGrid.cs index 42579555a0..9840f47200 100644 --- a/Intersect.Server.Core/Maps/MapGrid.cs +++ b/Intersect.Server.Core/Maps/MapGrid.cs @@ -1,6 +1,5 @@ using System.Diagnostics.Contracts; using Intersect.Server.Database; - using Newtonsoft.Json.Linq; namespace Intersect.Server.Maps; diff --git a/Intersect.Server.Core/Maps/MapInstance.cs b/Intersect.Server.Core/Maps/MapInstance.cs index 9de9b65aa1..e4ed92a136 100644 --- a/Intersect.Server.Core/Maps/MapInstance.cs +++ b/Intersect.Server.Core/Maps/MapInstance.cs @@ -1,9 +1,9 @@ using System.Collections.Concurrent; +using Intersect.Core; using Intersect.Enums; using Intersect.GameObjects; using Intersect.GameObjects.Events; using Intersect.GameObjects.Maps; -using Intersect.Logging; using Intersect.Network.Packets.Server; using Intersect.Server.Database; using Intersect.Server.Entities.Events; @@ -15,6 +15,7 @@ using Intersect.Server.Framework.Items; using Intersect.Server.Framework.Maps; using Intersect.Server.Plugins.Helpers; +using Microsoft.Extensions.Logging; namespace Intersect.Server.Maps; @@ -741,7 +742,7 @@ public void SpawnItem(IItemSource? source, int x, int y, Item item, int amount, { if (item == null) { - Log.Warn($"Tried to spawn {amount} of a null item at ({x}, {y}) in map {Id}."); + ApplicationContext.Context.Value?.Logger.LogWarning($"Tried to spawn {amount} of a null item at ({x}, {y}) in map {Id}."); return; } @@ -749,7 +750,7 @@ public void SpawnItem(IItemSource? source, int x, int y, Item item, int amount, var itemDescriptor = ItemBase.Get(item.ItemId); if (itemDescriptor == null) { - Log.Warn($"No item found for {item.ItemId}."); + ApplicationContext.Context.Value?.Logger.LogWarning($"No item found for {item.ItemId}."); return; } diff --git a/Intersect.Server.Core/Maps/MapItemInstance.cs b/Intersect.Server.Core/Maps/MapItemInstance.cs index 77f73e2df7..e286e6a9e5 100644 --- a/Intersect.Server.Core/Maps/MapItemInstance.cs +++ b/Intersect.Server.Core/Maps/MapItemInstance.cs @@ -1,6 +1,5 @@ using Intersect.Server.Database; using Intersect.Server.Database.PlayerData.Players; - using Newtonsoft.Json; namespace Intersect.Server.Maps; diff --git a/Intersect.Server.Core/Metrics/Histogram.cs b/Intersect.Server.Core/Metrics/Histogram.cs index 1d66502698..8aeb9cd7f0 100644 --- a/Intersect.Server.Core/Metrics/Histogram.cs +++ b/Intersect.Server.Core/Metrics/Histogram.cs @@ -1,5 +1,4 @@ using Intersect.Server.Metrics.Controllers; - using Newtonsoft.Json; namespace Intersect.Server.Metrics; diff --git a/Intersect.Server.Core/Metrics/MetricsRoot.cs b/Intersect.Server.Core/Metrics/MetricsRoot.cs index ba39ac5a14..a7cacabf85 100644 --- a/Intersect.Server.Core/Metrics/MetricsRoot.cs +++ b/Intersect.Server.Core/Metrics/MetricsRoot.cs @@ -1,6 +1,5 @@ using Intersect.Server.Metrics.Controllers; using Intersect.Utilities; - using Newtonsoft.Json; namespace Intersect.Server.Metrics; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20180905042857_Initial.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20180905042857_Initial.Designer.cs index 7ed8f2f810..c71db9330b 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20180905042857_Initial.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20180905042857_Initial.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20190303234637_SpellUpgrades_OnHit_Shields.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20190303234637_SpellUpgrades_OnHit_Shields.Designer.cs index 1f19db9724..16de86aef5 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20190303234637_SpellUpgrades_OnHit_Shields.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20190303234637_SpellUpgrades_OnHit_Shields.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20190306224847_BoundSpells.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20190306224847_BoundSpells.Designer.cs index b03edf034b..1e120e1592 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20190306224847_BoundSpells.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20190306224847_BoundSpells.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20190320233655_ItemRarityAndSpellQuickCast.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20190320233655_ItemRarityAndSpellQuickCast.Designer.cs index 5e8f98e7c4..8ebad6161d 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20190320233655_ItemRarityAndSpellQuickCast.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20190320233655_ItemRarityAndSpellQuickCast.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20190530000628_AddingCraftingQuantities.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20190530000628_AddingCraftingQuantities.Designer.cs index 750cecb97f..3c5f5719de 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20190530000628_AddingCraftingQuantities.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20190530000628_AddingCraftingQuantities.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20190611170819_CombiningSwitchesVariables.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20190611170819_CombiningSwitchesVariables.Designer.cs index f8611465f2..fff68706a8 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20190611170819_CombiningSwitchesVariables.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20190611170819_CombiningSwitchesVariables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20190615010038_AddingExpOveridesToClasses.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20190615010038_AddingExpOveridesToClasses.Designer.cs index cec74d3914..e564cc9d29 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20190615010038_AddingExpOveridesToClasses.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20190615010038_AddingExpOveridesToClasses.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20190618013705_AddingFoldersToGameObjects.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20190618013705_AddingFoldersToGameObjects.Designer.cs index b6f0e2b862..37b9124f83 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20190618013705_AddingFoldersToGameObjects.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20190618013705_AddingFoldersToGameObjects.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20190618014158_AddingFoldersToVaraibles.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20190618014158_AddingFoldersToVaraibles.Designer.cs index da73e29a6d..5788e2d737 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20190618014158_AddingFoldersToVaraibles.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20190618014158_AddingFoldersToVaraibles.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20190712220904_AddingAnimationSoundCompletionOpt.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20190712220904_AddingAnimationSoundCompletionOpt.Designer.cs index ed4e75b5a4..abc6256489 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20190712220904_AddingAnimationSoundCompletionOpt.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20190712220904_AddingAnimationSoundCompletionOpt.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20190726203949_SpellUpgrades_Percentage_Buffs.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20190726203949_SpellUpgrades_Percentage_Buffs.Designer.cs index 15b6d55113..a1eb69bb72 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20190726203949_SpellUpgrades_Percentage_Buffs.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20190726203949_SpellUpgrades_Percentage_Buffs.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20190727120303_ItemUpgrades_Percentage_Based_Stats.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20190727120303_ItemUpgrades_Percentage_Based_Stats.Designer.cs index 38ec582fb0..a9581055b7 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20190727120303_ItemUpgrades_Percentage_Based_Stats.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20190727120303_ItemUpgrades_Percentage_Based_Stats.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20191030214236_Spell_Upgrades_Traps_Item_Upgrades_Effects_Event_Upgrades_Labels.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20191030214236_Spell_Upgrades_Traps_Item_Upgrades_Effects_Event_Upgrades_Labels.Designer.cs index b64e58ec7b..1f874c84a3 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20191030214236_Spell_Upgrades_Traps_Item_Upgrades_Effects_Event_Upgrades_Labels.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20191030214236_Spell_Upgrades_Traps_Item_Upgrades_Effects_Event_Upgrades_Labels.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20200216143942_MoreGraularAttackSpeedOptions.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20200216143942_MoreGraularAttackSpeedOptions.Designer.cs index 38ee18b053..8265e58dc9 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20200216143942_MoreGraularAttackSpeedOptions.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20200216143942_MoreGraularAttackSpeedOptions.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20201001163344_ItemAndSpellCooldownImprovements.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20201001163344_ItemAndSpellCooldownImprovements.Designer.cs index 065b5584f0..97698ce062 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20201001163344_ItemAndSpellCooldownImprovements.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20201001163344_ItemAndSpellCooldownImprovements.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20201004032158_EnablingCerasVersionTolerance.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20201004032158_EnablingCerasVersionTolerance.Designer.cs index df6161c8b9..4f1f295fb7 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20201004032158_EnablingCerasVersionTolerance.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20201004032158_EnablingCerasVersionTolerance.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20201016122614_AddItemAndNpcColors.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20201016122614_AddItemAndNpcColors.Designer.cs index 3183f79aaa..8cbd8e6205 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20201016122614_AddItemAndNpcColors.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20201016122614_AddItemAndNpcColors.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20201222164741_NpcResetRadius.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20201222164741_NpcResetRadius.Designer.cs index 530438dff6..9e49fd8ffd 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20201222164741_NpcResetRadius.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20201222164741_NpcResetRadius.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20210423131813_AddItemSpellIgnoreCdrOptions.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20210423131813_AddItemSpellIgnoreCdrOptions.Designer.cs index 6008a707a4..87d5e49a6d 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20210423131813_AddItemSpellIgnoreCdrOptions.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20210423131813_AddItemSpellIgnoreCdrOptions.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20210423141451_AddIndividualizedLootOptionToNpcs.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20210423141451_AddIndividualizedLootOptionToNpcs.Designer.cs index f70690422d..e2fb25e1d1 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20210423141451_AddIndividualizedLootOptionToNpcs.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20210423141451_AddIndividualizedLootOptionToNpcs.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20210509070229_AddingQuestCategoriesAndOrderValues.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20210509070229_AddingQuestCategoriesAndOrderValues.Designer.cs index 6c4b51dd8e..10b2fd7957 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20210509070229_AddingQuestCategoriesAndOrderValues.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20210509070229_AddingQuestCategoriesAndOrderValues.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20210512071349_BoundItemExtension.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20210512071349_BoundItemExtension.Designer.cs index 1981c2461f..f1ef0d62aa 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20210512071349_BoundItemExtension.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20210512071349_BoundItemExtension.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20210513080440_AddItemStackCaps.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20210513080440_AddItemStackCaps.Designer.cs index f378010d0b..a2ec627b9e 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20210513080440_AddItemStackCaps.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20210513080440_AddItemStackCaps.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20210607115442_AddedCanGuildBankOptionToItems.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20210607115442_AddedCanGuildBankOptionToItems.Designer.cs index bbaa869ef0..79abfb0b69 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20210607115442_AddedCanGuildBankOptionToItems.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20210607115442_AddedCanGuildBankOptionToItems.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20210611154131_AddingGuildVariables.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20210611154131_AddingGuildVariables.Designer.cs index 4ab2891aac..f74660478c 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20210611154131_AddingGuildVariables.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20210611154131_AddingGuildVariables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20210622051409_AddingRequirementNotMetMessages.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20210622051409_AddingRequirementNotMetMessages.Designer.cs index 75e81595ca..306180b6ac 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20210622051409_AddingRequirementNotMetMessages.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20210622051409_AddingRequirementNotMetMessages.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20210630114724_CraftingCommonEvents.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20210630114724_CraftingCommonEvents.Designer.cs index d51ee3d31a..1aaa0521bc 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20210630114724_CraftingCommonEvents.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20210630114724_CraftingCommonEvents.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20210703145618_AddingShopSoundEffects.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20210703145618_AddingShopSoundEffects.Designer.cs index 050cb287ed..dbfc386c78 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20210703145618_AddingShopSoundEffects.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20210703145618_AddingShopSoundEffects.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20210815153451_TickAnimationMigration.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20210815153451_TickAnimationMigration.Designer.cs index d3b161e22c..d08215dc95 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20210815153451_TickAnimationMigration.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20210815153451_TickAnimationMigration.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20211026130945_NpcImmunityMigration.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20211026130945_NpcImmunityMigration.Designer.cs index 3605ddf64c..a4f8e1e6ae 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20211026130945_NpcImmunityMigration.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20211026130945_NpcImmunityMigration.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20211031200145_FixQuestTaskCompletionEvents.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20211031200145_FixQuestTaskCompletionEvents.Designer.cs index e666f0c76f..4703a01b8c 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20211031200145_FixQuestTaskCompletionEvents.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20211031200145_FixQuestTaskCompletionEvents.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20220415212418_BlockProperties.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20220415212418_BlockProperties.Designer.cs index d6284e53a9..87b86894b6 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20220415212418_BlockProperties.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20220415212418_BlockProperties.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20220417193749_RandomCrafting.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20220417193749_RandomCrafting.Designer.cs index df6afc0ea6..7558538260 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20220417193749_RandomCrafting.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20220417193749_RandomCrafting.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20220624102443_AddingHideEquipmentMapProperty.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20220624102443_AddingHideEquipmentMapProperty.Designer.cs index 311120d192..c380efc0b5 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20220624102443_AddingHideEquipmentMapProperty.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20220624102443_AddingHideEquipmentMapProperty.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20220708174300_GrappleOptions.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20220708174300_GrappleOptions.Designer.cs index cf84423e3f..07f29528e3 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20220708174300_GrappleOptions.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20220708174300_GrappleOptions.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20220831194419_AddedCraftRequirements.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20220831194419_AddedCraftRequirements.Designer.cs index a675b27f46..e76266c8ff 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20220831194419_AddedCraftRequirements.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20220831194419_AddedCraftRequirements.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20220925050711_CustomAnimations.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20220925050711_CustomAnimations.Designer.cs index 657fb860a1..38bde8aed5 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20220925050711_CustomAnimations.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20220925050711_CustomAnimations.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20220926042726_AddedConfigurableItemDespawnTimes.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20220926042726_AddedConfigurableItemDespawnTimes.Designer.cs index aa7caa5f59..104be83f1d 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20220926042726_AddedConfigurableItemDespawnTimes.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20220926042726_AddedConfigurableItemDespawnTimes.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20221016001123_MultipleBonusEffectsMigration.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20221016001123_MultipleBonusEffectsMigration.Designer.cs index 867d7aea2a..501589347e 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20221016001123_MultipleBonusEffectsMigration.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20221016001123_MultipleBonusEffectsMigration.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20221016173617_AddUserVariables.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20221016173617_AddUserVariables.Designer.cs index fbd1034849..890244bbe8 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20221016173617_AddUserVariables.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20221016173617_AddUserVariables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20221017220000_DropColumns.designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20221017220000_DropColumns.designer.cs index 940d28468d..b5800437fa 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20221017220000_DropColumns.designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20221017220000_DropColumns.designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Game/20221018220000_PatchTables.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Game/20221018220000_PatchTables.Designer.cs index b0cf891891..2a5f5bc2d1 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Game/20221018220000_PatchTables.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Game/20221018220000_PatchTables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Logging/20191118024649_RequestLogs.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Logging/20191118024649_RequestLogs.Designer.cs index e9e64d06b5..2452e58cca 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Logging/20191118024649_RequestLogs.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Logging/20191118024649_RequestLogs.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.Logging; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Logging/20201119230003_AddUserActivityHistory.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Logging/20201119230003_AddUserActivityHistory.Designer.cs index 23d648b2b4..2c68c54323 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Logging/20201119230003_AddUserActivityHistory.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Logging/20201119230003_AddUserActivityHistory.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.Logging; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Logging/20210414222302_AddedChatLogging.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Logging/20210414222302_AddedChatLogging.Designer.cs index ac694bf385..099e556912 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Logging/20210414222302_AddedChatLogging.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Logging/20210414222302_AddedChatLogging.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.Logging; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Logging/20210515114555_LogPlayerTrades.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Logging/20210515114555_LogPlayerTrades.Designer.cs index 46862789dd..2962a949c2 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Logging/20210515114555_LogPlayerTrades.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Logging/20210515114555_LogPlayerTrades.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.Logging; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Logging/20210519095613_AddGuildActivityLogging.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Logging/20210519095613_AddGuildActivityLogging.Designer.cs index d3cdf48eea..b67495896c 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Logging/20210519095613_AddGuildActivityLogging.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Logging/20210519095613_AddGuildActivityLogging.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.Logging; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20180927161502_InitialPlayerDb.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20180927161502_InitialPlayerDb.Designer.cs index 96b53d7e7f..f5c39629cd 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20180927161502_InitialPlayerDb.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20180927161502_InitialPlayerDb.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20190310001204_AddRefreshTokens.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20190310001204_AddRefreshTokens.Designer.cs index a2b369f4e8..ee9f485dd0 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20190310001204_AddRefreshTokens.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20190310001204_AddRefreshTokens.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20190310013418_StandardizeVocabulary1.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20190310013418_StandardizeVocabulary1.Designer.cs index d47b148821..3602e7083c 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20190310013418_StandardizeVocabulary1.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20190310013418_StandardizeVocabulary1.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20190611170927_CombiningSwitchesVariables.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20190611170927_CombiningSwitchesVariables.Designer.cs index ea3675c980..787e74985a 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20190611170927_CombiningSwitchesVariables.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20190611170927_CombiningSwitchesVariables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20190804133420_Custom_Player_Name_Colors.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20190804133420_Custom_Player_Name_Colors.Designer.cs index 65bf30d591..e228f383f6 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20190804133420_Custom_Player_Name_Colors.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20190804133420_Custom_Player_Name_Colors.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20191030214333_PlayerUpgrades_Labels.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20191030214333_PlayerUpgrades_Labels.Designer.cs index 70571e529b..ca1aadc4a6 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20191030214333_PlayerUpgrades_Labels.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20191030214333_PlayerUpgrades_Labels.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20191126025000_RefactoringCooldowns.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20191126025000_RefactoringCooldowns.Designer.cs index aeda7360f6..d03f148f03 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20191126025000_RefactoringCooldowns.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20191126025000_RefactoringCooldowns.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20200205112316_FixingPlayerDeleteFriendsForeignKeyContraintFail.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20200205112316_FixingPlayerDeleteFriendsForeignKeyContraintFail.Designer.cs index 1475c0d152..7999e16172 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20200205112316_FixingPlayerDeleteFriendsForeignKeyContraintFail.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20200205112316_FixingPlayerDeleteFriendsForeignKeyContraintFail.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20200301145105_SavingPlayerLabelsInDb.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20200301145105_SavingPlayerLabelsInDb.Designer.cs index 9000f33bd2..14230eef80 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20200301145105_SavingPlayerLabelsInDb.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20200301145105_SavingPlayerLabelsInDb.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20201017065035_AddColorToEntities.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20201017065035_AddColorToEntities.Designer.cs index a9b6ea30f2..d47b7e7388 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20201017065035_AddColorToEntities.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20201017065035_AddColorToEntities.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20210414121435_TrackUserPlayerStats.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20210414121435_TrackUserPlayerStats.Designer.cs index 068a4c1877..3fb36d2313 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20210414121435_TrackUserPlayerStats.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20210414121435_TrackUserPlayerStats.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20210503165540_AddingGuildsWithGuildBanks.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20210503165540_AddingGuildsWithGuildBanks.Designer.cs index a0e2478e92..89658a1a3d 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20210503165540_AddingGuildsWithGuildBanks.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20210503165540_AddingGuildsWithGuildBanks.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20210510223205_TrackPlaytimeAsULongsInSeconds.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20210510223205_TrackPlaytimeAsULongsInSeconds.Designer.cs index b859904476..d7a1cf6e7c 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20210510223205_TrackPlaytimeAsULongsInSeconds.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20210510223205_TrackPlaytimeAsULongsInSeconds.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20210611184605_AddingGuildVariables.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20210611184605_AddingGuildVariables.Designer.cs index ec7d089b1c..0d448c700e 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20210611184605_AddingGuildVariables.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20210611184605_AddingGuildVariables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20220331140427_GuildBankMaxSlotsMigration.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20220331140427_GuildBankMaxSlotsMigration.Designer.cs index 48f8e3a01e..6f3e52ee85 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20220331140427_GuildBankMaxSlotsMigration.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20220331140427_GuildBankMaxSlotsMigration.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20220403141119_InstanceWarpMigration.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20220403141119_InstanceWarpMigration.Designer.cs index 77adb9c7ad..3000e974af 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20220403141119_InstanceWarpMigration.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20220403141119_InstanceWarpMigration.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20221016173603_AddUserVariables.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20221016173603_AddUserVariables.Designer.cs index 11402bae2b..53871e8ff2 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20221016173603_AddUserVariables.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20221016173603_AddUserVariables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20221017220000_DropColumns.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20221017220000_DropColumns.Designer.cs index f7dfc010dc..42bd47ca70 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20221017220000_DropColumns.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20221017220000_DropColumns.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20221018220000_PatchTables.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20221018220000_PatchTables.Designer.cs index eacc185eb3..5f5550c2aa 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20221018220000_PatchTables.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20221018220000_PatchTables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Migrations/Sqlite/Player/20221119214350_ItemProperties.Designer.cs b/Intersect.Server.Core/Migrations/Sqlite/Player/20221119214350_ItemProperties.Designer.cs index aa44e4bf72..516001c1cb 100644 --- a/Intersect.Server.Core/Migrations/Sqlite/Player/20221119214350_ItemProperties.Designer.cs +++ b/Intersect.Server.Core/Migrations/Sqlite/Player/20221119214350_ItemProperties.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server.Core/Networking/Client.cs b/Intersect.Server.Core/Networking/Client.cs index 5459dcd297..5376879424 100644 --- a/Intersect.Server.Core/Networking/Client.cs +++ b/Intersect.Server.Core/Networking/Client.cs @@ -1,8 +1,6 @@ using System.Collections.Concurrent; using Intersect.ErrorHandling; - using Intersect.Core; -using Intersect.Logging; using Intersect.Network; using Intersect.Network.Packets; using Intersect.Server.Database.Logging.Entities; @@ -12,6 +10,7 @@ using Intersect.Server.General; using Intersect.Server.Metrics; using Intersect.Utilities; +using Microsoft.Extensions.Logging; using Strings = Intersect.Server.Localization.Strings; namespace Intersect.Server.Networking; @@ -223,7 +222,7 @@ public string? Ip } catch (Exception exception) { - Log.Warn(exception, $"Failed to get IP for user {User.Id}"); + ApplicationContext.Logger.LogWarning(exception, $"Failed to get IP for user {User.Id}"); return default; } } @@ -286,7 +285,7 @@ public static void RemoveBeta4Client(IConnection connection) return; } - Log.Debug( + Intersect.Core.ApplicationContext.Context.Value?.Logger.LogDebug( string.IsNullOrWhiteSpace(client.Name) //? $"Client disconnected ({(client.IsEditor ? "[editor]" : "[client]")})" @@ -356,15 +355,15 @@ public void SendPackets() $"Sending Packet Error! [Packet: {packetType} | User: {this.Name ?? ""} | Player: {this.Entity?.Name ?? ""} | IP {this.Ip}]"; // TODO: Re-combine these once we figure out how to prevent the OutOfMemoryException that happens occasionally - Log.Error(packetMessage); - Log.Error(new ExceptionInfo(exception)); + ApplicationContext.Logger.LogError(packetMessage); + ApplicationContext.Logger.LogError(new ExceptionInfo(exception)); if (exception.InnerException != null) { - Log.Error(new ExceptionInfo(exception.InnerException)); + ApplicationContext.Logger.LogError(new ExceptionInfo(exception.InnerException)); } // Make the call that triggered the OOME in the first place so that we know when it stops happening - Log.Error(exception, packetMessage); + ApplicationContext.Logger.LogError(exception, packetMessage); #if DIAGNOSTIC this.Disconnect($"Error processing packet type '{packetType}'."); @@ -443,15 +442,15 @@ public void HandlePackets() $"Client Packet Error! [Packet: {packetType} | User: {this.Name ?? ""} | Player: {this.Entity?.Name ?? ""} | IP {this.Ip}]"; // TODO: Re-combine these once we figure out how to prevent the OutOfMemoryException that happens occasionally - Log.Error(packetMessage); - Log.Error(new ExceptionInfo(exception)); + ApplicationContext.Logger.LogError(packetMessage); + ApplicationContext.Logger.LogError(new ExceptionInfo(exception)); if (exception.InnerException != null) { - Log.Error(new ExceptionInfo(exception.InnerException)); + ApplicationContext.Logger.LogError(new ExceptionInfo(exception.InnerException)); } // Make the call that triggered the OOME in the first place so that we know when it stops happening - Log.Error(exception, packetMessage); + ApplicationContext.Logger.LogError(exception, packetMessage); #if DIAGNOSTIC this.Disconnect($"Error processing packet type '{packetType}'."); @@ -485,7 +484,7 @@ public async Task LogAndDisconnect(Guid? playerId, string? meta = default) var message = history?.Id.ToString(); if (message == default) { - Log.Error($"Failed to record crash for {User?.Id.ToString() ?? "N/A"}"); + ApplicationContext.Logger.LogError($"Failed to record crash for {User?.Id.ToString() ?? "N/A"}"); } Disconnect(message ?? Strings.Networking.ServerFull, loggingOut: true); diff --git a/Intersect.Server.Core/Networking/PacketHandler.cs b/Intersect.Server.Core/Networking/PacketHandler.cs index 85d35fe6f4..3ab328ad92 100644 --- a/Intersect.Server.Core/Networking/PacketHandler.cs +++ b/Intersect.Server.Core/Networking/PacketHandler.cs @@ -3,7 +3,6 @@ using Intersect.GameObjects.Crafting; using Intersect.GameObjects.Events; using Intersect.GameObjects.Maps; -using Intersect.Logging; using Intersect.Network; using Intersect.Network.Packets; using Intersect.Network.Packets.Client; @@ -20,8 +19,10 @@ using System.Collections.Concurrent; using System.Diagnostics; using System.Text; +using Intersect.Core; using Intersect.Network.Packets.Server; using Intersect.Server.Core; +using Microsoft.Extensions.Logging; using ChatMsgPacket = Intersect.Network.Packets.Client.ChatMsgPacket; using LoginPacket = Intersect.Network.Packets.Client.LoginPacket; using PartyInvitePacket = Intersect.Network.Packets.Client.PartyInvitePacket; @@ -112,7 +113,7 @@ public bool ShouldAcceptPacket(IConnection connection, long pSize) if (pSize > thresholds.MaxPacketSize) { - Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( Strings.Errors.ErrorFloodSize.ToString( pSize, client?.User?.Name ?? "", client?.Entity?.Name ?? "", client.Ip ) @@ -129,7 +130,7 @@ public bool ShouldAcceptPacket(IConnection connection, long pSize) client.PacketCount++; if (client.PacketCount > thresholds.MaxPacketPerSec) { - Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( Strings.Errors.ErrorFloodBurst.ToString( client.PacketCount, client?.User?.Name ?? "", client?.Entity?.Name ?? "", client.Ip ) @@ -148,7 +149,7 @@ public bool ShouldAcceptPacket(IConnection connection, long pSize) if (client.FloodDetects > 3) { - //Log.Error( + //ApplicationContext.Context.Value?.Logger.LogError( // Strings.Errors.floodaverage.ToString( // client.TotalFloodDetects, client?.User?.Name ?? "", client?.Entity?.Name ?? "", // client.GetIp() @@ -164,7 +165,7 @@ public bool ShouldAcceptPacket(IConnection connection, long pSize) //TODO: Make this check a rolling average somehow to prevent constant flooding right below the threshholds. if (client.TotalFloodDetects > 10) { - //Log.Error(string.Format("[Flood]: Total Detections: {00} [User: {01} | Player: {02} | IP {03}]", client.TotalFloodDetects, client?.User?.Name ?? "", client?.Entity?.Name ?? "", client.GetIp())); + //ApplicationContext.Context.Value?.Logger.LogError(string.Format("[Flood]: Total Detections: {00} [User: {01} | Player: {02} | IP {03}]", client.TotalFloodDetects, client?.User?.Name ?? "", client?.Entity?.Name ?? "", client.GetIp())); //client.Disconnect("Flooding detected."); //return false; } @@ -181,7 +182,7 @@ public bool ShouldAcceptPacket(IConnection connection, long pSize) { if (client.PacketFloodDetect) { - Log.Diagnostic(string.Format("Possible Flood Detected: Packets in last second {00} [User: {01} | Player: {02} | IP {03}]", client.PacketCount, client?.User?.Name ?? "", client?.Entity?.Name ?? "", client.Ip)); + ApplicationContext.Context.Value?.Logger.LogTrace(string.Format("Possible Flood Detected: Packets in last second {00} [User: {01} | Player: {02} | IP {03}]", client.PacketCount, client?.User?.Name ?? "", client?.Entity?.Name ?? "", client.Ip)); } client.PacketCount = 0; @@ -199,7 +200,7 @@ public bool HandlePacket(IConnection connection, IPacket packet) var client = Client.FindBeta4Client(connection); if (client == null) { - Log.Error("Client was null when packet was being handled."); + ApplicationContext.Context.Value?.Logger.LogError("Client was null when packet was being handled."); return false; } @@ -221,7 +222,7 @@ public bool HandlePacket(IConnection connection, IPacket packet) return false; case null: - Log.Error($@"Received null packet from {client.Id} ({client.Name})."); + ApplicationContext.Context.Value?.Logger.LogError($@"Received null packet from {client.Id} ({client.Name})."); client.Disconnect("Error processing packet."); return true; @@ -256,16 +257,16 @@ public bool HandlePacket(IConnection connection, IPacket packet) sanitizationBuilder.AppendLine(); } - Log.Warn(sanitizationBuilder.ToString()); + ApplicationContext.Context.Value?.Logger.LogWarning(sanitizationBuilder.ToString()); } } catch (Exception exception) { - Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( $"Client Packet Error! [Packet: {packet.GetType().Name} | User: {client.Name ?? ""} | Player: {client.Entity?.Name ?? ""} | IP {client.Ip}]" ); - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Client packet error"); client.Disconnect("Error processing packet."); return false; @@ -343,7 +344,7 @@ public bool HandlePacket(IConnection connection, IPacket packet) if (logDiagnostics) { - Log.Debug( + ApplicationContext.Context.Value?.Logger.LogDebug( "\n\t" + $"Ping[Connection={ping}, Error={Math.Abs(ping)}]\n\t" + $"Error[G={Math.Abs(localAdjustedMs - remoteAdjustedMs)}, R={Math.Abs(localUtcMs - remoteUtcMs)}, O={Math.Abs(localOffsetMs - remoteOffsetMs)}]\n\t" + @@ -365,7 +366,7 @@ public bool HandlePacket(IConnection connection, IPacket packet) { //if (!(packet is PingPacket)) //{ - // Log.Warn( + // ApplicationContext.Context.Value?.Logger.LogWarning( // "Dropping Packet. Time desync? Debug Info:\n\t" + // $"Ping[Connection={ping}, NetConnection={ncPing}, Error={Math.Abs(ncPing - ping)}]\n\t" + // $"Server Time[Ticks={Timing.Global.Ticks}, AdjustedMs={localAdjustedMs}, TicksUTC={Timing.Global.TicksUTC}, Offset={Timing.Global.TicksOffset}]\n\t" + @@ -384,7 +385,7 @@ public bool HandlePacket(IConnection connection, IPacket packet) } catch (Exception exception) { - Log.Debug( + ApplicationContext.Context.Value?.Logger.LogDebug( exception, $"Exception thrown dropping packet ({packet.GetType().Name}/{client.Ip}/{client.Name ?? ""}/{client.Entity?.Name ?? ""})" ); @@ -434,7 +435,7 @@ public bool ProcessPacket(IPacket packet, Client client) { if (!Registry.TryGetHandler(packet, out HandlePacketGeneric handler)) { - Logger.Error($"No registered handler for {packet.GetType().FullName}!"); + Logger.LogError($"No registered handler for {packet.GetType().FullName}!"); return false; } @@ -453,7 +454,7 @@ public bool ProcessPacket(IPacket packet, Client client) if (!preHooks.All(hook => hook.Handle(client, packet))) { // Hooks should not fail, if they do that's an error - Logger.Error($"PreHook handler failed for {packet.GetType().FullName}."); + Logger.LogError($"PreHook handler failed for {packet.GetType().FullName}."); return false; } } @@ -468,7 +469,7 @@ public bool ProcessPacket(IPacket packet, Client client) if (!postHooks.All(hook => hook.Handle(client, packet))) { // Hooks should not fail, if they do that's an error - Logger.Error($"PostHook handler failed for {packet.GetType().FullName}."); + Logger.LogError($"PostHook handler failed for {packet.GetType().FullName}."); return false; } } @@ -584,11 +585,11 @@ public void HandlePacket(Client client, LoginPacket packet) if (disconnectedClients) { var disconnectionCount = logoutCompletionSources.Count; - Log.Info($"Login of {username} waiting on {disconnectionCount} clients before continuing..."); + ApplicationContext.Context.Value?.Logger.LogInformation($"Login of {username} waiting on {disconnectionCount} clients before continuing..."); Task.WaitAll(logoutCompletionSources.Select(source => source.Task).ToArray()); - Log.Info($"Continuing login of {username}..."); + ApplicationContext.Context.Value?.Logger.LogInformation($"Continuing login of {username}..."); if (!User.TryLogin( username, @@ -718,7 +719,7 @@ public void HandlePacket(Client client, LogoutPacket packet) if (packet.ReturningToCharSelect && (Options.MaxCharacters > 1 || !Options.Instance.PlayerOpts.SkipCharacterSelect)) { - Log.Debug($"[{nameof(LogoutPacket)}] Returning to character select from player {client.Entity?.Id} ({client.User?.Id})"); + ApplicationContext.Context.Value?.Logger.LogDebug($"[{nameof(LogoutPacket)}] Returning to character select from player {client.Entity?.Id} ({client.User?.Id})"); client.Entity?.TryLogout(false, true); client.Entity = default; PacketSender.SendPlayerCharacters(client, skipLoadingRelationships: true); @@ -1985,13 +1986,13 @@ public void HandlePacket(Client client, CraftItemPacket packet) if (!CraftBase.TryGet(packet.CraftId, out var craftDescriptor)) { - Log.Warn($"Player {player.Id} tried to craft {packet.CraftId} which does not exist."); + ApplicationContext.Context.Value?.Logger.LogWarning($"Player {player.Id} tried to craft {packet.CraftId} which does not exist."); return; } if (player.OpenCraftingTableId == default) { - Log.Warn($"Player {player.Id} tried to craft {packet.CraftId} without having opened a table yet."); + ApplicationContext.Context.Value?.Logger.LogWarning($"Player {player.Id} tried to craft {packet.CraftId} without having opened a table yet."); return; } @@ -2595,7 +2596,10 @@ public void HandlePacket(Client client, SelectCharacterPacket packet) } catch (Exception exception) { - Log.Warn(exception); + ApplicationContext.Context.Value?.Logger.LogWarning( + exception, + "Failed to set player as online or send JoinGame packet" + ); PacketSender.SendError(client, Strings.Account.LoadFail, Strings.General.NoticeError); client.Logout(); } @@ -2770,7 +2774,7 @@ public void HandlePacket(Client client, UpdateGuildMemberPacket packet) } else { - Log.Info( + ApplicationContext.Context.Value?.Logger.LogInformation( $"[Guild] Player {player.Id} sent an offline guild invite to guild {guild.Id} to player {target.Id}" ); target.Save(); diff --git a/Intersect.Server.Core/Networking/PacketSender.cs b/Intersect.Server.Core/Networking/PacketSender.cs index 98b28dab95..7fd4d8467a 100644 --- a/Intersect.Server.Core/Networking/PacketSender.cs +++ b/Intersect.Server.Core/Networking/PacketSender.cs @@ -1,11 +1,11 @@ using System.Collections.Concurrent; +using Intersect.Core; using Intersect.Enums; using Intersect.Framework.Core.GameObjects.Variables; using Intersect.GameObjects; using Intersect.GameObjects.Crafting; using Intersect.GameObjects.Events; using Intersect.GameObjects.Maps.MapList; -using Intersect.Logging; using Intersect.Models; using Intersect.Network; using Intersect.Network.Packets.Server; @@ -19,6 +19,7 @@ using Intersect.Server.Localization; using Intersect.Server.Maps; using Intersect.Utilities; +using Microsoft.Extensions.Logging; using Newtonsoft.Json; @@ -159,7 +160,7 @@ public static MapPacket GenerateMapPacket(Client client, Guid mapId) { if (client == null) { - Log.Error("Attempted to send packet to null client."); + ApplicationContext.Context.Value?.Logger.LogError("Attempted to send packet to null client."); return null; } @@ -239,7 +240,7 @@ public static (MapPacket, MapEntitiesPacket?, MapItemsPacket?) GenerateMapPacket { if (client == null) { - Log.Error("Attempted to send packet to null client."); + ApplicationContext.Context.Value?.Logger.LogError("Attempted to send packet to null client."); return default; } @@ -288,10 +289,13 @@ public static void SendMap(Client client, Guid mapId, bool allEditors = false, s } catch (Exception exception) { - Log.Error($"Current Map #: {mapId}"); - Log.Error($"# Sent maps: {sentMaps.Count}"); - Log.Error($"# Maps: {MapController.Lookup.Count}"); - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Current map: {MapId}\nSent Maps: {SentMapCount}\nMaps: {MapCount}", + mapId, + sentMaps.Count, + MapController.Lookup.Count + ); throw; } @@ -1327,21 +1331,21 @@ public static void SendPlayerCharacters(Client client, bool skipLoadingRelations { if (client == default) { - Log.Warn($"Tried to {nameof(SendPlayerCharacters)}() to a null client?"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Tried to {nameof(SendPlayerCharacters)}() to a null client?"); return; } var user = client.User; if (user == default) { - Log.Warn($"Tried to {nameof(SendPlayerCharacters)}() to client with no user? ({client.Id})"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Tried to {nameof(SendPlayerCharacters)}() to client with no user? ({client.Id})"); return; } var clientCharacters = client.Characters; if (clientCharacters == default) { - Log.Warn($"Tried to {nameof(SendPlayerCharacters)}() to client with no characters? (client {client.Id}/user {user.Id})"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Tried to {nameof(SendPlayerCharacters)}() to client with no characters? (client {client.Id}/user {user.Id})"); return; } @@ -1368,7 +1372,7 @@ public static void SendPlayerCharacters(Client client, bool skipLoadingRelations if (!client.Send(emptyBulkCharactersPacket)) { - Log.Error($"Failed to send empty bulk characters packet to {client.Id}"); + ApplicationContext.Context.Value?.Logger.LogError($"Failed to send empty bulk characters packet to {client.Id}"); } return; @@ -1439,7 +1443,7 @@ public static void SendPlayerCharacters(Client client, bool skipLoadingRelations if (!client.Send(bulkCharactersPacket)) { - Log.Error($"Failed to send {bulkCharactersPacket.Characters.Length} characters to {client.Id}"); + ApplicationContext.Context.Value?.Logger.LogError($"Failed to send {bulkCharactersPacket.Characters.Length} characters to {client.Id}"); } } diff --git a/Intersect.Server/Core/CommandParsing/CommandParser.cs b/Intersect.Server/Core/CommandParsing/CommandParser.cs index ca8461ced9..c071c90d94 100644 --- a/Intersect.Server/Core/CommandParsing/CommandParser.cs +++ b/Intersect.Server/Core/CommandParsing/CommandParser.cs @@ -4,7 +4,6 @@ using Intersect.Server.Core.CommandParsing.Commands; using Intersect.Server.Core.CommandParsing.Errors; using Intersect.Server.Core.CommandParsing.Tokenization; - using Newtonsoft.Json; namespace Intersect.Server.Core.CommandParsing diff --git a/Intersect.Server/Core/CommandParsing/Commands/Command.cs b/Intersect.Server/Core/CommandParsing/Commands/Command.cs index 06a208a73b..11c6838824 100644 --- a/Intersect.Server/Core/CommandParsing/Commands/Command.cs +++ b/Intersect.Server/Core/CommandParsing/Commands/Command.cs @@ -1,6 +1,5 @@ using System.Collections.Immutable; using System.Text; - using Intersect.Core; using Intersect.Localization; using Intersect.Reflection; diff --git a/Intersect.Server/Core/CommandParsing/Commands/ICommand.cs b/Intersect.Server/Core/CommandParsing/Commands/ICommand.cs index 4a1440bfa4..aafcf0234d 100644 --- a/Intersect.Server/Core/CommandParsing/Commands/ICommand.cs +++ b/Intersect.Server/Core/CommandParsing/Commands/ICommand.cs @@ -1,5 +1,4 @@ using System.Collections.Immutable; - using Intersect.Core; using Intersect.Server.Core.CommandParsing.Arguments; diff --git a/Intersect.Server/Core/CommandParsing/Errors/ParserError.cs b/Intersect.Server/Core/CommandParsing/Errors/ParserError.cs index e95f98c6f1..dbb989a1cf 100644 --- a/Intersect.Server/Core/CommandParsing/Errors/ParserError.cs +++ b/Intersect.Server/Core/CommandParsing/Errors/ParserError.cs @@ -1,5 +1,4 @@ using System.Collections.Immutable; - using Intersect.Server.Core.CommandParsing.Commands; namespace Intersect.Server.Core.CommandParsing.Errors diff --git a/Intersect.Server/Core/CommandParsing/ParserContext.cs b/Intersect.Server/Core/CommandParsing/ParserContext.cs index 1027fe10b3..a5de24fb5e 100644 --- a/Intersect.Server/Core/CommandParsing/ParserContext.cs +++ b/Intersect.Server/Core/CommandParsing/ParserContext.cs @@ -1,5 +1,4 @@ using System.Collections.Immutable; - using Intersect.Server.Core.CommandParsing.Arguments; using Intersect.Server.Core.CommandParsing.Commands; using Intersect.Server.Core.CommandParsing.Errors; diff --git a/Intersect.Server/Core/Commands/ExperimentsCommand.cs b/Intersect.Server/Core/Commands/ExperimentsCommand.cs deleted file mode 100644 index 8677e14c9f..0000000000 --- a/Intersect.Server/Core/Commands/ExperimentsCommand.cs +++ /dev/null @@ -1,66 +0,0 @@ -using Intersect.Core.ExperimentalFeatures; -using Intersect.Server.Core.CommandParsing; -using Intersect.Server.Core.CommandParsing.Arguments; -using Intersect.Server.Core.ExperimentalFeatures; -using Intersect.Server.Localization; - -namespace Intersect.Server.Core.Commands -{ - - internal partial class ExperimentsCommand : TargettedCommand - { - - public ExperimentsCommand() : base( - Strings.Commands.Experiments, Strings.Commands.Arguments.TargetExperimentalFeature, - new VariableArgument(Strings.Commands.Arguments.EnablementBoolean, positional: true) - ) - { - } - - private VariableArgument Enablement => FindArgumentOrThrow>(); - - protected override IExperimentalFlag FindTarget(ServerContext context, ParserResult result, string targetName) - { - if (Guid.TryParse(targetName, out var flagId) && Experiments.Instance.TryGet(flagId, out var flag)) - { - return flag; - } - - if (!string.IsNullOrWhiteSpace(targetName) && Experiments.Instance.TryGet(targetName, out flag)) - { - return flag; - } - - Console.WriteLine($@" {Strings.Commands.ExperimentalFlagNotFound.ToString(targetName)}"); - - return default(IExperimentalFlag); - } - - protected override void HandleTarget(ServerContext context, ParserResult result, IExperimentalFlag target) - { - if (target == default(IExperimentalFlag)) - { - return; - } - - if (result.TryFind(Enablement, out var enablement, allowImplicit: false)) - { - if (!Experiments.Instance.TrySet(target, enablement)) - { - throw new Exception(@"Unknown error occurred."); - } - } - else - { - enablement = target.Enabled; - } - - var statusString = enablement ? Strings.General.EnabledLowerCase : Strings.General.DisabledLowerCase; - var enabledString = Strings.Commandoutput.ExperimentalFeatureEnablement.ToString(target.Name, statusString); - - Console.WriteLine($@" {enabledString}"); - } - - } - -} diff --git a/Intersect.Server/Core/Commands/PanicCommand.cs b/Intersect.Server/Core/Commands/PanicCommand.cs index c39c3beb2a..df5a7a7498 100644 --- a/Intersect.Server/Core/Commands/PanicCommand.cs +++ b/Intersect.Server/Core/Commands/PanicCommand.cs @@ -1,12 +1,12 @@ -using Intersect.Logging; + using Intersect.Server.Core.CommandParsing; using Intersect.Server.Core.CommandParsing.Arguments; using Intersect.Server.Localization; - using Microsoft.Diagnostics.Runtime; using System.Diagnostics; using System.Globalization; using System.Text; +using Intersect.Core; using Intersect.Reflection; namespace Intersect.Server.Core.Commands @@ -34,7 +34,7 @@ protected override void HandleValue(ServerContext context, ParserResult result) break; default: - Log.Warn($"'{PanicType}' is not an implemented panic type.", panicType); + ApplicationContext.Context.Value?.Logger.LogWarning($"'{PanicType}' is not an implemented panic type.", panicType); break; } } @@ -132,7 +132,7 @@ private static void HandleStack() } } - Log.Warn(dumpBuilder.ToString()); + ApplicationContext.Context.Value?.Logger.LogWarning(dumpBuilder.ToString()); } } } diff --git a/Intersect.Server/Core/ConsoleService.ConsoleThread.cs b/Intersect.Server/Core/ConsoleService.ConsoleThread.cs index 66706220e5..be57a8d3f4 100644 --- a/Intersect.Server/Core/ConsoleService.ConsoleThread.cs +++ b/Intersect.Server/Core/ConsoleService.ConsoleThread.cs @@ -1,4 +1,4 @@ -using Intersect.Logging; +using Intersect.Core; using Intersect.Server.Core.CommandParsing; using Intersect.Server.Core.CommandParsing.Commands; using Intersect.Server.Core.CommandParsing.Errors; @@ -33,7 +33,6 @@ internal ConsoleThread() : base(nameof(ConsoleService)) Parser.Register(); Parser.Register(); Parser.Register(); - Parser.Register(); Parser.Register(); Parser.Register(Parser.Settings); Parser.Register(); @@ -125,7 +124,7 @@ protected override void ThreadStart(ServerContext serverContext) if (error.Exception != null) { - Log.Warn(error.Exception); + ApplicationContext.Context.Value?.Logger.LogWarning(error.Exception, "Command parser error"); } Console.WriteLine(error.Message); @@ -143,7 +142,10 @@ protected override void ThreadStart(ServerContext serverContext) } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError( + exception, + "Command handler error" + ); } #pragma warning restore CA1031 // Do not catch general exception types diff --git a/Intersect.Server/Core/FullServerContext.cs b/Intersect.Server/Core/FullServerContext.cs index 4983957b06..434a7832df 100644 --- a/Intersect.Server/Core/FullServerContext.cs +++ b/Intersect.Server/Core/FullServerContext.cs @@ -1,6 +1,6 @@ using System.Diagnostics; using System.Resources; -using Intersect.Logging; +using Intersect.Core; using Intersect.Plugins.Interfaces; using Intersect.Rsa; using Intersect.Server.Core.Services; @@ -9,6 +9,7 @@ using Intersect.Server.Networking.Helpers; using Intersect.Server.Web; using Open.Nat; +using ILogger = Microsoft.Extensions.Logging.ILogger; namespace Intersect.Server.Core; @@ -22,7 +23,7 @@ internal class FullServerContext : ServerContext, IFullServerContext internal FullServerContext( ServerCommandLineOptions startupOptions, - Logger logger, + ILogger logger, IPacketHelper packetHelper ) : base(startupOptions, logger, packetHelper) { @@ -68,7 +69,7 @@ protected override void JoinOrKillConsoleThread(Stopwatch stopwatch) return; } - Log.Info("Shutting down the console thread..." + $" ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation("Shutting down the console thread..." + $" ({stopwatch.ElapsedMilliseconds}ms)"); if (!ThreadConsole.Join(1000)) { try @@ -77,7 +78,7 @@ protected override void JoinOrKillConsoleThread(Stopwatch stopwatch) } catch (ThreadAbortException threadAbortException) { - Log.Error(threadAbortException, $"{nameof(ThreadConsole)} aborted."); + ApplicationContext.Context.Value?.Logger.LogError(threadAbortException, $"{nameof(ThreadConsole)} aborted."); } } } @@ -87,7 +88,7 @@ protected override void OnDisposing(Stopwatch stopwatch) base.OnDisposing(stopwatch); #if WEBSOCKETS - Log.Info("Shutting down websockets..." + $" ({stopwatch.ElapsedMilliseconds}ms)"); + ApplicationContext.Context.Value?.Logger.LogInformation("Shutting down websockets..." + $" ({stopwatch.ElapsedMilliseconds}ms)"); WebSocketNetwork.Stop(); #endif } @@ -98,7 +99,7 @@ protected override void InternalStartNetworking() #if WEBSOCKETS WebSocketNetwork.Init(Options.ServerPort); - Log.Pretty.Info(Strings.Intro.websocketstarted.ToString(Options.ServerPort)); + ApplicationContext.Context.Value?.Logger.LogInformation(Strings.Intro.websocketstarted.ToString(Options.ServerPort)); Console.WriteLine(); #endif @@ -122,7 +123,7 @@ internal void CheckNetwork() if (Options.UPnP && !StartupOptions.NoNatPunchthrough) { - Log.Pretty.Info(Strings.Portchecking.PortNotOpenTryingUpnp.ToString(Options.ServerPort)); + ApplicationContext.Context.Value?.Logger.LogInformation(Strings.Portchecking.PortNotOpenTryingUpnp.ToString(Options.ServerPort)); Console.WriteLine(); if (TryUPnP()) @@ -132,35 +133,35 @@ internal void CheckNetwork() return; } - Log.Pretty.Warn(Strings.Portchecking.ProbablyFirewall.ToString(Options.ServerPort)); + ApplicationContext.Context.Value?.Logger.LogWarning(Strings.Portchecking.ProbablyFirewall.ToString(Options.ServerPort)); } else { - Log.Pretty.Warn(Strings.Portchecking.RouterUpnpFailed); + ApplicationContext.Context.Value?.Logger.LogWarning(Strings.Portchecking.RouterUpnpFailed); } } else { - Log.Pretty.Warn(Strings.Portchecking.PortNotOpenUpnpDisabled.ToString(Options.ServerPort)); + ApplicationContext.Context.Value?.Logger.LogWarning(Strings.Portchecking.PortNotOpenUpnpDisabled.ToString(Options.ServerPort)); } } else if (Options.UPnP) { - Log.Pretty.Info(Strings.Portchecking.TryingUpnp); + ApplicationContext.Context.Value?.Logger.LogInformation(Strings.Portchecking.TryingUpnp); Console.WriteLine(); if (TryUPnP()) { - Log.Pretty.Info(Strings.Portchecking.UpnpSucceededPortCheckerDisabled); + ApplicationContext.Context.Value?.Logger.LogInformation(Strings.Portchecking.UpnpSucceededPortCheckerDisabled); } else { - Log.Pretty.Warn(Strings.Portchecking.RouterUpnpFailed); + ApplicationContext.Context.Value?.Logger.LogWarning(Strings.Portchecking.RouterUpnpFailed); } } else { - Log.Pretty.Warn(Strings.Portchecking.PortCheckerAndUpnpDisabled); + ApplicationContext.Context.Value?.Logger.LogWarning(Strings.Portchecking.PortCheckerAndUpnpDisabled); } } @@ -195,7 +196,7 @@ private bool CheckPort() portCheckResultMessage = portCheckResult.ToString(); } - Log.Pretty.Info(portCheckResultMessage.ToString(Strings.Portchecking.DocumentationUrl)); + ApplicationContext.Context.Value?.Logger.LogInformation(portCheckResultMessage.ToString(Strings.Portchecking.DocumentationUrl)); if (!string.IsNullOrEmpty(externalIp)) { diff --git a/Intersect.Server/Migrations/MySql/Game/20180905042857_Initial.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20180905042857_Initial.Designer.cs index 445b6a15bb..091678119d 100644 --- a/Intersect.Server/Migrations/MySql/Game/20180905042857_Initial.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20180905042857_Initial.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20190303234637_SpellUpgrades_OnHit_Shields.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20190303234637_SpellUpgrades_OnHit_Shields.Designer.cs index ead41a1b35..e9c4a13b62 100644 --- a/Intersect.Server/Migrations/MySql/Game/20190303234637_SpellUpgrades_OnHit_Shields.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20190303234637_SpellUpgrades_OnHit_Shields.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20190306224847_BoundSpells.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20190306224847_BoundSpells.Designer.cs index 745a8ff395..04b99f1f61 100644 --- a/Intersect.Server/Migrations/MySql/Game/20190306224847_BoundSpells.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20190306224847_BoundSpells.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20190320233655_ItemRarityAndSpellQuickCast.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20190320233655_ItemRarityAndSpellQuickCast.Designer.cs index b165a9bf8f..224a58bebe 100644 --- a/Intersect.Server/Migrations/MySql/Game/20190320233655_ItemRarityAndSpellQuickCast.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20190320233655_ItemRarityAndSpellQuickCast.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20190530000628_AddingCraftingQuantities.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20190530000628_AddingCraftingQuantities.Designer.cs index fd5122d9e6..1f7a9f7cb3 100644 --- a/Intersect.Server/Migrations/MySql/Game/20190530000628_AddingCraftingQuantities.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20190530000628_AddingCraftingQuantities.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20190611170819_CombiningSwitchesVariables.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20190611170819_CombiningSwitchesVariables.Designer.cs index 081801e9ca..27a3165b65 100644 --- a/Intersect.Server/Migrations/MySql/Game/20190611170819_CombiningSwitchesVariables.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20190611170819_CombiningSwitchesVariables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20190615010038_AddingExpOveridesToClasses.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20190615010038_AddingExpOveridesToClasses.Designer.cs index a9a3a8ca9f..20767db1b4 100644 --- a/Intersect.Server/Migrations/MySql/Game/20190615010038_AddingExpOveridesToClasses.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20190615010038_AddingExpOveridesToClasses.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20190618013705_AddingFoldersToGameObjects.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20190618013705_AddingFoldersToGameObjects.Designer.cs index adcb286df6..8cf8a2e52e 100644 --- a/Intersect.Server/Migrations/MySql/Game/20190618013705_AddingFoldersToGameObjects.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20190618013705_AddingFoldersToGameObjects.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20190618014158_AddingFoldersToVaraibles.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20190618014158_AddingFoldersToVaraibles.Designer.cs index b2e94d8640..86bd209b05 100644 --- a/Intersect.Server/Migrations/MySql/Game/20190618014158_AddingFoldersToVaraibles.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20190618014158_AddingFoldersToVaraibles.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20190712220904_AddingAnimationSoundCompletionOpt.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20190712220904_AddingAnimationSoundCompletionOpt.Designer.cs index 7fad669b0f..01c7ef4cf6 100644 --- a/Intersect.Server/Migrations/MySql/Game/20190712220904_AddingAnimationSoundCompletionOpt.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20190712220904_AddingAnimationSoundCompletionOpt.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20190726203949_SpellUpgrades_Percentage_Buffs.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20190726203949_SpellUpgrades_Percentage_Buffs.Designer.cs index e191759913..e41edf6e56 100644 --- a/Intersect.Server/Migrations/MySql/Game/20190726203949_SpellUpgrades_Percentage_Buffs.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20190726203949_SpellUpgrades_Percentage_Buffs.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20190727120303_ItemUpgrades_Percentage_Based_Stats.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20190727120303_ItemUpgrades_Percentage_Based_Stats.Designer.cs index 61cf83aebb..b7459480c5 100644 --- a/Intersect.Server/Migrations/MySql/Game/20190727120303_ItemUpgrades_Percentage_Based_Stats.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20190727120303_ItemUpgrades_Percentage_Based_Stats.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20191030214236_Spell_Upgrades_Traps_Item_Upgrades_Effects_Event_Upgrades_Labels.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20191030214236_Spell_Upgrades_Traps_Item_Upgrades_Effects_Event_Upgrades_Labels.Designer.cs index 5acdca7e8a..b0c81f5e76 100644 --- a/Intersect.Server/Migrations/MySql/Game/20191030214236_Spell_Upgrades_Traps_Item_Upgrades_Effects_Event_Upgrades_Labels.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20191030214236_Spell_Upgrades_Traps_Item_Upgrades_Effects_Event_Upgrades_Labels.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20200216143942_MoreGraularAttackSpeedOptions.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20200216143942_MoreGraularAttackSpeedOptions.Designer.cs index a66a6a93c9..508e3cec54 100644 --- a/Intersect.Server/Migrations/MySql/Game/20200216143942_MoreGraularAttackSpeedOptions.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20200216143942_MoreGraularAttackSpeedOptions.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20201001163344_ItemAndSpellCooldownImprovements.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20201001163344_ItemAndSpellCooldownImprovements.Designer.cs index dd3f2a3471..2365d777e3 100644 --- a/Intersect.Server/Migrations/MySql/Game/20201001163344_ItemAndSpellCooldownImprovements.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20201001163344_ItemAndSpellCooldownImprovements.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20201004032158_EnablingCerasVersionTolerance.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20201004032158_EnablingCerasVersionTolerance.Designer.cs index 4d437b0052..6b20652e81 100644 --- a/Intersect.Server/Migrations/MySql/Game/20201004032158_EnablingCerasVersionTolerance.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20201004032158_EnablingCerasVersionTolerance.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20201016122614_AddItemAndNpcColors.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20201016122614_AddItemAndNpcColors.Designer.cs index 5e02cae268..51eed09560 100644 --- a/Intersect.Server/Migrations/MySql/Game/20201016122614_AddItemAndNpcColors.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20201016122614_AddItemAndNpcColors.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20201222164741_NpcResetRadius.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20201222164741_NpcResetRadius.Designer.cs index 449d606121..e219d1213b 100644 --- a/Intersect.Server/Migrations/MySql/Game/20201222164741_NpcResetRadius.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20201222164741_NpcResetRadius.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20210423131813_AddItemSpellIgnoreCdrOptions.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20210423131813_AddItemSpellIgnoreCdrOptions.Designer.cs index 0d66b35e8c..5c9afda4c7 100644 --- a/Intersect.Server/Migrations/MySql/Game/20210423131813_AddItemSpellIgnoreCdrOptions.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20210423131813_AddItemSpellIgnoreCdrOptions.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20210423141451_AddIndividualizedLootOptionToNpcs.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20210423141451_AddIndividualizedLootOptionToNpcs.Designer.cs index 0c826e9363..0faa70d071 100644 --- a/Intersect.Server/Migrations/MySql/Game/20210423141451_AddIndividualizedLootOptionToNpcs.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20210423141451_AddIndividualizedLootOptionToNpcs.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20210509070229_AddingQuestCategoriesAndOrderValues.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20210509070229_AddingQuestCategoriesAndOrderValues.Designer.cs index 663434c955..57f816ff90 100644 --- a/Intersect.Server/Migrations/MySql/Game/20210509070229_AddingQuestCategoriesAndOrderValues.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20210509070229_AddingQuestCategoriesAndOrderValues.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20210512071349_BoundItemExtension.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20210512071349_BoundItemExtension.Designer.cs index b3a87ec24e..0d3ca15d1b 100644 --- a/Intersect.Server/Migrations/MySql/Game/20210512071349_BoundItemExtension.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20210512071349_BoundItemExtension.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20210513080440_AddItemStackCaps.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20210513080440_AddItemStackCaps.Designer.cs index caef1a0bba..c1c772657b 100644 --- a/Intersect.Server/Migrations/MySql/Game/20210513080440_AddItemStackCaps.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20210513080440_AddItemStackCaps.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20210607115442_AddedCanGuildBankOptionToItems.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20210607115442_AddedCanGuildBankOptionToItems.Designer.cs index c6fe256722..3353d763f0 100644 --- a/Intersect.Server/Migrations/MySql/Game/20210607115442_AddedCanGuildBankOptionToItems.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20210607115442_AddedCanGuildBankOptionToItems.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20210611154131_AddingGuildVariables.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20210611154131_AddingGuildVariables.Designer.cs index 5289449fe6..5c57340fe0 100644 --- a/Intersect.Server/Migrations/MySql/Game/20210611154131_AddingGuildVariables.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20210611154131_AddingGuildVariables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20210622051409_AddingRequirementNotMetMessages.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20210622051409_AddingRequirementNotMetMessages.Designer.cs index 4add08965a..afb0c3c68e 100644 --- a/Intersect.Server/Migrations/MySql/Game/20210622051409_AddingRequirementNotMetMessages.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20210622051409_AddingRequirementNotMetMessages.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20210630114724_CraftingCommonEvents.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20210630114724_CraftingCommonEvents.Designer.cs index 49588f705e..04b11fb26d 100644 --- a/Intersect.Server/Migrations/MySql/Game/20210630114724_CraftingCommonEvents.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20210630114724_CraftingCommonEvents.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20210703145618_AddingShopSoundEffects.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20210703145618_AddingShopSoundEffects.Designer.cs index ef024f0eaa..30b2c8c6ea 100644 --- a/Intersect.Server/Migrations/MySql/Game/20210703145618_AddingShopSoundEffects.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20210703145618_AddingShopSoundEffects.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20210815153451_TickAnimationMigration.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20210815153451_TickAnimationMigration.Designer.cs index 52ef2837cb..12b03e8fbe 100644 --- a/Intersect.Server/Migrations/MySql/Game/20210815153451_TickAnimationMigration.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20210815153451_TickAnimationMigration.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20211026130945_NpcImmunityMigration.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20211026130945_NpcImmunityMigration.Designer.cs index 3e02a5f294..6e4eb0122e 100644 --- a/Intersect.Server/Migrations/MySql/Game/20211026130945_NpcImmunityMigration.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20211026130945_NpcImmunityMigration.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20211031200145_FixQuestTaskCompletionEvents.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20211031200145_FixQuestTaskCompletionEvents.Designer.cs index 5ed4107742..b03a8571ac 100644 --- a/Intersect.Server/Migrations/MySql/Game/20211031200145_FixQuestTaskCompletionEvents.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20211031200145_FixQuestTaskCompletionEvents.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20220415212418_BlockProperties.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20220415212418_BlockProperties.Designer.cs index 0b68ac6d82..76bf79e8c5 100644 --- a/Intersect.Server/Migrations/MySql/Game/20220415212418_BlockProperties.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20220415212418_BlockProperties.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20220417193749_RandomCrafting.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20220417193749_RandomCrafting.Designer.cs index 9a582af3ee..624941d99b 100644 --- a/Intersect.Server/Migrations/MySql/Game/20220417193749_RandomCrafting.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20220417193749_RandomCrafting.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20220624102443_AddingHideEquipmentMapProperty.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20220624102443_AddingHideEquipmentMapProperty.Designer.cs index 2c4704fa30..23d4b7213d 100644 --- a/Intersect.Server/Migrations/MySql/Game/20220624102443_AddingHideEquipmentMapProperty.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20220624102443_AddingHideEquipmentMapProperty.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20220708174300_GrappleOptions.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20220708174300_GrappleOptions.Designer.cs index 0d2914bb22..0ac201e749 100644 --- a/Intersect.Server/Migrations/MySql/Game/20220708174300_GrappleOptions.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20220708174300_GrappleOptions.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20220831194419_AddedCraftRequirements.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20220831194419_AddedCraftRequirements.Designer.cs index 39a79519f9..b8b85be9c2 100644 --- a/Intersect.Server/Migrations/MySql/Game/20220831194419_AddedCraftRequirements.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20220831194419_AddedCraftRequirements.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20220925050711_CustomAnimations.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20220925050711_CustomAnimations.Designer.cs index f0d0135e3c..6799f293a4 100644 --- a/Intersect.Server/Migrations/MySql/Game/20220925050711_CustomAnimations.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20220925050711_CustomAnimations.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20220926042726_AddedConfigurableItemDespawnTimes.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20220926042726_AddedConfigurableItemDespawnTimes.Designer.cs index 81108a1014..6ac92af566 100644 --- a/Intersect.Server/Migrations/MySql/Game/20220926042726_AddedConfigurableItemDespawnTimes.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20220926042726_AddedConfigurableItemDespawnTimes.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20221016001123_MultipleBonusEffectsMigration.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20221016001123_MultipleBonusEffectsMigration.Designer.cs index 82d67156f1..15c45bead7 100644 --- a/Intersect.Server/Migrations/MySql/Game/20221016001123_MultipleBonusEffectsMigration.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20221016001123_MultipleBonusEffectsMigration.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20221016173617_AddUserVariables.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20221016173617_AddUserVariables.Designer.cs index 6d6e215cb8..910fa7811b 100644 --- a/Intersect.Server/Migrations/MySql/Game/20221016173617_AddUserVariables.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20221016173617_AddUserVariables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20221017220000_DropColumns.designer.cs b/Intersect.Server/Migrations/MySql/Game/20221017220000_DropColumns.designer.cs index 2460831345..07bc4d0dd1 100644 --- a/Intersect.Server/Migrations/MySql/Game/20221017220000_DropColumns.designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20221017220000_DropColumns.designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Game/20221018220000_PatchTables.Designer.cs b/Intersect.Server/Migrations/MySql/Game/20221018220000_PatchTables.Designer.cs index 0a620c5c95..e68f06b846 100644 --- a/Intersect.Server/Migrations/MySql/Game/20221018220000_PatchTables.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Game/20221018220000_PatchTables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.GameData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Logging/20191118024649_RequestLogs.Designer.cs b/Intersect.Server/Migrations/MySql/Logging/20191118024649_RequestLogs.Designer.cs index 5dacc6b34e..fd3cffdd65 100644 --- a/Intersect.Server/Migrations/MySql/Logging/20191118024649_RequestLogs.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Logging/20191118024649_RequestLogs.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.Logging; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Logging/20201119230003_AddUserActivityHistory.Designer.cs b/Intersect.Server/Migrations/MySql/Logging/20201119230003_AddUserActivityHistory.Designer.cs index 8fe81447b9..2b960613a4 100644 --- a/Intersect.Server/Migrations/MySql/Logging/20201119230003_AddUserActivityHistory.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Logging/20201119230003_AddUserActivityHistory.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.Logging; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Logging/20210414222302_AddedChatLogging.Designer.cs b/Intersect.Server/Migrations/MySql/Logging/20210414222302_AddedChatLogging.Designer.cs index f3ea3a8d37..fffff3f2d7 100644 --- a/Intersect.Server/Migrations/MySql/Logging/20210414222302_AddedChatLogging.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Logging/20210414222302_AddedChatLogging.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.Logging; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Logging/20210515114555_LogPlayerTrades.Designer.cs b/Intersect.Server/Migrations/MySql/Logging/20210515114555_LogPlayerTrades.Designer.cs index e950f47c9e..3dd16ae1c6 100644 --- a/Intersect.Server/Migrations/MySql/Logging/20210515114555_LogPlayerTrades.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Logging/20210515114555_LogPlayerTrades.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.Logging; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Logging/20210519095613_AddGuildActivityLogging.Designer.cs b/Intersect.Server/Migrations/MySql/Logging/20210519095613_AddGuildActivityLogging.Designer.cs index 93fe129ac8..553d31b592 100644 --- a/Intersect.Server/Migrations/MySql/Logging/20210519095613_AddGuildActivityLogging.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Logging/20210519095613_AddGuildActivityLogging.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.Logging; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20180927161502_InitialPlayerDb.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20180927161502_InitialPlayerDb.Designer.cs index c5d21c073e..a32fe3adbc 100644 --- a/Intersect.Server/Migrations/MySql/Player/20180927161502_InitialPlayerDb.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20180927161502_InitialPlayerDb.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20190310001204_AddRefreshTokens.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20190310001204_AddRefreshTokens.Designer.cs index 88af8ede18..c9317faccc 100644 --- a/Intersect.Server/Migrations/MySql/Player/20190310001204_AddRefreshTokens.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20190310001204_AddRefreshTokens.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20190310013418_StandardizeVocabulary1.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20190310013418_StandardizeVocabulary1.Designer.cs index f960667e69..4f4cff736b 100644 --- a/Intersect.Server/Migrations/MySql/Player/20190310013418_StandardizeVocabulary1.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20190310013418_StandardizeVocabulary1.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20190611170927_CombiningSwitchesVariables.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20190611170927_CombiningSwitchesVariables.Designer.cs index 4e0afe9c65..632d8ae4b6 100644 --- a/Intersect.Server/Migrations/MySql/Player/20190611170927_CombiningSwitchesVariables.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20190611170927_CombiningSwitchesVariables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20190804133420_Custom_Player_Name_Colors.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20190804133420_Custom_Player_Name_Colors.Designer.cs index 36c7785573..5fd9a95d93 100644 --- a/Intersect.Server/Migrations/MySql/Player/20190804133420_Custom_Player_Name_Colors.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20190804133420_Custom_Player_Name_Colors.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20191030214333_PlayerUpgrades_Labels.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20191030214333_PlayerUpgrades_Labels.Designer.cs index fdbc87b48d..a04c8245d0 100644 --- a/Intersect.Server/Migrations/MySql/Player/20191030214333_PlayerUpgrades_Labels.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20191030214333_PlayerUpgrades_Labels.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20191126025000_RefactoringCooldowns.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20191126025000_RefactoringCooldowns.Designer.cs index ed30d7ce4e..cb18a0a061 100644 --- a/Intersect.Server/Migrations/MySql/Player/20191126025000_RefactoringCooldowns.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20191126025000_RefactoringCooldowns.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20200205112316_FixingPlayerDeleteFriendsForeignKeyContraintFail.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20200205112316_FixingPlayerDeleteFriendsForeignKeyContraintFail.Designer.cs index aa9bbd6fad..0247c91b62 100644 --- a/Intersect.Server/Migrations/MySql/Player/20200205112316_FixingPlayerDeleteFriendsForeignKeyContraintFail.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20200205112316_FixingPlayerDeleteFriendsForeignKeyContraintFail.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20200301145105_SavingPlayerLabelsInDb.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20200301145105_SavingPlayerLabelsInDb.Designer.cs index 44a6a6f0cc..65505b5ccd 100644 --- a/Intersect.Server/Migrations/MySql/Player/20200301145105_SavingPlayerLabelsInDb.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20200301145105_SavingPlayerLabelsInDb.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20201017065035_AddColorToEntities.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20201017065035_AddColorToEntities.Designer.cs index 4c7d8e4900..e7f52ffd64 100644 --- a/Intersect.Server/Migrations/MySql/Player/20201017065035_AddColorToEntities.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20201017065035_AddColorToEntities.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20210414121435_TrackUserPlayerStats.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20210414121435_TrackUserPlayerStats.Designer.cs index 4098a5bfaf..e3d36462da 100644 --- a/Intersect.Server/Migrations/MySql/Player/20210414121435_TrackUserPlayerStats.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20210414121435_TrackUserPlayerStats.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20210503165540_AddingGuildsWithGuildBanks.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20210503165540_AddingGuildsWithGuildBanks.Designer.cs index efa3510696..b1bfca3d74 100644 --- a/Intersect.Server/Migrations/MySql/Player/20210503165540_AddingGuildsWithGuildBanks.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20210503165540_AddingGuildsWithGuildBanks.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20210510223205_TrackPlaytimeAsULongsInSeconds.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20210510223205_TrackPlaytimeAsULongsInSeconds.Designer.cs index c8431f11fa..fc8c84f46b 100644 --- a/Intersect.Server/Migrations/MySql/Player/20210510223205_TrackPlaytimeAsULongsInSeconds.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20210510223205_TrackPlaytimeAsULongsInSeconds.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20210611184605_AddingGuildVariables.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20210611184605_AddingGuildVariables.Designer.cs index 9b6a667786..07d83ac15c 100644 --- a/Intersect.Server/Migrations/MySql/Player/20210611184605_AddingGuildVariables.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20210611184605_AddingGuildVariables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20220331140427_GuildBankMaxSlotsMigration.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20220331140427_GuildBankMaxSlotsMigration.Designer.cs index a9c3047ffb..cc5a93fa44 100644 --- a/Intersect.Server/Migrations/MySql/Player/20220331140427_GuildBankMaxSlotsMigration.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20220331140427_GuildBankMaxSlotsMigration.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20220403141119_InstanceWarpMigration.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20220403141119_InstanceWarpMigration.Designer.cs index be8098c603..82b8c2e238 100644 --- a/Intersect.Server/Migrations/MySql/Player/20220403141119_InstanceWarpMigration.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20220403141119_InstanceWarpMigration.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20221016173603_AddUserVariables.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20221016173603_AddUserVariables.Designer.cs index 25f8f0f1d8..1cb6b40d89 100644 --- a/Intersect.Server/Migrations/MySql/Player/20221016173603_AddUserVariables.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20221016173603_AddUserVariables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20221017220000_DropColumns.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20221017220000_DropColumns.Designer.cs index 9ca8bcd34c..8bf3dd8472 100644 --- a/Intersect.Server/Migrations/MySql/Player/20221017220000_DropColumns.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20221017220000_DropColumns.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20221018220000_PatchTables.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20221018220000_PatchTables.Designer.cs index 3b954d7501..39914622e8 100644 --- a/Intersect.Server/Migrations/MySql/Player/20221018220000_PatchTables.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20221018220000_PatchTables.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Migrations/MySql/Player/20221119214350_ItemProperties.Designer.cs b/Intersect.Server/Migrations/MySql/Player/20221119214350_ItemProperties.Designer.cs index 7bc8f9d229..abc0145435 100644 --- a/Intersect.Server/Migrations/MySql/Player/20221119214350_ItemProperties.Designer.cs +++ b/Intersect.Server/Migrations/MySql/Player/20221119214350_ItemProperties.Designer.cs @@ -1,5 +1,4 @@ // - using Intersect.Server.Database.PlayerData; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; diff --git a/Intersect.Server/Networking/Helpers/NetDebug.cs b/Intersect.Server/Networking/Helpers/NetDebug.cs index 8b8f57a03e..d8f17b199f 100644 --- a/Intersect.Server/Networking/Helpers/NetDebug.cs +++ b/Intersect.Server/Networking/Helpers/NetDebug.cs @@ -4,7 +4,6 @@ using System.Text; using Intersect.Server.Core; using Intersect.Server.Localization; - using Newtonsoft.Json; namespace Intersect.Server.Networking.Helpers @@ -204,7 +203,7 @@ public static IEnumerable GetTraceRoute(string hostname) // } // catch (Exception exception) // { - // Log.Warn(exception); + // ApplicationContext.Context.Value?.Logger.LogWarning(exception); // } // finally // { diff --git a/Intersect.Server/Networking/Helpers/PortChecker.cs b/Intersect.Server/Networking/Helpers/PortChecker.cs index 60df28df2e..d7542aab26 100644 --- a/Intersect.Server/Networking/Helpers/PortChecker.cs +++ b/Intersect.Server/Networking/Helpers/PortChecker.cs @@ -1,7 +1,7 @@ using System.Globalization; using System.Net; using System.Security.Cryptography; -using Intersect.Logging; +using Intersect.Core; using Microsoft.AspNetCore.WebUtilities; namespace Intersect.Server.Networking.Helpers; @@ -53,7 +53,7 @@ public static PortCheckResult CanYouSeeMe(int port, out string externalIp) if (responseMessage.StatusCode != HttpStatusCode.OK) { var statusCodePrefix = (int)responseMessage.StatusCode / 100; - Log.Debug($"Received {statusCodePrefix} from port checker service"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Received {statusCodePrefix} from port checker service"); return statusCodePrefix switch { 1 => PortCheckResult.PortCheckerServerUnexpectedResponse, @@ -67,7 +67,7 @@ public static PortCheckResult CanYouSeeMe(int port, out string externalIp) if (!responseMessage.Headers.Any()) { - Log.Debug("Received no headers from port checker service."); + ApplicationContext.Context.Value?.Logger.LogDebug("Received no headers from port checker service."); return PortCheckResult.Inaccessible; } @@ -89,33 +89,33 @@ public static PortCheckResult CanYouSeeMe(int port, out string externalIp) responseTime = DateTimeFrom(responseTimeValues); } - Log.Verbose($"Port checker service received request after {(requestTime - time).TotalMilliseconds}ms."); - Log.Verbose($"Port checker service responded to the request after {(responseTime - requestTime).TotalMilliseconds}ms."); - Log.Verbose($"Port checker service response was received after {(receivedResponseTime - responseTime).TotalMilliseconds}ms."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Port checker service received request after {(requestTime - time).TotalMilliseconds}ms."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Port checker service responded to the request after {(responseTime - requestTime).TotalMilliseconds}ms."); + ApplicationContext.Context.Value?.Logger.LogDebug($"Port checker service response was received after {(receivedResponseTime - responseTime).TotalMilliseconds}ms."); if (!responseMessage.Headers.TryGetValues("ip", out var ipValues)) { - Log.Debug("Received no 'ip' header from port checker service."); + ApplicationContext.Context.Value?.Logger.LogDebug("Received no 'ip' header from port checker service."); return PortCheckResult.InvalidPortCheckerResponse; } externalIp = ipValues.FirstOrDefault(value => !string.IsNullOrWhiteSpace(value)); if (string.IsNullOrWhiteSpace(externalIp)) { - Log.Debug("Received empty 'ip' header from port checker service."); + ApplicationContext.Context.Value?.Logger.LogDebug("Received empty 'ip' header from port checker service."); return PortCheckResult.InvalidPortCheckerResponse; } if (!responseMessage.Headers.TryGetValues("secret", out var portCheckerSecretValues)) { - Log.Debug("Received no 'secret' header from port checker service."); + ApplicationContext.Context.Value?.Logger.LogDebug("Received no 'secret' header from port checker service."); return PortCheckResult.InvalidPortCheckerResponse; } var portCheckerSecret = portCheckerSecretValues.FirstOrDefault(value => !string.IsNullOrWhiteSpace(value)); if (string.IsNullOrWhiteSpace(portCheckerSecret)) { - Log.Debug("Received empty 'secret' header from port checker service."); + ApplicationContext.Context.Value?.Logger.LogDebug("Received empty 'secret' header from port checker service."); return PortCheckResult.InvalidPortCheckerResponse; } @@ -124,12 +124,12 @@ public static PortCheckResult CanYouSeeMe(int port, out string externalIp) return PortCheckResult.Open; } - Log.Debug($"Received invalid 'secret' header from port checker service: {portCheckerSecret}"); + ApplicationContext.Context.Value?.Logger.LogDebug($"Received invalid 'secret' header from port checker service: {portCheckerSecret}"); return PortCheckResult.InvalidPortCheckerResponse; } catch (HttpRequestException httpRequestException) { - Log.Debug(httpRequestException); + ApplicationContext.Context.Value?.Logger.LogDebug(httpRequestException, "HTTP request failed"); return httpRequestException.StatusCode.HasValue ? PortCheckResult.PortCheckerServerError @@ -137,12 +137,12 @@ public static PortCheckResult CanYouSeeMe(int port, out string externalIp) } catch (TaskCanceledException taskCanceledException) { - Log.Debug(taskCanceledException.Message); + ApplicationContext.Context.Value?.Logger.LogDebug(taskCanceledException.Message); return PortCheckResult.PortCheckerServerError; } catch (Exception exception) { - Log.Debug(exception); + ApplicationContext.Context.Value?.Logger.LogDebug(exception, "General error occurred"); return PortCheckResult.PortCheckerServerError; } } diff --git a/Intersect.Server/Networking/Helpers/UPnP.cs b/Intersect.Server/Networking/Helpers/UPnP.cs index 5548da66a3..6312812a01 100644 --- a/Intersect.Server/Networking/Helpers/UPnP.cs +++ b/Intersect.Server/Networking/Helpers/UPnP.cs @@ -1,7 +1,6 @@ using System.Text; -using Intersect.Logging; +using Intersect.Core; using Intersect.Server.Localization; - using Open.Nat; namespace Intersect.Server.Networking.Helpers @@ -26,12 +25,12 @@ public static async Task ConnectNatDevice() var cts = new CancellationTokenSource(5000); sDevice = await nat.DiscoverDeviceAsync(PortMapper.Upnp, cts); sExternalIp = (await sDevice.GetExternalIPAsync()).ToString(); - Log.Pretty.Info(Strings.Upnp.Initialized); + ApplicationContext.Context.Value?.Logger.LogInformation(Strings.Upnp.Initialized); sLog.AppendLine("Connected to UPnP device: " + sDevice.ToString()); } catch (Exception exception) { - Log.Pretty.Error(exception, Strings.Upnp.InitializationFailed); + ApplicationContext.Context.Value?.Logger.LogError(exception, Strings.Upnp.InitializationFailed); sLog.AppendLine(Strings.Upnp.InitializationFailed); sLog.AppendLine("UPnP Initialization Error: " + exception.ToString()); } @@ -58,13 +57,13 @@ public static async Task OpenServerPort(int port, Protocol protocol) switch (protocol) { case Protocol.Tcp: - Log.Pretty.Info(Strings.Upnp.ForwardedTcp.ToString(port)); + ApplicationContext.Context.Value?.Logger.LogInformation(Strings.Upnp.ForwardedTcp.ToString(port)); sLog.AppendLine(Strings.Upnp.ForwardedTcp.ToString(port)); break; case Protocol.Udp: - Log.Pretty.Info(Strings.Upnp.ForwardedUdp.ToString(port)); + ApplicationContext.Context.Value?.Logger.LogInformation(Strings.Upnp.ForwardedUdp.ToString(port)); sLog.AppendLine(Strings.Upnp.ForwardedUdp.ToString(port)); sPortForwarded = true; @@ -79,15 +78,15 @@ public static async Task OpenServerPort(int port, Protocol protocol) switch (protocol) { case Protocol.Tcp: - Log.Pretty.Warn(Strings.Upnp.FailedForwardingTcp.ToString(port)); - Log.Warn("UPnP Could Not Open TCP Port " + port + Environment.NewLine + ex.ToString()); + ApplicationContext.Context.Value?.Logger.LogWarning(Strings.Upnp.FailedForwardingTcp.ToString(port)); + ApplicationContext.Context.Value?.Logger.LogWarning("UPnP Could Not Open TCP Port " + port + Environment.NewLine + ex.ToString()); sLog.AppendLine("UPnP Could Not Open TCP Port " + port + Environment.NewLine + ex.ToString()); break; case Protocol.Udp: - Log.Pretty.Warn(Strings.Upnp.FailedForwardingUdp.ToString(port)); - Log.Warn("UPnP Could Not Open UDP Port " + port + Environment.NewLine + ex.ToString()); + ApplicationContext.Context.Value?.Logger.LogWarning(Strings.Upnp.FailedForwardingUdp.ToString(port)); + ApplicationContext.Context.Value?.Logger.LogWarning("UPnP Could Not Open UDP Port " + port + Environment.NewLine + ex.ToString()); sLog.AppendLine("UPnP Could Not Open UDP Port " + port + Environment.NewLine + ex.ToString()); break; diff --git a/Intersect.Server/Networking/IntersectNetworkServer.cs b/Intersect.Server/Networking/IntersectNetworkServer.cs index 52833c3aa5..b2acadac06 100644 --- a/Intersect.Server/Networking/IntersectNetworkServer.cs +++ b/Intersect.Server/Networking/IntersectNetworkServer.cs @@ -2,7 +2,6 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Security.Cryptography; -using Intersect.Logging; using Intersect.Network; using Intersect.Network.Packets.Reflectable; using Intersect.Server.Classes.Networking; @@ -34,20 +33,20 @@ public IntersectNetworkServer(NetworkConfiguration configuration, RSAParameters protected virtual void HandleInterfaceOnConnected(INetworkLayerInterface sender, IConnection connection) { - Log.Info($"Connected [{connection?.Guid}]."); + ApplicationContext.Context.Value?.Logger.LogInformation($"Connected [{connection?.Guid}]."); new IntersectNetworkSocket(connection).CreateClient(); OnConnected?.Invoke(sender, connection); } protected virtual void HandleInterfaceOnConnectonApproved(INetworkLayerInterface sender, IConnection connection) { - Log.Info($"Connection approved [{connection?.Guid}]."); + ApplicationContext.Context.Value?.Logger.LogInformation($"Connection approved [{connection?.Guid}]."); OnConnectionApproved?.Invoke(sender, connection); } protected virtual void HandleInterfaceOnDisconnected(INetworkLayerInterface sender, IConnection connection) { - Log.Info($"Disconnected [{connection?.Guid}]."); + ApplicationContext.Context.Value?.Logger.LogInformation($"Disconnected [{connection?.Guid}]."); ((Client) connection.UserData).Disconnect(); OnDisconnected?.Invoke(sender, connection); } diff --git a/Intersect.Server/Networking/IntersectNetworkSocket.cs b/Intersect.Server/Networking/IntersectNetworkSocket.cs index 726dbcf0d3..f34f7cdad6 100644 --- a/Intersect.Server/Networking/IntersectNetworkSocket.cs +++ b/Intersect.Server/Networking/IntersectNetworkSocket.cs @@ -3,7 +3,6 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -using Intersect.Logging; using Intersect.Network; using Intersect.Network.Packets.Reflectable; using Intersect.Server.Classes.General; @@ -49,7 +48,7 @@ public override void SendData(ByteBuffer bf) } catch (Exception ex) { - Log.Trace(ex); + ApplicationContext.Context.Value?.Logger.LogTrace(ex); HandleDisconnect(); } } diff --git a/Intersect.Server/Networking/LiteNetLib/ServerNetwork.LiteNetLib.cs b/Intersect.Server/Networking/LiteNetLib/ServerNetwork.LiteNetLib.cs index c8eacac56e..108be8629c 100644 --- a/Intersect.Server/Networking/LiteNetLib/ServerNetwork.LiteNetLib.cs +++ b/Intersect.Server/Networking/LiteNetLib/ServerNetwork.LiteNetLib.cs @@ -3,7 +3,6 @@ using System.Security.Cryptography; using Amib.Threading; using Intersect.Core; -using Intersect.Logging; using Intersect.Memory; using Intersect.Network; using Intersect.Network.Events; @@ -11,7 +10,6 @@ using Intersect.Server.Core; using Intersect.Server.Networking.Helpers; using LiteNetLib.Utils; -using LogLevel = Intersect.Logging.LogLevel; namespace Intersect.Server.Networking.LiteNetLib; @@ -67,7 +65,7 @@ protected virtual void HandleInterfaceOnConnected( ConnectionEventArgs connectionEventArgs ) { - Log.Info($"Connected [{connectionEventArgs.Connection?.Guid}]."); + ApplicationContext.Logger.LogInformation($"Connected [{connectionEventArgs.Connection?.Guid}]."); var client = Client.CreateBeta4Client(Context, this, connectionEventArgs.Connection); PacketSender.SendPing(client); OnConnected?.Invoke(sender, connectionEventArgs); @@ -78,7 +76,7 @@ protected virtual void HandleInterfaceOnConnectonApproved( ConnectionEventArgs connectionEventArgs ) { - Log.Info($"Connection approved [{connectionEventArgs.Connection?.Guid}]."); + ApplicationContext.Logger.LogInformation($"Connection approved [{connectionEventArgs.Connection?.Guid}]."); OnConnectionApproved?.Invoke(sender, connectionEventArgs); } @@ -87,7 +85,7 @@ protected virtual void HandleInterfaceOnDisconnected( ConnectionEventArgs connectionEventArgs ) { - Log.Info($"Disconnected [{connectionEventArgs.Connection?.Guid}]."); + ApplicationContext.Logger.LogInformation($"Disconnected [{connectionEventArgs.Connection?.Guid}]."); Client.RemoveBeta4Client(connectionEventArgs.Connection); OnDisconnected?.Invoke(sender, connectionEventArgs); } @@ -112,17 +110,14 @@ protected virtual void HandleOnUnconnectedMessage(UnconnectedMessageSender sende NetDataWriter checkPortResponse = new(); checkPortResponse.Put(PortChecker.Secret); checkPortResponse.Put(guidData); - Log.Debug($"Responding to port checker service with {new Guid(guidData)}"); + ApplicationContext.Logger.LogDebug($"Responding to port checker service with {new Guid(guidData)}"); sender.Reply(checkPortResponse.CopyData()); break; } } catch (Exception exception) { - if (Log.Default.Configuration.LogLevel > LogLevel.Info) - { - Log.Error(exception); - } + ApplicationContext.Logger.LogError(exception, "Error on unconnected message"); } } diff --git a/Intersect.Server/Networking/NetworkedPacketHandler.cs b/Intersect.Server/Networking/NetworkedPacketHandler.cs index 4b30ead70e..d74b0f55bf 100644 --- a/Intersect.Server/Networking/NetworkedPacketHandler.cs +++ b/Intersect.Server/Networking/NetworkedPacketHandler.cs @@ -1,3 +1,4 @@ +using Intersect.Core; using Intersect.Enums; using Intersect.Framework.Core.GameObjects.Variables; using Intersect.GameObjects; @@ -5,7 +6,6 @@ using Intersect.GameObjects.Events; using Intersect.GameObjects.Maps; using Intersect.GameObjects.Maps.MapList; -using Intersect.Logging; using Intersect.Models; using Intersect.Network.Packets.Client; using Intersect.Server.Admin.Actions; @@ -494,7 +494,7 @@ public void HandlePacket(Client client, Network.Packets.Editor.MapListUpdatePack parent = MapList.List.FindFolder(packet.TargetId); if (parent == default) { - Log.Warn($"Tried to rename {nameof(MapListFolder)} {packet.TargetId} but it was not found."); + ApplicationContext.Context.Value?.Logger.LogWarning($"Tried to rename {nameof(MapListFolder)} {packet.TargetId} but it was not found."); return; } @@ -507,13 +507,13 @@ public void HandlePacket(Client client, Network.Packets.Editor.MapListUpdatePack var mapListMap = MapList.List.FindMap(packet.TargetId); if (mapListMap == default) { - Log.Warn($"Tried to rename {nameof(MapListMap)} {packet.TargetId} but it was not found in the map list."); + ApplicationContext.Context.Value?.Logger.LogWarning($"Tried to rename {nameof(MapListMap)} {packet.TargetId} but it was not found in the map list."); return; } if (!MapController.TryGet(packet.TargetId, out var mapToRename)) { - Log.Warn($"Tried to rename {nameof(MapListMap)} {packet.TargetId} but the map itself could not be found."); + ApplicationContext.Context.Value?.Logger.LogWarning($"Tried to rename {nameof(MapListMap)} {packet.TargetId} but the map itself could not be found."); return; } @@ -535,7 +535,7 @@ public void HandlePacket(Client client, Network.Packets.Editor.MapListUpdatePack { if (MapController.Lookup == default) { - Log.Warn($"Tried to delete {nameof(MapListMap)} {packet.TargetId} but the {nameof(MapController)}.{nameof(MapController.Lookup)} was null?"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Tried to delete {nameof(MapListMap)} {packet.TargetId} but the {nameof(MapController)}.{nameof(MapController.Lookup)} was null?"); return; } @@ -549,26 +549,26 @@ public void HandlePacket(Client client, Network.Packets.Editor.MapListUpdatePack var logicLock = logicService?.LogicLock; if (logicLock == default) { - Log.Error($"{nameof(ServerContext)}.{nameof(ServerContext.Instance)}.{nameof(ServerContext.LogicService)}.{nameof(LogicService.LogicLock)} was unexpectedly null when try to delete {nameof(MapListMap)} {packet.TargetId}."); + ApplicationContext.Context.Value?.Logger.LogError($"{nameof(ServerContext)}.{nameof(ServerContext.Instance)}.{nameof(ServerContext.LogicService)}.{nameof(LogicService.LogicLock)} was unexpectedly null when try to delete {nameof(MapListMap)} {packet.TargetId}."); return; } var logicPool = logicService.LogicPool; if (logicPool == default) { - Log.Error($"{nameof(ServerContext)}.{nameof(ServerContext.Instance)}.{nameof(ServerContext.LogicService)}.{nameof(LogicService.LogicPool)} was unexpectedly null when try to delete {nameof(MapListMap)} {packet.TargetId}."); + ApplicationContext.Context.Value?.Logger.LogError($"{nameof(ServerContext)}.{nameof(ServerContext.Instance)}.{nameof(ServerContext.LogicService)}.{nameof(LogicService.LogicPool)} was unexpectedly null when try to delete {nameof(MapListMap)} {packet.TargetId}."); return; } if (!MapController.TryGet(packet.TargetId, out var mapToDelete)) { - Log.Warn($"Tried to delete {nameof(MapListMap)} {packet.TargetId} but the map itself could not be found."); + ApplicationContext.Context.Value?.Logger.LogWarning($"Tried to delete {nameof(MapListMap)} {packet.TargetId} but the map itself could not be found."); return; } if (!(mapToDelete is MapController mapController)) { - Log.Warn($"Tried to delete {nameof(MapListMap)} {packet.TargetId} but {nameof(MapController)}.{nameof(MapController.TryGet)} returned something other than a {nameof(MapController)}."); + ApplicationContext.Context.Value?.Logger.LogWarning($"Tried to delete {nameof(MapListMap)} {packet.TargetId} but {nameof(MapController)}.{nameof(MapController.TryGet)} returned something other than a {nameof(MapController)}."); return; } diff --git a/Intersect.Server/Notifications/Notification.cs b/Intersect.Server/Notifications/Notification.cs index a8dc1ca4bb..0cc71606ed 100644 --- a/Intersect.Server/Notifications/Notification.cs +++ b/Intersect.Server/Notifications/Notification.cs @@ -1,4 +1,4 @@ -using Intersect.Logging; +using Intersect.Core; using Intersect.Server.Localization; using MailKit.Net.Smtp; using MailKit.Security; @@ -68,7 +68,7 @@ public bool Send() } catch (Exception ex) { - Log.Error( + ApplicationContext.Context.Value?.Logger.LogError( "Failed to send email (Subject: " + Subject + ") to " + @@ -82,7 +82,7 @@ public bool Send() } else { - Log.Warn( + ApplicationContext.Context.Value?.Logger.LogWarning( "Failed to send email (Subject: " + Subject + ") to " + @@ -94,7 +94,7 @@ public bool Send() } else { - Log.Warn( + ApplicationContext.Context.Value?.Logger.LogWarning( "Failed to send email (Subject: " + Subject + ") to " + ToAddress + ". Reason: SMTP not configured!" ); return false; @@ -122,7 +122,7 @@ protected bool LoadFromTemplate(string templatename, string username) } else { - Log.Warn( + ApplicationContext.Context.Value?.Logger.LogWarning( "Failed to load email template (Subject: " + Subject + ") for " + diff --git a/Intersect.Server/Web/ApiService.AppSettings.cs b/Intersect.Server/Web/ApiService.AppSettings.cs index 8ec94fbabb..96520d1266 100644 --- a/Intersect.Server/Web/ApiService.AppSettings.cs +++ b/Intersect.Server/Web/ApiService.AppSettings.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; -using Intersect.Logging; +using Intersect.Core; using Intersect.Server.Web.Configuration; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.IdentityModel.Tokens; @@ -16,7 +16,7 @@ internal partial class ApiService private static void UnpackAppSettings() { - Log.Info("Unpacking appsettings..."); + ApplicationContext.Context.Value?.Logger.LogInformation("Unpacking appsettings..."); var hostBuilder = Host.CreateApplicationBuilder(); var names = new[] { "appsettings.json", $"appsettings.{hostBuilder.Environment.EnvironmentName}.json" }; @@ -29,24 +29,24 @@ private static void UnpackAppSettings() { if (string.IsNullOrWhiteSpace(mrn) || string.IsNullOrWhiteSpace(name)) { - Log.Warn($"Manifest resource name or file name is null/empty: ({mrn}, {name})"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Manifest resource name or file name is null/empty: ({mrn}, {name})"); continue; } if (File.Exists(name)) { - Log.Debug($"'{name}' already exists, not unpacking '{mrn}'"); + ApplicationContext.Context.Value?.Logger.LogDebug($"'{name}' already exists, not unpacking '{mrn}'"); continue; } using var mrs = Assembly.GetManifestResourceStream(mrn); if (mrs == default) { - Log.Warn($"Unable to open stream for embedded content: '{mrn}'"); + ApplicationContext.Context.Value?.Logger.LogWarning($"Unable to open stream for embedded content: '{mrn}'"); continue; } - Log.Info($"Unpacking '{name}' in {Environment.CurrentDirectory}"); + ApplicationContext.Context.Value?.Logger.LogInformation($"Unpacking '{name}' in {Environment.CurrentDirectory}"); using var fs = File.OpenWrite(name); mrs.CopyTo(fs); @@ -209,7 +209,10 @@ out var validIssuerToken } catch (Exception exception) { - Log.Warn(exception); + ApplicationContext.Context.Value?.Logger.LogWarning( + exception, + "Error creating self-signed certificate" + ); } } } diff --git a/Intersect.Server/Web/ApiService.cs b/Intersect.Server/Web/ApiService.cs index 6aa84f7e0c..1098e1a783 100644 --- a/Intersect.Server/Web/ApiService.cs +++ b/Intersect.Server/Web/ApiService.cs @@ -7,7 +7,6 @@ using Intersect.Core; using Intersect.Enums; using Intersect.Framework.Reflection; -using Intersect.Logging; using Intersect.Security.Claims; using Intersect.Server.Core; using Intersect.Server.Database.PlayerData.Api; @@ -67,7 +66,7 @@ internal partial class ApiService : ApplicationService @@ -39,7 +38,7 @@ public static void UseIntersectRequestLogging(this WebApplication app, LogLevel } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error invoking next handler"); internalServerError = true; } @@ -99,7 +98,7 @@ public static void UseIntersectRequestLogging(this WebApplication app, LogLevel } catch (Exception exception) { - Log.Error(exception); + ApplicationContext.Context.Value?.Logger.LogError(exception, "Error processing request"); throw; } diff --git a/Intersect.Server/Web/Pages/Account/Login.cshtml b/Intersect.Server/Web/Pages/Account/Login.cshtml index 766af70534..049438ef28 100644 --- a/Intersect.Server/Web/Pages/Account/Login.cshtml +++ b/Intersect.Server/Web/Pages/Account/Login.cshtml @@ -1,4 +1,5 @@ @page +@using Microsoft.AspNetCore.Mvc.TagHelpers @model LoginModel @{ ViewData["Title"] = WebResources.Login; diff --git a/Intersect.Server/Web/Pages/Account/Logout.cshtml b/Intersect.Server/Web/Pages/Account/Logout.cshtml index c956f58730..4eadcdae27 100644 --- a/Intersect.Server/Web/Pages/Account/Logout.cshtml +++ b/Intersect.Server/Web/Pages/Account/Logout.cshtml @@ -1,4 +1,5 @@ @page +@using Microsoft.AspNetCore.Mvc.TagHelpers @model LogoutModel @{ ViewData["Title"] = WebResources.Logout; diff --git a/Intersect.Server/Web/Pages/Shared/_Toasts.cshtml b/Intersect.Server/Web/Pages/Shared/_Toasts.cshtml index 9ae97397d2..51adc5cf50 100644 --- a/Intersect.Server/Web/Pages/Shared/_Toasts.cshtml +++ b/Intersect.Server/Web/Pages/Shared/_Toasts.cshtml @@ -1,3 +1,4 @@ +@using Microsoft.AspNetCore.Mvc.TagHelpers @model ToastModel[] @foreach (var model in Model) diff --git a/Intersect.SinglePlayer/Networking/SinglePlayerNetwork.cs b/Intersect.SinglePlayer/Networking/SinglePlayerNetwork.cs index 2c60c39eb9..71cbd9588f 100644 --- a/Intersect.SinglePlayer/Networking/SinglePlayerNetwork.cs +++ b/Intersect.SinglePlayer/Networking/SinglePlayerNetwork.cs @@ -1,11 +1,11 @@ using System.Net; using Intersect.Core; -using Intersect.Logging; using Intersect.Network; using Intersect.Network.Packets.Client; using Intersect.Network.Packets.Unconnected.Client; using Intersect.Network.Packets.Unconnected.Server; using Intersect.Plugins.Interfaces; +using Microsoft.Extensions.Logging; namespace Intersect.SinglePlayer.Networking; @@ -49,7 +49,7 @@ public SinglePlayerNetwork(IApplicationContext applicationContext, NetworkPairAc public void Close() { - Log.Debug($"Disposing {nameof(SinglePlayerNetwork)}"); + ApplicationContext.Logger.LogDebug($"Disposing {nameof(SinglePlayerNetwork)}"); } public bool Connect() @@ -77,7 +77,7 @@ private void HandleConnection() public bool Disconnect(string? message = default) { - Log.Info(message); + ApplicationContext.Logger.LogInformation(message); return true; } @@ -91,7 +91,7 @@ public bool Disconnect(string? message = default) public void Dispose() { - Log.Debug($"Disposing {nameof(SinglePlayerNetwork)}"); + ApplicationContext.Logger.LogDebug($"Disposing {nameof(SinglePlayerNetwork)}"); } private bool Handle(IPacket packet) diff --git a/Intersect.Tests.Client/Stub.cs b/Intersect.Tests.Client/Stub.cs index 05524a44f0..463dfa4ddb 100644 --- a/Intersect.Tests.Client/Stub.cs +++ b/Intersect.Tests.Client/Stub.cs @@ -1,5 +1,4 @@ using Intersect.Client.Utilities; - using NUnit.Framework; namespace Intersect.Tests.Client diff --git a/Intersect.Tests/Extensions/DateTimeExtensionsTests.cs b/Intersect.Tests/Extensions/DateTimeExtensionsTests.cs index 9082c9aac1..c46a1cfa76 100644 --- a/Intersect.Tests/Extensions/DateTimeExtensionsTests.cs +++ b/Intersect.Tests/Extensions/DateTimeExtensionsTests.cs @@ -1,5 +1,4 @@ using NUnit.Framework; - using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert; namespace Intersect.Extensions diff --git a/Intersect.Tests/Extensions/GameObjectInfoAttributeTests.cs b/Intersect.Tests/Extensions/GameObjectInfoAttributeTests.cs index 0460524776..25a9d28357 100644 --- a/Intersect.Tests/Extensions/GameObjectInfoAttributeTests.cs +++ b/Intersect.Tests/Extensions/GameObjectInfoAttributeTests.cs @@ -1,5 +1,4 @@ using NUnit.Framework; - using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert; namespace Intersect.Extensions diff --git a/Intersect.Tests/Extensions/RandomExtensionsTests.cs b/Intersect.Tests/Extensions/RandomExtensionsTests.cs index 32fb37807f..dda484c38c 100644 --- a/Intersect.Tests/Extensions/RandomExtensionsTests.cs +++ b/Intersect.Tests/Extensions/RandomExtensionsTests.cs @@ -1,5 +1,4 @@ using NUnit.Framework; - using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert; namespace Intersect.Extensions diff --git a/Intersect.Tests/Factories/FactoryRegistryTests.cs b/Intersect.Tests/Factories/FactoryRegistryTests.cs index 36ca6bf244..d10a25b5ac 100644 --- a/Intersect.Tests/Factories/FactoryRegistryTests.cs +++ b/Intersect.Tests/Factories/FactoryRegistryTests.cs @@ -1,10 +1,8 @@ using System.Diagnostics; -using Intersect.Logging; using Moq; - using NUnit.Framework; - +using Serilog; using Assert = NUnit.Framework.Assert; namespace Intersect.Factories diff --git a/Intersect.Tests/IO/Files/FileSystemHelperTests.cs b/Intersect.Tests/IO/Files/FileSystemHelperTests.cs index 7ded49b1ce..925579abcb 100644 --- a/Intersect.Tests/IO/Files/FileSystemHelperTests.cs +++ b/Intersect.Tests/IO/Files/FileSystemHelperTests.cs @@ -1,5 +1,4 @@ using System.IO.Abstractions.TestingHelpers; - using NUnit.Framework; namespace Intersect.IO.Files diff --git a/Intersect.Tests/Network/PacketHandlerAttributeTests.cs b/Intersect.Tests/Network/PacketHandlerAttributeTests.cs index 30dbfe79bc..5b594e0c3d 100644 --- a/Intersect.Tests/Network/PacketHandlerAttributeTests.cs +++ b/Intersect.Tests/Network/PacketHandlerAttributeTests.cs @@ -1,5 +1,4 @@ using Intersect.Collections; - using NUnit.Framework; using System.Reflection; diff --git a/Intersect.Tests/Plugins/Loaders/ManifestLoaderTest.cs b/Intersect.Tests/Plugins/Loaders/ManifestLoaderTest.cs index 76bab691f7..3f8cf99b73 100644 --- a/Intersect.Tests/Plugins/Loaders/ManifestLoaderTest.cs +++ b/Intersect.Tests/Plugins/Loaders/ManifestLoaderTest.cs @@ -1,15 +1,12 @@ -using Intersect.Logging; + using Intersect.Plugins.Manifests; - using Moq; - using NUnit.Framework; - using Semver; using System.Reflection; - using Intersect.Plugins.Interfaces; using Intersect.Plugins.Manifests.Types; +using Serilog; namespace Intersect.Plugins.Loaders { diff --git a/Intersect.Tests/Plugins/Manifests/JsonManifestTests.cs b/Intersect.Tests/Plugins/Manifests/JsonManifestTests.cs index ccaa63e41b..62e8d38536 100644 --- a/Intersect.Tests/Plugins/Manifests/JsonManifestTests.cs +++ b/Intersect.Tests/Plugins/Manifests/JsonManifestTests.cs @@ -1,8 +1,6 @@  using Newtonsoft.Json; - using NUnit.Framework; - using Semver; namespace Intersect.Plugins.Manifests diff --git a/Intersect.Tests/Plugins/Manifests/Types/AuthorTests.cs b/Intersect.Tests/Plugins/Manifests/Types/AuthorTests.cs index df3fee15cc..27f14150b3 100644 --- a/Intersect.Tests/Plugins/Manifests/Types/AuthorTests.cs +++ b/Intersect.Tests/Plugins/Manifests/Types/AuthorTests.cs @@ -1,5 +1,4 @@ using Intersect.Utilities; - using NUnit.Framework; using System.Diagnostics.CodeAnalysis; diff --git a/Intersect.Tests/Plugins/Manifests/Types/AuthorsTests.cs b/Intersect.Tests/Plugins/Manifests/Types/AuthorsTests.cs index 8365d7c404..48d4f4f20c 100644 --- a/Intersect.Tests/Plugins/Manifests/Types/AuthorsTests.cs +++ b/Intersect.Tests/Plugins/Manifests/Types/AuthorsTests.cs @@ -1,10 +1,7 @@ using System.Collections; using System.Diagnostics; - using Intersect.Utilities; - using Moq; - using NUnit.Framework; namespace Intersect.Plugins.Manifests.Types diff --git a/Intersect.Tests/Plugins/VirtualTestManifest.cs b/Intersect.Tests/Plugins/VirtualTestManifest.cs index 79e8f91e8c..e4369db30a 100644 --- a/Intersect.Tests/Plugins/VirtualTestManifest.cs +++ b/Intersect.Tests/Plugins/VirtualTestManifest.cs @@ -1,6 +1,5 @@ using Intersect.Plugins.Interfaces; using Intersect.Plugins.Manifests.Types; - using Semver; namespace Intersect.Plugins diff --git a/Intersect.Tests/Utilities/MathHelperTests.cs b/Intersect.Tests/Utilities/MathHelperTests.cs index 4bfe9ebbb5..32d93f1a04 100644 --- a/Intersect.Tests/Utilities/MathHelperTests.cs +++ b/Intersect.Tests/Utilities/MathHelperTests.cs @@ -1,7 +1,5 @@ using Intersect.Extensions; - using NUnit.Framework; - using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert; namespace Intersect.Utilities diff --git a/Intersect.Tests/Utilities/TextUtilsTests.cs b/Intersect.Tests/Utilities/TextUtilsTests.cs index f1d037bd25..fb723a359d 100644 --- a/Intersect.Tests/Utilities/TextUtilsTests.cs +++ b/Intersect.Tests/Utilities/TextUtilsTests.cs @@ -1,5 +1,4 @@ using NUnit.Framework; - using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert; namespace Intersect.Utilities diff --git a/Intersect.Tests/Utilities/TimingTests.cs b/Intersect.Tests/Utilities/TimingTests.cs index 65664e2f8a..77cb79ae63 100644 --- a/Intersect.Tests/Utilities/TimingTests.cs +++ b/Intersect.Tests/Utilities/TimingTests.cs @@ -1,5 +1,4 @@ using Intersect.Utilities; - using NUnit.Framework; using System.Diagnostics; diff --git a/Intersect.Tests/Utilities/ValueUtilsTests.cs b/Intersect.Tests/Utilities/ValueUtilsTests.cs index 92c9595daf..518b455823 100644 --- a/Intersect.Tests/Utilities/ValueUtilsTests.cs +++ b/Intersect.Tests/Utilities/ValueUtilsTests.cs @@ -1,5 +1,4 @@ using NUnit.Framework; - using Assert = Microsoft.VisualStudio.TestTools.UnitTesting.Assert; namespace Intersect.Utilities diff --git a/Utilities/Intersect.OpenPortChecker/PortChecker.cs b/Utilities/Intersect.OpenPortChecker/PortChecker.cs index 62c10aa34a..8a4c12f409 100644 --- a/Utilities/Intersect.OpenPortChecker/PortChecker.cs +++ b/Utilities/Intersect.OpenPortChecker/PortChecker.cs @@ -145,7 +145,7 @@ public void OnConnectionRequest(ConnectionRequest request) request.Reject(); } - public void WriteNet(NetLogLevel level, string str, params object[] args) + public void WriteNet(NetLogLevel level, string format, params object[] args) { var logLevel = level switch { @@ -155,7 +155,7 @@ public void WriteNet(NetLogLevel level, string str, params object[] args) NetLogLevel.Info => LogLevel.Information, _ => throw new ArgumentOutOfRangeException(nameof(level), level, null), }; - _logger.Log(logLevel, str, args); + _logger.Log(logLevel, format, args); } public void PruneTasks(bool onlyExpired = true) diff --git a/Utilities/Intersect.OpenPortChecker/Program.cs b/Utilities/Intersect.OpenPortChecker/Program.cs index 51a8d6feac..70b8f9335c 100644 --- a/Utilities/Intersect.OpenPortChecker/Program.cs +++ b/Utilities/Intersect.OpenPortChecker/Program.cs @@ -7,7 +7,6 @@ var portCheckerOptionsSection = builder.Configuration.GetSection("PortChecker"); var portCheckerOptions = portCheckerOptionsSection.Get(); builder.Services.Configure(portCheckerOptionsSection); - using var loggerFactory = LoggerFactory.Create(loggingBuilder => loggingBuilder.AddConsole()); var startupLogger = loggerFactory.CreateLogger();