From 00d7894cc5146b954c068e61777a3ded0d5effbe Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Wed, 10 Apr 2019 00:30:11 -0500 Subject: [PATCH] Debug logger now only attempts to show info it has --- IPA.Loader/Logging/StandardLogger.cs | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/IPA.Loader/Logging/StandardLogger.cs b/IPA.Loader/Logging/StandardLogger.cs index 1672bcfb..94ef2968 100644 --- a/IPA.Loader/Logging/StandardLogger.cs +++ b/IPA.Loader/Logging/StandardLogger.cs @@ -204,14 +204,23 @@ namespace IPA.Logging /// the message to log 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