From bc8773bbddb017b8f67fcf6139f923069392e723 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 14 Nov 2016 21:48:40 -0500 Subject: migrate TrainerMod to new logging framework (#168) --- src/TrainerMod/TrainerMod.cs | 66 ++++++++++++++++++++++---------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/TrainerMod/TrainerMod.cs b/src/TrainerMod/TrainerMod.cs index f14a08c8..61b36685 100644 --- a/src/TrainerMod/TrainerMod.cs +++ b/src/TrainerMod/TrainerMod.cs @@ -119,7 +119,7 @@ namespace TrainerMod /// The event arguments. private void HandleTypes(object sender, EventArgsCommand e) { - Log.AsyncY($"[Int32: {int.MinValue} - {int.MaxValue}], [Int64: {long.MinValue} - {long.MaxValue}], [String: \"raw text\"], [Colour: r,g,b (EG: 128, 32, 255)]"); + this.Monitor.Log($"[Int32: {int.MinValue} - {int.MaxValue}], [Int64: {long.MinValue} - {long.MaxValue}], [String: \"raw text\"], [Colour: r,g,b (EG: 128, 32, 255)]", LogLevel.Info); } /// The event raised when the 'save' command is triggered. @@ -165,7 +165,7 @@ namespace TrainerMod Game1.player.Name = e.Command.CalledArgs[1]; break; case "pet": - Log.AsyncR("Pets cannot currently be renamed."); + this.Monitor.Log("Pets cannot currently be renamed.", LogLevel.Info); break; case "farm": Game1.player.farmName = e.Command.CalledArgs[1]; @@ -196,7 +196,7 @@ namespace TrainerMod if (int.TryParse(amountStr, out amount)) { Game1.player.Money = amount; - Log.Async($"Set {Game1.player.Name}'s money to {Game1.player.Money}"); + this.Monitor.Log($"Set {Game1.player.Name}'s money to {Game1.player.Money}", LogLevel.Info); } else this.LogValueNotInt32(); @@ -223,7 +223,7 @@ namespace TrainerMod if (int.TryParse(amountStr, out amount)) { Game1.player.Stamina = amount; - Log.Async($"Set {Game1.player.Name}'s stamina to {Game1.player.Stamina}"); + this.Monitor.Log($"Set {Game1.player.Name}'s stamina to {Game1.player.Stamina}", LogLevel.Info); } else this.LogValueNotInt32(); @@ -244,7 +244,7 @@ namespace TrainerMod if (int.TryParse(e.Command.CalledArgs[0], out amount)) { Game1.player.MaxStamina = amount; - Log.Async($"Set {Game1.player.Name}'s max stamina to {Game1.player.MaxStamina}"); + this.Monitor.Log($"Set {Game1.player.Name}'s max stamina to {Game1.player.MaxStamina}", LogLevel.Info); } else this.LogValueNotInt32(); @@ -293,10 +293,10 @@ namespace TrainerMod this.LogValueNotInt32(); } else - Log.AsyncR(" is invalid"); + this.Monitor.Log(" is invalid", LogLevel.Error); } else - Log.AsyncR(" and must be specified"); + this.Monitor.Log(" and must be specified", LogLevel.Error); } /// The event raised when the 'player_setSpeed' command is triggered. @@ -310,7 +310,7 @@ namespace TrainerMod if (amountStr.IsInt()) { Game1.player.addedSpeed = amountStr.ToInt(); - Log.Async($"Set {Game1.player.Name}'s added speed to {Game1.player.addedSpeed}"); + this.Monitor.Log($"Set {Game1.player.Name}'s added speed to {Game1.player.addedSpeed}", LogLevel.Info); } else this.LogValueNotInt32(); @@ -348,13 +348,13 @@ namespace TrainerMod } } else - Log.AsyncR(" is invalid"); + this.Monitor.Log(" is invalid", LogLevel.Error); } else this.LogObjectInvalid(); } else - Log.AsyncR(" and must be specified"); + this.Monitor.Log(" and must be specified", LogLevel.Error); } /// The event raised when the 'player_changeStyle' command is triggered. @@ -394,7 +394,7 @@ namespace TrainerMod else if (styleID == 1) Game1.player.changeIntoSwimsuit(); else - Log.AsyncR(" must be 0 or 1 for this "); + this.Monitor.Log(" must be 0 or 1 for this ", LogLevel.Error); break; case "gender": if (styleID == 0) @@ -402,7 +402,7 @@ namespace TrainerMod else if (styleID == 1) Game1.player.changeGender(false); else - Log.AsyncR(" must be 0 or 1 for this "); + this.Monitor.Log(" must be 0 or 1 for this ", LogLevel.Error); break; } } @@ -431,10 +431,10 @@ namespace TrainerMod { this.FreezeTime = value == 1; this.FrozenTime = this.FreezeTime ? Game1.timeOfDay : 0; - Log.AsyncY("Time is now " + (this.FreezeTime ? "frozen" : "thawed")); + this.Monitor.Log("Time is now " + (this.FreezeTime ? "frozen" : "thawed"), LogLevel.Info); } else - Log.AsyncR(" should be 0 or 1"); + this.Monitor.Log(" should be 0 or 1", LogLevel.Error); } else this.LogValueNotInt32(); @@ -459,10 +459,10 @@ namespace TrainerMod { Game1.timeOfDay = e.Command.CalledArgs[0].ToInt(); this.FrozenTime = this.FreezeTime ? Game1.timeOfDay : 0; - Log.AsyncY($"Time set to: {Game1.timeOfDay}"); + this.Monitor.Log($"Time set to: {Game1.timeOfDay}", LogLevel.Info); } else - Log.AsyncR(" should be between 600 and 2600 (06:00 AM - 02:00 AM [NEXT DAY])"); + this.Monitor.Log(" should be between 600 and 2600 (06:00 AM - 02:00 AM [NEXT DAY])", LogLevel.Error); } else this.LogValueNotInt32(); @@ -486,7 +486,7 @@ namespace TrainerMod if (day <= 28 && day > 0) Game1.dayOfMonth = day; else - Log.AsyncY(" must be between 1 and 28"); + this.Monitor.Log(" must be between 1 and 28", LogLevel.Error); } else this.LogValueNotInt32(); @@ -590,7 +590,7 @@ namespace TrainerMod count = e.Command.CalledArgs[1].ToInt(); else { - Log.AsyncR("[count] is invalid"); + this.Monitor.Log("[count] is invalid", LogLevel.Error); return; } @@ -600,7 +600,7 @@ namespace TrainerMod quality = e.Command.CalledArgs[2].ToInt(); else { - Log.AsyncR("[quality] is invalid"); + this.Monitor.Log("[quality] is invalid", LogLevel.Error); return; } } @@ -611,7 +611,7 @@ namespace TrainerMod Game1.player.addItemByMenuIfNecessary(item); } else - Log.AsyncR(" is invalid"); + this.Monitor.Log(" is invalid", LogLevel.Error); } else this.LogObjectValueNotSpecified(); @@ -628,10 +628,10 @@ namespace TrainerMod { MeleeWeapon weapon = new MeleeWeapon(e.Command.CalledArgs[0].ToInt()); Game1.player.addItemByMenuIfNecessary(weapon); - Log.Async($"Given {weapon.Name} to {Game1.player.Name}"); + this.Monitor.Log($"Gave {weapon.Name} to {Game1.player.Name}", LogLevel.Info); } else - Log.AsyncR(" is invalid"); + this.Monitor.Log(" is invalid", LogLevel.Error); } else this.LogObjectValueNotSpecified(); @@ -648,10 +648,10 @@ namespace TrainerMod { Ring ring = new Ring(e.Command.CalledArgs[0].ToInt()); Game1.player.addItemByMenuIfNecessary(ring); - Log.Async($"Given {ring.Name} to {Game1.player.Name}"); + this.Monitor.Log($"Gave {ring.Name} to {Game1.player.Name}", LogLevel.Info); } else - Log.AsyncR(" is invalid"); + this.Monitor.Log(" is invalid", LogLevel.Error); } else this.LogObjectValueNotSpecified(); @@ -668,7 +668,7 @@ namespace TrainerMod { Item itemName = new Object(itemID, 1); if (itemName.Name != "Error Item") - Console.WriteLine($"{itemID} | {itemName.Name}"); + this.Monitor.Log($"{itemID} | {itemName.Name}", LogLevel.Info); } catch { } } @@ -680,9 +680,9 @@ namespace TrainerMod private void HandleOutMelee(object sender, EventArgsCommand e) { var data = Game1.content.Load>("Data\\weapons"); - Console.Write("DATA\\WEAPONS: "); + this.Monitor.Log("DATA\\WEAPONS: ", LogLevel.Info); foreach (var pair in data) - Console.WriteLine($"{pair.Key} | {pair.Value}"); + this.Monitor.Log($"{pair.Key} | {pair.Value}", LogLevel.Info); } /// The event raised when the 'out_rings' command is triggered. @@ -696,7 +696,7 @@ namespace TrainerMod { Item item = new Ring(ringID); if (item.Name != "Error Item") - Console.WriteLine($"{ringID} | {item.Name}"); + this.Monitor.Log($"{ringID} | {item.Name}", LogLevel.Info); } catch { } } @@ -732,31 +732,31 @@ namespace TrainerMod /// Log an error indicating a value must be specified. public void LogValueNotSpecified() { - Log.AsyncR(" must be specified"); + this.Monitor.Log(" must be specified", LogLevel.Error); } /// Log an error indicating a target and value must be specified. public void LogObjectValueNotSpecified() { - Log.AsyncR(" and must be specified"); + this.Monitor.Log(" and must be specified", LogLevel.Error); } /// Log an error indicating a value is invalid. public void LogValueInvalid() { - Log.AsyncR(" is invalid"); + this.Monitor.Log(" is invalid", LogLevel.Error); } /// Log an error indicating a target is invalid. public void LogObjectInvalid() { - Log.AsyncR(" is invalid"); + this.Monitor.Log(" is invalid", LogLevel.Error); } /// Log an error indicating a value must be an integer. public void LogValueNotInt32() { - Log.AsyncR(" must be a whole number (Int32)"); + this.Monitor.Log(" must be a whole number (Int32)", LogLevel.Error); } } } -- cgit