Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test-proxy always logs exceptions on console #5218

Merged
merged 2 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ public static void LogInformation(string details)
}


public static void LogError(string details)
{
if (null != logger)
{
logger.LogError(details);
}
else
{
System.Console.WriteLine(details);
}
}

/// <summary>
/// Simple access to the logging api. Accepts a simple message (preformatted) and logs to debug logger.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Text.Json;
Expand Down Expand Up @@ -62,7 +63,7 @@ public async Task Invoke(HttpContext context)
Status = e.StatusCode.ToString()
};

DebugLogger.LogInformation(e.Message);
DebugLogger.LogError(e.Message);

var body = JsonSerializer.Serialize(bodyObj);
await context.Response.WriteAsync(body);
Expand All @@ -79,6 +80,8 @@ public async Task Invoke(HttpContext context)
response.Headers.Add("x-request-exception", "true");
response.Headers.Add("x-request-exception-error", Convert.ToBase64String(Encoding.UTF8.GetBytes(e.Message)));

DebugLogger.LogError(unexpectedStatusCode.ToString() + Environment.NewLine + e.Message + Environment.NewLine + e.StackTrace);
scbedd marked this conversation as resolved.
Show resolved Hide resolved

var bodyObj = new
{
Message = e.Message,
Expand Down