DEBUG preprocessor conditional inside method

This commit is contained in:
White 2015-04-09 15:56:51 +09:30
parent c0f28f4aaf
commit b4f2ddef47
5 changed files with 11 additions and 15 deletions

View file

@ -2469,9 +2469,7 @@ namespace TShockAPI
{ {
if (type == 100 || type == 164 || type == 180 || type == 261 || (type > 289 && type < 298) || (type >= 325 && type <= 328) || (type >= 345 && type <= 352)) if (type == 100 || type == 164 || type == 180 || type == 261 || (type > 289 && type < 298) || (type >= 325 && type <= 328) || (type >= 345 && type <= 352))
{ {
#if DEBUG
TShock.Log.Debug("Certain projectiles have been ignored for cheat detection."); TShock.Log.Debug("Certain projectiles have been ignored for cheat detection.");
#endif
} }
else else
{ {
@ -2498,9 +2496,7 @@ namespace TShockAPI
{ {
if (type == 90 && TShock.Config.ProjIgnoreShrapnel) // Ignore crystal shards if (type == 90 && TShock.Config.ProjIgnoreShrapnel) // Ignore crystal shards
{ {
#if DEBUG
TShock.Log.Debug("Ignoring shrapnel per config.."); TShock.Log.Debug("Ignoring shrapnel per config..");
#endif
} }
else if (!Main.projectile[index].active) else if (!Main.projectile[index].active)
{ {

View file

@ -122,20 +122,18 @@ namespace TShockAPI
/// <param name="level">LogLevel assosciated with the message</param> /// <param name="level">LogLevel assosciated with the message</param>
void Write(string message, TraceLevel level); void Write(string message, TraceLevel level);
#if DEBUG
/// <summary> /// <summary>
/// Writes a debug string to the log file. /// Writes a debug string to the log file. Only works if the DEBUG preprocessor conditional is set.
/// </summary> /// </summary>
/// <param name="message">The message to be written.</param> /// <param name="message">The message to be written.</param>
void Debug(string message); void Debug(string message);
/// <summary> /// <summary>
/// Writes a debug string to the log file. /// Writes a debug string to the log file. Only works if the DEBUG preprocessor conditional is set.
/// </summary> /// </summary>
/// <param name="format">The format of the message to be written.</param> /// <param name="format">The format of the message to be written.</param>
/// <param name="args">The format arguments.</param> /// <param name="args">The format arguments.</param>
void Debug(string format, params object[] args); void Debug(string format, params object[] args);
#endif
/// <summary> /// <summary>
/// Dispose the Log /// Dispose the Log

View file

@ -205,14 +205,15 @@ namespace TShockAPI
ConsoleInfo(string.Format(format, args)); ConsoleInfo(string.Format(format, args));
} }
#if DEBUG
/// <summary> /// <summary>
/// Writes a debug string to the log file. /// Writes a debug string to the log file.
/// </summary> /// </summary>
/// <param name="message">The message to be written.</param> /// <param name="message">The message to be written.</param>
public void Debug(string message) public void Debug(string message)
{ {
Write(message, TraceLevel.Verbose); #if DEBUG
Write(message, TraceLevel.Verbose);\
#endif
} }
/// <summary> /// <summary>
@ -222,9 +223,10 @@ namespace TShockAPI
/// <param name="args">The format arguments.</param> /// <param name="args">The format arguments.</param>
public void Debug(string format, params object[] args) public void Debug(string format, params object[] args)
{ {
#if DEBUG
Debug(string.Format(format, args)); Debug(string.Format(format, args));
}
#endif #endif
}
public void Write(string message, TraceLevel level) public void Write(string message, TraceLevel level)
{ {

View file

@ -858,13 +858,11 @@ namespace TShockAPI
LastDisableNotification = DateTime.UtcNow; LastDisableNotification = DateTime.UtcNow;
} }
} }
#if DEBUG
var trace = new StackTrace(); var trace = new StackTrace();
StackFrame frame = null; StackFrame frame = null;
frame = trace.GetFrame(1); frame = trace.GetFrame(1);
if (frame != null && frame.GetMethod().DeclaringType != null) if (frame != null && frame.GetMethod().DeclaringType != null)
TShock.Log.Debug(frame.GetMethod().DeclaringType.Name + " called Disable()."); TShock.Log.Debug(frame.GetMethod().DeclaringType.Name + " called Disable().");
#endif
} }
public virtual void Whoopie(object time) public virtual void Whoopie(object time)

View file

@ -172,14 +172,15 @@ namespace TShockAPI
ConsoleInfo(string.Format(format, args)); ConsoleInfo(string.Format(format, args));
} }
#if DEBUG
/// <summary> /// <summary>
/// Writes a debug string to the log file. /// Writes a debug string to the log file.
/// </summary> /// </summary>
/// <param name="message">The message to be written.</param> /// <param name="message">The message to be written.</param>
public void Debug(string message) public void Debug(string message)
{ {
#if DEBUG
Write(message, TraceLevel.Verbose); Write(message, TraceLevel.Verbose);
#endif
} }
/// <summary> /// <summary>
@ -189,9 +190,10 @@ namespace TShockAPI
/// <param name="args">The format arguments.</param> /// <param name="args">The format arguments.</param>
public void Debug(string format, params object[] args) public void Debug(string format, params object[] args)
{ {
#if DEBUG
Debug(string.Format(format, args)); Debug(string.Format(format, args));
}
#endif #endif
}
/// <summary> /// <summary>
/// Writes a message to the log /// Writes a message to the log