Overhaul debug logging
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.
This commit is contained in:
parent
19de422304
commit
b76d906c59
5 changed files with 68 additions and 14 deletions
|
|
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Reads a configuration file from a given path
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -123,13 +123,25 @@ namespace TShockAPI
|
|||
void Write(string message, TraceLevel level);
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to be written.</param>
|
||||
void ConsoleDebug(string message);
|
||||
|
||||
/// <summary>
|
||||
/// Writes a debug string to the log file. Only works if the DebugLogs config option is set to true.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to be written.</param>
|
||||
void ConsoleDebug(string message, params object[] args);
|
||||
|
||||
/// <summary>
|
||||
/// Writes a debug string to the log file. Only works if the DebugLogs config option is set to true.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to be written.</param>
|
||||
void Debug(string message);
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <param name="format">The format of the message to be written.</param>
|
||||
/// <param name="args">The format arguments.</param>
|
||||
|
|
|
|||
|
|
@ -205,15 +205,34 @@ namespace TShockAPI
|
|||
ConsoleInfo(string.Format(format, args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a debug string to the log file. Also outputs to the console. Requires config TShock.DebugLogs to be true.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to be written.</param>
|
||||
public void ConsoleDebug(string message)
|
||||
{
|
||||
Console.WriteLine("Debug: " + message);
|
||||
Write(message, TraceLevel.Verbose);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a debug string to the log file. Also outputs to the console. Requires config TShock.DebugLogs to be true.
|
||||
/// </summary>
|
||||
/// <param name="format">The format of the message to be written.</param>
|
||||
/// <param name="args">The format arguments.</param>
|
||||
public void ConsoleDebug(string format, params object[] args)
|
||||
{
|
||||
ConsoleDebug(string.Format(format, args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a debug string to the log file.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to be written.</param>
|
||||
public void Debug(string message)
|
||||
{
|
||||
#if DEBUG
|
||||
Write(message, TraceLevel.Verbose);
|
||||
#endif
|
||||
if (TShock.Config.DebugLogs)
|
||||
Write(message, TraceLevel.Verbose);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -223,9 +242,8 @@ namespace TShockAPI
|
|||
/// <param name="args">The format arguments.</param>
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -172,15 +172,34 @@ namespace TShockAPI
|
|||
ConsoleInfo(string.Format(format, args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a debug string to the log file. Also outputs to the console. Requires config TShock.DebugLogs to be true.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to be written.</param>
|
||||
public void ConsoleDebug(string message)
|
||||
{
|
||||
Console.WriteLine("Debug: " + message);
|
||||
Write(message, TraceLevel.Verbose);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a debug string to the log file. Also outputs to the console. Requires config TShock.DebugLogs to be true.
|
||||
/// </summary>
|
||||
/// <param name="format">The format of the message to be written.</param>
|
||||
/// <param name="args">The format arguments.</param>
|
||||
public void ConsoleDebug(string format, params object[] args)
|
||||
{
|
||||
ConsoleDebug(string.Format(format, args));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a debug string to the log file.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to be written.</param>
|
||||
public void Debug(string message)
|
||||
{
|
||||
#if DEBUG
|
||||
Write(message, TraceLevel.Verbose);
|
||||
#endif
|
||||
if (TShock.Config.DebugLogs)
|
||||
Write(message, TraceLevel.Verbose);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -190,9 +209,8 @@ namespace TShockAPI
|
|||
/// <param name="args">The format arguments.</param>
|
||||
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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue