Browse Source

Debug logger now only attempts to show info it has

pull/11/head
Anairkoen Schno 5 years ago
parent
commit
cf21769fed
1 changed files with 17 additions and 8 deletions
  1. +17
    -8
      IPA.Loader/Logging/StandardLogger.cs

+ 17
- 8
IPA.Loader/Logging/StandardLogger.cs View File

@ -204,14 +204,23 @@ namespace IPA.Logging
/// <param name="message">the message to log</param> /// <param name="message">the message to log</param>
public override void Debug(string message) public override void Debug(string message)
{ {
// add source to message
var stackFrame = new StackTrace(true).GetFrame(1);
var method = stackFrame.GetMethod();
var lineNo = stackFrame.GetFileLineNumber();
var paramString = string.Join(", ", method.GetParameters().Select(p => p.ParameterType.FullName));
base.Debug(showSourceClass
? $"{{{method.DeclaringType?.FullName}::{method.Name}({paramString}):{lineNo}}} {message}"
: message);
if (showSourceClass)
{
// add source to message
var stackFrame = new StackTrace(true).GetFrame(1);
var method = stackFrame.GetMethod();
var lineNo = stackFrame.GetFileLineNumber();
var fileName = stackFrame.GetFileName();
var paramString = string.Join(", ", method.GetParameters().Select(p => p.ParameterType.FullName));
message = lineNo == 0 ? // no symbols
$"{{{method.DeclaringType?.FullName}::{method.Name}({paramString})}} {message}" :
$"{{{fileName}:{lineNo}}} {message}";
base.Debug(message);
}
else
base.Debug(message);
} }
private struct LogMessage private struct LogMessage


Loading…
Cancel
Save