Added Shorthand Property for CalamityMod.Instance.Logger
This commit is contained in:
1 parent
6c4826ceb3
commit
ed22b65bed
23 files changed
+43
-42
No files matched your search
+4
-3
@@ -1,17 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using CalamityMod.FluidSimulation;
|
||||
using CalamityMod.Items;
|
||||
using CalamityMod.MainMenu;
|
||||
using CalamityMod.Particles;
|
||||
using CalamityMod.Projectiles;
|
||||
using log4net;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using Terraria.ModLoader.Config;
|
||||
|
||||
[assembly: InternalsVisibleTo("CalTestHelpers")]
|
||||
[assembly: InternalsVisibleTo("InfernumMode")]
|
||||
@@ -30,6 +28,9 @@ namespace CalamityMod
|
||||
internal static CalamityMod Instance => _Instance ??= ModContent.GetInstance<CalamityMod>();
|
||||
private static CalamityMod _Instance;
|
||||
|
||||
// This should not be named as 'Logger' as it hides Instance Property 'Logger'
|
||||
internal static ILog Log => Instance.Logger;
|
||||
|
||||
#region Load
|
||||
public override void Load()
|
||||
{
|
||||
|
||||
+7
-7
@@ -29,7 +29,7 @@ namespace CalamityMod
|
||||
var existingHandler = _PacketRegistry[msgType];
|
||||
if (existingHandler != null)
|
||||
{
|
||||
CalamityMod.Instance.Logger.Error($"Packet instance has already registered by other type!" +
|
||||
CalamityMod.Log.Error($"Packet instance has already registered by other type!" +
|
||||
$" [Failed On: '{type.FullName}'" +
|
||||
$" Current Owner: '{existingHandler.GetType().FullName}'," +
|
||||
$" msgTypeToRegister: '{msgType}']");
|
||||
@@ -48,7 +48,7 @@ namespace CalamityMod
|
||||
}
|
||||
else
|
||||
{
|
||||
CalamityMod.Instance.Logger.Error($"Packet instance's 'Instance' property is not asssignable with given type!" +
|
||||
CalamityMod.Log.Error($"Packet instance's 'Instance' property is not asssignable with given type!" +
|
||||
$" [Failed On: '{type.FullName}']");
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ namespace CalamityMod
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CalamityMod.Instance.Logger.Error($"Exception was thrown while loading for Packets! {e}");
|
||||
CalamityMod.Log.Error($"Exception was thrown while loading for Packets! {e}");
|
||||
return;
|
||||
}
|
||||
});
|
||||
@@ -102,18 +102,18 @@ namespace CalamityMod
|
||||
// Throw an exception now instead of allowing the network stream to corrupt.
|
||||
//
|
||||
|
||||
CalamityMod.Instance.Logger.Error($"Failed to parse Calamity packet: No Calamity packet exists with ID {msgType}.");
|
||||
CalamityMod.Log.Error($"Failed to parse Calamity packet: No Calamity packet exists with ID {msgType}.");
|
||||
throw new Exception("Failed to parse Calamity packet: Invalid Calamity packet ID.");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e is EndOfStreamException eose)
|
||||
CalamityMod.Instance.Logger.Error("Failed to parse Calamity packet: Packet was too short, missing data, or otherwise corrupt.", eose);
|
||||
CalamityMod.Log.Error("Failed to parse Calamity packet: Packet was too short, missing data, or otherwise corrupt.", eose);
|
||||
else if (e is ObjectDisposedException ode)
|
||||
CalamityMod.Instance.Logger.Error("Failed to parse Calamity packet: Packet reader disposed or destroyed.", ode);
|
||||
CalamityMod.Log.Error("Failed to parse Calamity packet: Packet reader disposed or destroyed.", ode);
|
||||
else if (e is IOException ioe)
|
||||
CalamityMod.Instance.Logger.Error("Failed to parse Calamity packet: An unknown I/O error occurred.", ioe);
|
||||
CalamityMod.Log.Error("Failed to parse Calamity packet: An unknown I/O error occurred.", ioe);
|
||||
else
|
||||
throw; // this either will crash the game or be caught by TML's packet policing
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace CalamityMod.Cooldowns
|
||||
// It is possible this cooldown does not exist. If this occurs, log it, even though it will be (mostly) harmless.
|
||||
if (cd is null)
|
||||
{
|
||||
CalamityMod.Instance.Logger.Warn($"Cooldown \"{id}\" loaded from NBT, but was not found. This cooldown will not be applied to the player.");
|
||||
CalamityMod.Log.Warn($"Cooldown \"{id}\" loaded from NBT, but was not found. This cooldown will not be applied to the player.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace CalamityMod.Cooldowns
|
||||
if (netID != registeredNetID)
|
||||
{
|
||||
// Log when this occurs, even though it should be harmless.
|
||||
CalamityMod.Instance.Logger.Warn($"Cooldown \"{id}\" loaded from NBT with discrepant netID {netID}. This cooldown was registered with netID {registeredNetID}");
|
||||
CalamityMod.Log.Warn($"Cooldown \"{id}\" loaded from NBT with discrepant netID {netID}. This cooldown was registered with netID {registeredNetID}");
|
||||
netID = registeredNetID;
|
||||
}
|
||||
player = p;
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace CalamityMod.ILEditing
|
||||
}
|
||||
}
|
||||
|
||||
public static void DumpToLog(ILContext il) => CalamityMod.Instance.Logger.Debug(il.ToString());
|
||||
public static void LogFailure(string name, string reason) => CalamityMod.Instance.Logger.Warn($"IL edit \"{name}\" failed! {reason}");
|
||||
public static void DumpToLog(ILContext il) => CalamityMod.Log.Debug(il.ToString());
|
||||
public static void LogFailure(string name, string reason) => CalamityMod.Log.Warn($"IL edit \"{name}\" failed! {reason}");
|
||||
}
|
||||
}
|
||||
@@ -365,7 +365,7 @@ namespace CalamityMod.ILEditing
|
||||
|
||||
if (!cursor.TryGotoNext(MoveType.Before, i => i.MatchCallOrCallvirt<Main>("UpdateTime_SpawnTownNPCs")))
|
||||
{
|
||||
CalamityMod.Instance.Logger.Warn("Town NPC spawn editing code failed.");
|
||||
CalamityMod.Log.Warn("Town NPC spawn editing code failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@ namespace CalamityMod.ILEditing
|
||||
{
|
||||
if (Main.netMode == NetmodeID.MultiplayerClient)
|
||||
{
|
||||
CalamityMod.Instance.Logger.Error($"NETCODE SAFETY VIOLATION DETECTED: {nameof(NPC.NewNPC)} was called from a Multiplayer Client");
|
||||
CalamityMod.Instance.Logger.Error(GetSimplifiedStackTrace());
|
||||
CalamityMod.Log.Error($"NETCODE SAFETY VIOLATION DETECTED: {nameof(NPC.NewNPC)} was called from a Multiplayer Client");
|
||||
CalamityMod.Log.Error(GetSimplifiedStackTrace());
|
||||
return Main.maxNPCs;
|
||||
}
|
||||
|
||||
@@ -54,8 +54,8 @@ namespace CalamityMod.ILEditing
|
||||
// So we simply stop that from happening
|
||||
if (msgType == MessageID.SyncNPC && Main.netMode == NetmodeID.MultiplayerClient)
|
||||
{
|
||||
CalamityMod.Instance.Logger.Error($"NETCODE SAFETY VIOLATION DETECTED: {nameof(NetMessage.SendData)} ({nameof(MessageID.SyncNPC)}) was called from a Multiplayer Client");
|
||||
CalamityMod.Instance.Logger.Error(GetSimplifiedStackTrace());
|
||||
CalamityMod.Log.Error($"NETCODE SAFETY VIOLATION DETECTED: {nameof(NetMessage.SendData)} ({nameof(MessageID.SyncNPC)}) was called from a Multiplayer Client");
|
||||
CalamityMod.Log.Error(GetSimplifiedStackTrace());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,13 +62,13 @@ namespace CalamityMod.Items.Fishing
|
||||
if (aquamarine is not null)
|
||||
itemLoot.Add(aquamarine.Type, 4, gemMin, gemMax);
|
||||
else
|
||||
CalamityMod.Instance.Logger.Warn("Could not find Thorium Aquamarine gem. This item will not be added to Glimmering Gemfish.");
|
||||
CalamityMod.Log.Warn("Could not find Thorium Aquamarine gem. This item will not be added to Glimmering Gemfish.");
|
||||
|
||||
var opal = thorium.Find<ModItem>("Opal");
|
||||
if (opal is not null)
|
||||
itemLoot.Add(opal.Type, 4, gemMin, gemMax);
|
||||
else
|
||||
CalamityMod.Instance.Logger.Warn("Could not find Thorium Opal gem. This item will not be added to Glimmering Gemfish.");
|
||||
CalamityMod.Log.Warn("Could not find Thorium Opal gem. This item will not be added to Glimmering Gemfish.");
|
||||
}
|
||||
|
||||
public override void ModifyTooltips(List<TooltipLine> list)
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace CalamityMod.Items.Fishing
|
||||
itemLoot.Add(marineKelpSeeds.Type, 10, seedMin, seedMax);
|
||||
}
|
||||
else
|
||||
CalamityMod.Instance.Logger.Warn("Could not find either Marine Kelp or Marine Kelp Seeds from Thorium. These items will not be added to Stuffed Fish.");
|
||||
CalamityMod.Log.Warn("Could not find either Marine Kelp or Marine Kelp Seeds from Thorium. These items will not be added to Stuffed Fish.");
|
||||
|
||||
// Ozzatron 30DEC2022: It is unlikely SoA will ever be ported to 1.4 and beyond. Commenting this out indefinitely.
|
||||
/*
|
||||
@@ -133,7 +133,7 @@ namespace CalamityMod.Items.Fishing
|
||||
}
|
||||
catch
|
||||
{
|
||||
CalamityMod.Instance.Logger.Debug("One of the items in this file got renamed internally. Please report this in the #bugs-read-pins channel of the official Calamity discord server.");
|
||||
CalamityMod.Log.Debug("One of the items in this file got renamed internally. Please report this in the #bugs-read-pins channel of the official Calamity discord server.");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace CalamityMod.Items.Weapons.Melee
|
||||
//.. but just in case
|
||||
if (mainAttunement == null)
|
||||
{
|
||||
CalamityMod.Instance.Logger.Error("No main attunement on galaxia, couldn't edit its tooltip properly. How the hell did that happen.");
|
||||
CalamityMod.Log.Error("No main attunement on galaxia, couldn't edit its tooltip properly. How the hell did that happen.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2045,11 +2045,11 @@ namespace CalamityMod
|
||||
return null;
|
||||
|
||||
case "LoadParticleInstances":
|
||||
CalamityMod.Instance.Logger.Warn("This mod call is deprecated. Calamity automatically registers particles.");
|
||||
CalamityMod.Log.Warn("This mod call is deprecated. Calamity automatically registers particles.");
|
||||
return null;
|
||||
|
||||
case "RegisterModCooldowns":
|
||||
CalamityMod.Instance.Logger.Warn("This mod call is deprecated. Calamity automatically registers cooldowns.");
|
||||
CalamityMod.Log.Warn("This mod call is deprecated. Calamity automatically registers cooldowns.");
|
||||
return null;
|
||||
|
||||
case "GetSummonerNerfDisabledByItem":
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace CalamityMod.NPCs
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CalamityMod.Instance.Logger.Error($"Exception thrown while evaluating type \"{type.Name}\": {e}");
|
||||
CalamityMod.Log.Error($"Exception thrown while evaluating type \"{type.Name}\": {e}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace CalamityMod.NPCs
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CalamityMod.Instance.Logger.Error($"Exception thrown while evaluating type \"{type.Name}\": {e}");
|
||||
CalamityMod.Log.Error($"Exception thrown while evaluating type \"{type.Name}\": {e}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace CalamityMod.NPCs
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
CalamityMod.Instance.Logger.Error($"Exception thrown while evaluating type \"{type.Name}\": {e}");
|
||||
CalamityMod.Log.Error($"Exception thrown while evaluating type \"{type.Name}\": {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace CalamityMod.Packets
|
||||
}
|
||||
else
|
||||
{
|
||||
CalamityMod.Instance.Logger.Error($"Packet: [{nameof(SwitchToDifficultyPacket)}] has failed! Name: [{modeName}] is not a valid {nameof(DifficultyMode)} name!");
|
||||
CalamityMod.Log.Error($"Packet: [{nameof(SwitchToDifficultyPacket)}] has failed! Name: [{modeName}] is not a valid {nameof(DifficultyMode)} name!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ namespace CalamityMod.Projectiles.Summon
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CalamityMod.Instance.Logger.Warn("IbanPlay Victide Cnidarian Position Netcode failed safely");
|
||||
CalamityMod.Log.Warn("IbanPlay Victide Cnidarian Position Netcode failed safely");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -772,7 +772,7 @@ PostAreaIteration:
|
||||
// This is an intentional "fail gracefully" case.
|
||||
else if (isTML13Schematic)
|
||||
{
|
||||
CalamityMod.Instance.Logger.Error(TML13ValidString);
|
||||
CalamityMod.Log.Error(TML13ValidString);
|
||||
SchematicMetaTile[,] empty = new SchematicMetaTile[0, 0];
|
||||
return empty;
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ namespace CalamityMod.Schematics
|
||||
// If no schematic exists with this name, cancel with a helpful log message.
|
||||
if (!TileMaps.TryGetValue(name, out SchematicMetaTile[,] schematic))
|
||||
{
|
||||
CalamityMod.Instance.Logger.Warn($"Tried to place a schematic with name \"{name}\". No matching schematic file found.");
|
||||
CalamityMod.Log.Warn($"Tried to place a schematic with name \"{name}\". No matching schematic file found.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ namespace CalamityMod.Schematics
|
||||
// Make sure that all four corners of the target area are actually in the world.
|
||||
if (!WorldGen.InWorld(cornerX, cornerY) || !WorldGen.InWorld(cornerX + width, cornerY + height))
|
||||
{
|
||||
CalamityMod.Instance.Logger.Warn("Schematic failed to place: Part of the target location is outside the game world.");
|
||||
CalamityMod.Log.Warn("Schematic failed to place: Part of the target location is outside the game world.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace CalamityMod.Systems
|
||||
// If the key already exists, log it as a warning and don't run any code.
|
||||
if (GlobalSaveDataKeys.Contains(key))
|
||||
{
|
||||
CalamityMod.Instance.Logger.Error($"WARNING! A global save data key \"{key}\" which has already been registered is attempting to be registered again. " +
|
||||
CalamityMod.Log.Error($"WARNING! A global save data key \"{key}\" which has already been registered is attempting to be registered again. " +
|
||||
"Please report this to the Calamity Mod Team if you see this!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ namespace CalamityMod.Systems
|
||||
if (blendTextureSlot == TileBlendTextureLoader.EmptySlot)
|
||||
{
|
||||
var tileName = TileLoader.GetTile(blendTileType)?.FullName ?? "Vanilla Tile";
|
||||
CalamityMod.Instance.Logger.Error($"[BlendMergeSystem] BlendTileType: {blendTileType} ({tileName}) does not have TileBlendTexture! StackTrace:\n{Environment.StackTrace}");
|
||||
CalamityMod.Log.Error($"[BlendMergeSystem] BlendTileType: {blendTileType} ({tileName}) does not have TileBlendTexture! StackTrace:\n{Environment.StackTrace}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace CalamityMod.Tiles
|
||||
{
|
||||
if (GlowMask != null)
|
||||
{
|
||||
CalamityMod.Instance.Logger.Error($"{Name} has called {nameof(SetStaticDefaults)} themselve! This is not allowed!");
|
||||
CalamityMod.Log.Error($"{Name} has called {nameof(SetStaticDefaults)} themselve! This is not allowed!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace CalamityMod.World
|
||||
bool invalidHeightData = top >= bottom;
|
||||
if (invalidWidthData || invalidHeightData)
|
||||
{
|
||||
CalamityMod.Instance.Logger.Warn("The generated dungeon was found to have unusable area bounds. As a result, the astral chest could not be generated.");
|
||||
CalamityMod.Log.Warn("The generated dungeon was found to have unusable area bounds. As a result, the astral chest could not be generated.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace CalamityMod.World
|
||||
// If a chest was NOT placed, that means that the loop somehow failed.
|
||||
// Log this.
|
||||
else
|
||||
CalamityMod.Instance.Logger.Warn("The astral chest loop could not find a valid generation location. As a result, it has not generated.");
|
||||
CalamityMod.Log.Warn("The astral chest loop could not find a valid generation location. As a result, it has not generated.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -589,7 +589,7 @@ namespace CalamityMod.World
|
||||
contents.Add(new ChestItem(marineKelpPlanterBox.Type, WorldGen.genRand.Next(5, 9 + 1)));
|
||||
}
|
||||
else
|
||||
CalamityMod.Instance.Logger.Warn("Could not find Thorium Marine Kelp Planter Box. This item will not be added to the Draedon Planetoid Lab.");
|
||||
CalamityMod.Log.Warn("Could not find Thorium Marine Kelp Planter Box. This item will not be added to the Draedon Planetoid Lab.");
|
||||
|
||||
//Adds the Jungle Seeking Mechanism
|
||||
contents.Insert(0, new ChestItem(ModContent.ItemType<GreenSeekingMechanism>(), 1));
|
||||
|
||||
@@ -959,7 +959,7 @@ namespace CalamityMod.World
|
||||
// Create a log message if for some reason the schematic in question doesn't exist.
|
||||
if (!wrappedSchematicArea.HasValue)
|
||||
{
|
||||
CalamityMod.Instance.Logger.Warn($"Tried to place a schematic with name \"{schematicName}\". No matching schematic file found.");
|
||||
CalamityMod.Log.Warn($"Tried to place a schematic with name \"{schematicName}\". No matching schematic file found.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -941,7 +941,7 @@ namespace CalamityMod.World
|
||||
break;
|
||||
}
|
||||
} while (tries <= 100000);
|
||||
CalamityMod.Instance.Logger.Debug("Rox Shrine failed to generate");
|
||||
CalamityMod.Log.Debug("Rox Shrine failed to generate");
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in new issue
Block a user