internal static void FixNames(LogEventStackFrame stackFrame)
        {
            if (stackFrame.Function == "MoveNext")
            {
                var asyncMatch = asyncRegex.Match(stackFrame.Module);
                if (asyncMatch.Success)
                {
                    stackFrame.Module   = asyncMatch.Groups[1].Value;
                    stackFrame.Function = asyncMatch.Groups[2].Value;
                }
            }
            var matchLambda = lambdaRegex.Match(stackFrame.Function);

            if (matchLambda.Success)
            {
                stackFrame.Function = matchLambda.Groups[1].Value + " { <lambda> }";
            }
            if (stackFrame.Module == null)
            {
                return;
            }
            if (stackFrame.Module.EndsWith(".<>c") || stackFrame.Module.EndsWith("+<>c"))
            {
                stackFrame.Module = stackFrame.Module.Substring(0, stackFrame.Module.Length - 4);
            }
        }
Example #2
0
 private static void WriteStackFrame(IBinaryWriter writer, LogEventStackFrame stackFrame)
 {
     writer.WriteNullable(stackFrame.Module, (w, s) => w.Write(s));
     writer.WriteNullable(stackFrame.Function, (w, s) => w.Write(s));
     writer.WriteNullable(stackFrame.Source, (w, s) => w.Write(s));
     writer.WriteNullable(stackFrame.Filename, (w, s) => w.Write(s));
     writer.Write(stackFrame.LineNumber);
     writer.Write(stackFrame.ColumnNumber);
 }
        private static LogEventStackFrame CreateLogEventStackFrame(StackFrame frame)
        {
            var method     = frame.GetMethod();
            var stackFrame = new LogEventStackFrame
            {
                Module       = method?.DeclaringType?.FullName ?? "(unknown)",
                Function     = method?.Name ?? "(unknown)",
                Source       = method?.ToString() ?? "(unknown)",
                Filename     = frame.GetFileName(),
                LineNumber   = frame.GetFileLineNumber(),
                ColumnNumber = frame.GetFileColumnNumber()
            };

            FixNames(stackFrame);
            return(stackFrame);
        }