2using System.Diagnostics;
4using System.Reflection;
6using Terraria.ModLoader.Core;
14 [Obsolete(
"This class is deprecated. Use Terraria.ModLoader.Logging instead (see ExampleMod for example)",
false)]
21 [Obsolete(
"Please use Terraria.ModLoader.Logging.LogDir instead",
false)]
24 private static Object
logLock =
new Object();
29 [Obsolete(
"Please use your own ILog instead, see ExampleMod for an example",
false)]
30 public static void Log(
string message)
32 if (AssemblyManager.FirstModInStackTrace(
new StackTrace(), out
string modName) &&
ModLoader.
GetMod(modName) is
Mod mod) {
33 mod.Logger.Info(message);
36 Logging.tML.WarnFormat(
"Tried to forward ErrorLogger.Log for mod {0} but failed (mod not found!)", modName);
46 [Obsolete(
"Please use your own ILog instead, see ExampleMod for an example",
false)]
47 public static void Log(
object param,
bool alternateOutput =
false) {
48 string getParamString() {
49 StringBuilder sb =
new StringBuilder();
50 sb.AppendLine(
"Object type: " + param.GetType());
51 foreach (PropertyInfo property
in param.GetType().GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {
52 sb.AppendLine(
"PROPERTY " + property.Name +
" = " + property.GetValue(param,
null) +
"\n");
55 foreach (FieldInfo field
in param.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {
56 sb.AppendLine(
"FIELD " + field.Name +
" = " + (field.GetValue(param).ToString() !=
"" ? field.GetValue(param) :
"(Field value not found)") +
"\n");
59 foreach (MethodInfo method
in param.GetType().GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {
60 sb.AppendLine(
"METHOD " + method.Name +
"\n");
65 foreach (ConstructorInfo constructor
in param.GetType().GetConstructors(BindingFlags.Public | BindingFlags.NonPublic)) {
67 sb.AppendLine(
"CONSTRUCTOR " + temp +
" : " + constructor.Name +
"\n");
73 Log(!alternateOutput ? param.ToString() : getParamString());
80 [Obsolete(
"Please use Terraria.ModLoader.Logging instead",
false)]
86 string[] files =
new string[] {
87 LogPath + Path.DirectorySeparatorChar +
"Logs.txt",
88 LogPath + Path.DirectorySeparatorChar +
"Network Error.txt",
89 LogPath + Path.DirectorySeparatorChar +
"Runtime Error.txt",
91 foreach (var file
in files) {
NOTE: This class is deprecated. Use Logging instead (see ExampleMod for example) This class consists ...
static void Log(string message)
NOTE: Deprecated. Please use your own ILog instead, see ExampleMod for an example You can use this me...
static void Log(object param, bool alternateOutput=false)
NOTE: Deprecated. Please use your own ILog instead, see ExampleMod for an example Allows you to log a...
static readonly string LogPath
NOTE: Deprecated. Use Logging.LogDir instead The file path to which logs are written and stored.
static void ClearLogs()
NOTE: Deprecated. Deletes all log files.
static readonly string LogDir
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
This serves as the central class which loads mods. It contains many static fields and methods related...
static Mod GetMod(string name)
Gets the instance of the Mod with the specified name.