diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2ef4591b..88c853a3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,9 @@
This is the rolling changelog for TShock for Terraria. Use past tense when adding new entries; sign your name off when you add or change something. This should primarily be things like user changes, not necessarily codebase changes unless it's really relevant or large.
+## Upcoming changes
+* Debug logging now provides ConsoleDebug and ILog has been updated to support the concept of debug logs. Debug logs are now controlled by `config.json` instead of by preprocessor debug flag. (@hakusaro)
+
## TShock 4.4.0 (Pre-release 3)
* Fixed `/worldmode` command to correctly target world mode. (@Ristellise)
* The following commands have been removed: `tbloodmoon`, `invade`, `dropmeteor`. `fullmoon`, `sandstorm`, `rain`, `eclipse`
diff --git a/TShockAPI/ConfigFile.cs b/TShockAPI/ConfigFile.cs
index d9a5b559..e440e241 100644
--- a/TShockAPI/ConfigFile.cs
+++ b/TShockAPI/ConfigFile.cs
@@ -520,6 +520,9 @@ namespace TShockAPI
[Description("Whether or not to show backup auto save messages.")]
public bool ShowBackupAutosaveMessages = true;
+ [Description("Whether or not the server should output debug level messages related to system operation.")]
+ public bool DebugLogs = false;
+
///
/// Reads a configuration file from a given path
///
diff --git a/TShockAPI/ILog.cs b/TShockAPI/ILog.cs
index 29a303ad..9fac3789 100644
--- a/TShockAPI/ILog.cs
+++ b/TShockAPI/ILog.cs
@@ -123,13 +123,25 @@ namespace TShockAPI
void Write(string message, TraceLevel level);
///
- /// Writes a debug string to the log file. Only works if the DEBUG preprocessor conditional is set.
+ /// Writes a debug string to the log file and console. Only works if the DebugLogs config option is set to true.
+ ///
+ /// The message to be written.
+ void ConsoleDebug(string message);
+
+ ///
+ /// Writes a debug string to the log file. Only works if the DebugLogs config option is set to true.
+ ///
+ /// The message to be written.
+ void ConsoleDebug(string message, params object[] args);
+
+ ///
+ /// Writes a debug string to the log file. Only works if the DebugLogs config option is set to true.
///
/// The message to be written.
void Debug(string message);
///
- /// Writes a debug string to the log file. Only works if the DEBUG preprocessor conditional is set.
+ /// Writes a debug string to the log file. Only works if the DebugLogs config option is set to true.
///
/// The format of the message to be written.
/// The format arguments.
diff --git a/TShockAPI/SqlLog.cs b/TShockAPI/SqlLog.cs
index 3b035c81..a0fd4493 100644
--- a/TShockAPI/SqlLog.cs
+++ b/TShockAPI/SqlLog.cs
@@ -205,15 +205,34 @@ namespace TShockAPI
ConsoleInfo(string.Format(format, args));
}
+ ///
+ /// Writes a debug string to the log file. Also outputs to the console. Requires config TShock.DebugLogs to be true.
+ ///
+ /// The message to be written.
+ public void ConsoleDebug(string message)
+ {
+ Console.WriteLine("Debug: " + message);
+ Write(message, TraceLevel.Verbose);
+ }
+
+ ///
+ /// Writes a debug string to the log file. Also outputs to the console. Requires config TShock.DebugLogs to be true.
+ ///
+ /// The format of the message to be written.
+ /// The format arguments.
+ public void ConsoleDebug(string format, params object[] args)
+ {
+ ConsoleDebug(string.Format(format, args));
+ }
+
///
/// Writes a debug string to the log file.
///
/// The message to be written.
public void Debug(string message)
{
-#if DEBUG
- Write(message, TraceLevel.Verbose);
-#endif
+ if (TShock.Config.DebugLogs)
+ Write(message, TraceLevel.Verbose);
}
///
@@ -223,9 +242,8 @@ namespace TShockAPI
/// The format arguments.
public void Debug(string format, params object[] args)
{
-#if DEBUG
- Debug(string.Format(format, args));
-#endif
+ if (TShock.Config.DebugLogs)
+ Debug(string.Format(format, args));
}
public void Write(string message, TraceLevel level)
diff --git a/TShockAPI/TextLog.cs b/TShockAPI/TextLog.cs
index 532c9ebf..349ceb01 100644
--- a/TShockAPI/TextLog.cs
+++ b/TShockAPI/TextLog.cs
@@ -172,15 +172,34 @@ namespace TShockAPI
ConsoleInfo(string.Format(format, args));
}
+ ///
+ /// Writes a debug string to the log file. Also outputs to the console. Requires config TShock.DebugLogs to be true.
+ ///
+ /// The message to be written.
+ public void ConsoleDebug(string message)
+ {
+ Console.WriteLine("Debug: " + message);
+ Write(message, TraceLevel.Verbose);
+ }
+
+ ///
+ /// Writes a debug string to the log file. Also outputs to the console. Requires config TShock.DebugLogs to be true.
+ ///
+ /// The format of the message to be written.
+ /// The format arguments.
+ public void ConsoleDebug(string format, params object[] args)
+ {
+ ConsoleDebug(string.Format(format, args));
+ }
+
///
/// Writes a debug string to the log file.
///
/// The message to be written.
public void Debug(string message)
{
-#if DEBUG
- Write(message, TraceLevel.Verbose);
-#endif
+ if (TShock.Config.DebugLogs)
+ Write(message, TraceLevel.Verbose);
}
///
@@ -190,9 +209,8 @@ namespace TShockAPI
/// The format arguments.
public void Debug(string format, params object[] args)
{
-#if DEBUG
- Debug(string.Format(format, args));
-#endif
+ if (TShock.Config.DebugLogs)
+ Debug(string.Format(format, args));
}
///