From 67022b6ace1bdd8a65efd2116e55b901bc43c196 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Thu, 14 Dec 2023 21:38:17 -0800 Subject: [PATCH] Lint: md --- .editorconfig | 10 +- .../Macross.Windows.Debugging/Demo/README.md | 210 +++++++++--------- 2 files changed, 113 insertions(+), 107 deletions(-) diff --git a/.editorconfig b/.editorconfig index 2e66ff9..5d34a42 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,10 +1,16 @@ # top-most EditorConfig file for Macross Software root = true +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + [*.{cs,js,config,xml,json,html,htm,aspx,asmx,ascx,css,token,xaml,sql,cshtml,ps1}] indent_style = tab tab_width = 4 -trim_trailing_whitespace = true indent_size = tab # Dotnet code style settings: @@ -183,4 +189,4 @@ dotnet_diagnostic.IDE0005.severity = warning dotnet_diagnostic.CA1303.severity = none [*.cshtml.cs] -dotnet_diagnostic.SA1649.severity = none \ No newline at end of file +dotnet_diagnostic.SA1649.severity = none diff --git a/ClassLibraries/Macross.Windows.Debugging/Demo/README.md b/ClassLibraries/Macross.Windows.Debugging/Demo/README.md index af5b566..ad381da 100644 --- a/ClassLibraries/Macross.Windows.Debugging/Demo/README.md +++ b/ClassLibraries/Macross.Windows.Debugging/Demo/README.md @@ -1,4 +1,4 @@ -# Macross Software Demo Application +# Macross Software Demo Application A simple demo application using [Macross.Logging.Files](../../Macross.Logging.Files/README.md) and [Macross.Windows.Debugging](../README.md). @@ -6,121 +6,121 @@ A simple demo application using [Macross.Logging.Files](../../Macross.Logging.Fi * Feature registration is done via `ConfigureLogging` and `ConfigureDebugWindow` called in `Program.cs`: - ```csharp - public static IHostBuilder CreateHostBuilder(string[] args) - { - return Host - .CreateDefaultBuilder(args) - #if WINDOWS && DEBUG - .ConfigureDebugWindow() - #endif - .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()) - .ConfigureLogging((builder) => builder.AddFiles(options => options.IncludeGroupNameInFileName = true)); - } - ``` - - Logging into files by group is turned on. + ```csharp + public static IHostBuilder CreateHostBuilder(string[] args) + { + return Host + .CreateDefaultBuilder(args) + #if WINDOWS && DEBUG + .ConfigureDebugWindow() + #endif + .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup()) + .ConfigureLogging((builder) => builder.AddFiles(options => options.IncludeGroupNameInFileName = true)); + } + ``` + + Logging into files by group is turned on. * The `WINDOWS` constant is set in `csproj`: - ```xml - - net5.0-windows - WINDOWS - + ```xml + + net5.0-windows + WINDOWS + - - net5.0 - - ``` + + net5.0 + + ``` * `appsettings.Development.json` has some configuration targeted for development: - ```json - { - "Logging": { - "LogLevel": { - "DemoWebApplication": "Debug", - "DemoWebApplication.MessageSpamBackgroundService": "Warning" - } - } - } + ```json + { + "Logging": { + "LogLevel": { + "DemoWebApplication": "Debug", + "DemoWebApplication.MessageSpamBackgroundService": "Warning" + } + } + } - ``` + ``` - The `MessageSpamBackgroundService` writes a lot of spam (by design), the "Warning" rule demonstrates how to filter that out when debugging. + The `MessageSpamBackgroundService` writes a lot of spam (by design), the "Warning" rule demonstrates how to filter that out when debugging. * `Properties\launchSettings.json` has been customized so IIS Express debugging is not the default launch setting. Launching via the compiled executable will give the best experience when combined with the `DebugWindow`. * A custom (somewhat experimental) middleware has been provided (`Middleware\RequestTraceMiddleware.cs`) which will group log messages by routes and then trace them out to logs as the Http pipeline is executed. It will also log raw request and response bodies when debugging. I have it configured to only log bodies for JSON & XML responses, but you can tweak that in your own applications. Here's an example of the output: - ```json - { - "TimestampUtc": "2020-02-02T18:26:12.0192317Z", - "ThreadId": 15, - "LogLevel": "Information", - "GroupName": "WeatherForecast", - "CategoryName": "DemoWebApplication.RequestTraceMiddleware", - "Content": "REQ", - "RequestId": "0HLT81LCG66U6:00000003", - "RequestPath": "/api/WeatherForecast", - "SpanId": "8911b2e83f658a4e", - "TraceId": "c5dc1ceb867e44449789e8669d6f7eae", - "ParentId": "0000000000000000", - "RemoteEndpoint": "::1:64468", - "Protocol": "HTTP/2", - "Method": "GET", - "Scheme": "https", - "Path": "/api/WeatherForecast", - "QueryString": "?postalCode=90210", - "Headers": { - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "en-US,en;q=0.9", - "Host": "localhost:5001", - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36 Edg/79.0.309.71", - "Upgrade-Insecure-Requests": "1", - ":method": "GET", - ":authority": "localhost:5001", - ":scheme": "https", - ":path": "/api/WeatherForecast?postalCode=90210", - "sec-fetch-user": "?1", - "sec-fetch-site": "none", - "sec-fetch-mode": "navigate" - }, - "Cookies": {}, - "Body": "" - } - { - "TimestampUtc": "2020-02-02T18:26:12.0592014Z", - "ThreadId": 15, - "LogLevel": "Information", - "GroupName": "WeatherForecast", - "CategoryName": "DemoWebApplication.RequestTraceMiddleware", - "Content": "RSP", - "RequestId": "0HLT81LCG66U6:00000003", - "RequestPath": "/api/WeatherForecast", - "SpanId": "8911b2e83f658a4e", - "TraceId": "c5dc1ceb867e44449789e8669d6f7eae", - "ParentId": "0000000000000000", - "StatusCode": 200, - "Headers": { - "Content-Type": "application/json; charset=utf-8" - }, - "Cookies": {}, - "Body": "{\"postalCode\":90210,\"friendlyName\":\"Blanchtown\",\"highTemperatureInFahrenheitDegrees\":70,\"lowTemperatureInFahrenheitDegrees\":50,\"forecastGoodUntilTime\":\"2020-02-02T10:26:42.041683-08:00\"}", - "ElapsedMilliseconds": 38.9791 - } - ``` - - The `RequestTraceMiddleware` is registered in `Startup.cs`: - - ```csharp - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - app.UseMiddleware(); - ... - } - ``` - - Note: It has to be the first middleware registered to be useful. \ No newline at end of file + ```json + { + "TimestampUtc": "2020-02-02T18:26:12.0192317Z", + "ThreadId": 15, + "LogLevel": "Information", + "GroupName": "WeatherForecast", + "CategoryName": "DemoWebApplication.RequestTraceMiddleware", + "Content": "REQ", + "RequestId": "0HLT81LCG66U6:00000003", + "RequestPath": "/api/WeatherForecast", + "SpanId": "8911b2e83f658a4e", + "TraceId": "c5dc1ceb867e44449789e8669d6f7eae", + "ParentId": "0000000000000000", + "RemoteEndpoint": "::1:64468", + "Protocol": "HTTP/2", + "Method": "GET", + "Scheme": "https", + "Path": "/api/WeatherForecast", + "QueryString": "?postalCode=90210", + "Headers": { + "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "en-US,en;q=0.9", + "Host": "localhost:5001", + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36 Edg/79.0.309.71", + "Upgrade-Insecure-Requests": "1", + ":method": "GET", + ":authority": "localhost:5001", + ":scheme": "https", + ":path": "/api/WeatherForecast?postalCode=90210", + "sec-fetch-user": "?1", + "sec-fetch-site": "none", + "sec-fetch-mode": "navigate" + }, + "Cookies": {}, + "Body": "" + } + { + "TimestampUtc": "2020-02-02T18:26:12.0592014Z", + "ThreadId": 15, + "LogLevel": "Information", + "GroupName": "WeatherForecast", + "CategoryName": "DemoWebApplication.RequestTraceMiddleware", + "Content": "RSP", + "RequestId": "0HLT81LCG66U6:00000003", + "RequestPath": "/api/WeatherForecast", + "SpanId": "8911b2e83f658a4e", + "TraceId": "c5dc1ceb867e44449789e8669d6f7eae", + "ParentId": "0000000000000000", + "StatusCode": 200, + "Headers": { + "Content-Type": "application/json; charset=utf-8" + }, + "Cookies": {}, + "Body": "{\"postalCode\":90210,\"friendlyName\":\"Blanchtown\",\"highTemperatureInFahrenheitDegrees\":70,\"lowTemperatureInFahrenheitDegrees\":50,\"forecastGoodUntilTime\":\"2020-02-02T10:26:42.041683-08:00\"}", + "ElapsedMilliseconds": 38.9791 + } + ``` + + The `RequestTraceMiddleware` is registered in `Startup.cs`: + + ```csharp + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.UseMiddleware(); + ... + } + ``` + + Note: It has to be the first middleware registered to be useful.