From 0a4bb1be82405456b00fe59da19b65426c01e391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Garcia?= Date: Thu, 8 Jun 2023 09:06:31 +0200 Subject: [PATCH] Debug.WriteLine in place of Console.WriteLine Hello, I'm using this library in a project which is communicating via CGI with a nodejs project. The latter takes the console output of the C# project in a json format. My problem is that when the iRacing yaml fail to parse via the YamlParser, the error is sent to the standard output via the `Console.WriteLine` which pollute the output and any client connected to the app fails to parse as it's not JSON. As it is an error message and a stack trace, I propose to write them in the Debug trace listeners instead, that way we can still see them in a debug env. --- .../Models/Session/IRacingSessionModel.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/irsdkSharp.Serialization/Models/Session/IRacingSessionModel.cs b/src/irsdkSharp.Serialization/Models/Session/IRacingSessionModel.cs index a405355..a8a7fa0 100644 --- a/src/irsdkSharp.Serialization/Models/Session/IRacingSessionModel.cs +++ b/src/irsdkSharp.Serialization/Models/Session/IRacingSessionModel.cs @@ -6,6 +6,7 @@ using irsdkSharp.Serialization.Models.Session.SplitTimeInfo; using irsdkSharp.Serialization.Models.Session.WeekendInfo; using System; +using System.Diagnostics; using System.IO; using YamlDotNet.Serialization; @@ -23,8 +24,8 @@ public static IRacingSessionModel Serialize(string yaml) } catch(Exception ex) { - Console.WriteLine(ex.Message); - Console.WriteLine(ex.StackTrace); + Debug.WriteLine(ex.Message); + Debug.WriteLine(ex.StackTrace); return null; } }