tModLoader v0.11.8.9
A mod to make and play Terraria mods
Terraria.ModLoader.ErrorLogger Class Reference

NOTE: This class is deprecated. Use Logging instead (see ExampleMod for example) This class consists of functions that write error messages to text files for you to read. It also lets you write logs to text files. More...

+ Collaboration diagram for Terraria.ModLoader.ErrorLogger:

Static Public Member Functions

static void ClearLogs ()
 NOTE: Deprecated. Deletes all log files. More...
 
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 an object for your own testing purposes. The message will be added to the Logs.txt file in the Logs folder. More...
 
static void Log (string message)
 NOTE: Deprecated. Please use your own ILog instead, see ExampleMod for an example You can use this method for your own testing purposes. The message will be added to the Logs.txt file in the Logs folder. More...
 

Static Public Attributes

static readonly string LogPath = Logging.LogDir
 NOTE: Deprecated. Use Logging.LogDir instead The file path to which logs are written and stored. More...
 

Static Private Attributes

static Object logLock = new Object()
 

Detailed Description

NOTE: This class is deprecated. Use Logging instead (see ExampleMod for example) This class consists of functions that write error messages to text files for you to read. It also lets you write logs to text files.

Definition at line 15 of file ErrorLogger.cs.

Member Function Documentation

◆ ClearLogs()

static void Terraria.ModLoader.ErrorLogger.ClearLogs ( )
static

NOTE: Deprecated. Deletes all log files.

Definition at line 81 of file ErrorLogger.cs.

81 {
82 lock (logLock) {
83 if (!Directory.Exists(Logging.LogDir))
84 Directory.CreateDirectory(Logging.LogDir);
85
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",
90 };
91 foreach (var file in files) {
92 try {
93 File.Delete(file);
94 }
95 catch (Exception) {
96 // Don't worry about it, modder or player might have the file open in tail or notepad.
97 }
98 }
99 }
100 }
static readonly string LogPath
NOTE: Deprecated. Use Logging.LogDir instead The file path to which logs are written and stored.
Definition: ErrorLogger.cs:22

References Terraria.ModLoader.Logging.LogDir, Terraria.ModLoader.ErrorLogger.logLock, and Terraria.ModLoader.ErrorLogger.LogPath.

◆ Log() [1/2]

static void Terraria.ModLoader.ErrorLogger.Log ( object  param,
bool  alternateOutput = false 
)
static

NOTE: Deprecated. Please use your own ILog instead, see ExampleMod for an example Allows you to log an object for your own testing purposes. The message will be added to the Logs.txt file in the Logs folder.

Parameters
paramThe object to be logged.
alternateOutputIf true, the object's data will be manually retrieved and logged. If false, the object's ToString method is logged.

Definition at line 47 of file ErrorLogger.cs.

47 {
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");
53 }
54
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");
57 }
58
59 foreach (MethodInfo method in param.GetType().GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {
60 sb.AppendLine("METHOD " + method.Name + "\n");
61 }
62
63 int temp = 0;
64
65 foreach (ConstructorInfo constructor in param.GetType().GetConstructors(BindingFlags.Public | BindingFlags.NonPublic)) {
66 temp++;
67 sb.AppendLine("CONSTRUCTOR " + temp + " : " + constructor.Name + "\n");
68 }
69
70 return sb.ToString();
71 }
72
73 Log(!alternateOutput ? param.ToString() : getParamString());
74 }
static void Log(string message)
NOTE: Deprecated. Please use your own ILog instead, see ExampleMod for an example You can use this me...
Definition: ErrorLogger.cs:30

References Terraria.ModLoader.ErrorLogger.Log().

+ Here is the call graph for this function:

◆ Log() [2/2]

static void Terraria.ModLoader.ErrorLogger.Log ( string  message)
static

NOTE: Deprecated. Please use your own ILog instead, see ExampleMod for an example You can use this method for your own testing purposes. The message will be added to the Logs.txt file in the Logs folder.

Definition at line 30 of file ErrorLogger.cs.

31 {
32 if (AssemblyManager.FirstModInStackTrace(new StackTrace(), out string modName) && ModLoader.GetMod(modName) is Mod mod) {
33 mod.Logger.Info(message);
34 }
35 else {
36 Logging.tML.WarnFormat("Tried to forward ErrorLogger.Log for mod {0} but failed (mod not found!)", modName);
37 }
38 }

References Terraria.ModLoader.ModLoader.GetMod().

Referenced by Terraria.ModLoader.ErrorLogger.Log().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ logLock

Object Terraria.ModLoader.ErrorLogger.logLock = new Object()
staticprivate

Definition at line 24 of file ErrorLogger.cs.

Referenced by Terraria.ModLoader.ErrorLogger.ClearLogs().

◆ LogPath

readonly string Terraria.ModLoader.ErrorLogger.LogPath = Logging.LogDir
static

NOTE: Deprecated. Use Logging.LogDir instead The file path to which logs are written and stored.

Definition at line 22 of file ErrorLogger.cs.

Referenced by Terraria.ModLoader.ErrorLogger.ClearLogs().