Skip to content

Commit

Permalink
Dump whole input file line to log file on error parsing it
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Crossley committed Oct 14, 2024
1 parent c685888 commit df0f1cb
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ImportWD.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.0.4</Version>
<Version>0.0.5</Version>
<StartupObject>ImportWD.Program</StartupObject>
<Copyright>Copyright © 2024-$([System.DateTime]::Now.ToString('yyyy')) Cumulus MX</Copyright>
<Authors>Cumulus MX</Authors>
Expand Down
3 changes: 3 additions & 0 deletions WdExtraSensorsRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public WdExtraSensorsRecord(string entry)
catch (Exception ex)
{
Program.LogMessage(" Error parsing date/time fields: " + ex.Message);
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing date/time fields: " + ex.Message, ConsoleColor.Red);
return;
}
Expand All @@ -72,6 +73,7 @@ public WdExtraSensorsRecord(string entry)
else
{
Program.LogMessage($" Error parsing field {i} (temperature-{i - 4})");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole($" Error parsing field {i} (temperature-{i - 4})", ConsoleColor.Red);
}
}
Expand All @@ -91,6 +93,7 @@ public WdExtraSensorsRecord(string entry)
else
{
Program.LogMessage($" Error parsing field {i} (humidity-{i - 5})");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole($" Error parsing field {i} (humidity-{i - 5})", ConsoleColor.Red);
}
}
Expand Down
3 changes: 3 additions & 0 deletions WdIndoorRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public WdIndoorRecord(string entry)
catch (Exception ex)
{
Program.LogMessage(" Error parsing date/time fields: " + ex.Message);
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing date/time fields: " + ex.Message, ConsoleColor.Red);
return;
}
Expand All @@ -44,6 +45,7 @@ public WdIndoorRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 6 (temperature})");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 6 (temperature})", ConsoleColor.Red);
}

Expand All @@ -54,6 +56,7 @@ public WdIndoorRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 6 (humidity})");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 6 (humidity})", ConsoleColor.Red);
}
}
Expand Down
13 changes: 13 additions & 0 deletions WdLgRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public WdLgRecord(string entry)
catch(Exception ex)
{
Program.LogMessage(" Error parsing date/time fields: " + ex.Message);
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing date/time fields: " + ex.Message, ConsoleColor.Red);
return;
}
Expand All @@ -60,6 +61,7 @@ public WdLgRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 6 (temperature)");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 6 (temperature)", ConsoleColor.Red);
}

Expand All @@ -70,6 +72,7 @@ public WdLgRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 7 (humidity)");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 7 (humidity)", ConsoleColor.Red);
}

Expand All @@ -80,6 +83,7 @@ public WdLgRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 8 (temperature)");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 8 (temperature)", ConsoleColor.Red);
}

Expand All @@ -90,6 +94,7 @@ public WdLgRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 9 (pressure)");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 9 (pressure)", ConsoleColor.Red);
}

Expand All @@ -106,6 +111,7 @@ public WdLgRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 10 (wind speed)");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 10 (wind speed)", ConsoleColor.Red);
}

Expand All @@ -122,6 +128,7 @@ public WdLgRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 11 (wind gust)");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 11 (wind gust)", ConsoleColor.Red);
}

Expand All @@ -132,6 +139,7 @@ public WdLgRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 12 (wind direction)");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 12 (wind direction)", ConsoleColor.Red);
}

Expand All @@ -142,6 +150,7 @@ public WdLgRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 13 (rain 1 hr");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 13 (rain 1 hr)", ConsoleColor.Red);
}

Expand All @@ -152,6 +161,7 @@ public WdLgRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 14 (rain day");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 14 (rain day)", ConsoleColor.Red);
}

Expand All @@ -162,6 +172,7 @@ public WdLgRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 15 (rain month");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 15 (rain month)", ConsoleColor.Red);
}

Expand All @@ -172,6 +183,7 @@ public WdLgRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 16 (rain year");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 16 (rain year)", ConsoleColor.Red);
}

Expand All @@ -182,6 +194,7 @@ public WdLgRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 17 (heat index)");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 17 (heat index)", ConsoleColor.Red);
}
}
Expand Down
3 changes: 3 additions & 0 deletions WdVantageExtraRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public WdVantageExtraRecord(string entry)
catch (Exception ex)
{
Program.LogMessage(" Error parsing date/time fields: " + ex.Message);
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing date/time fields: " + ex.Message, ConsoleColor.Red);
return;
}
Expand All @@ -58,6 +59,7 @@ public WdVantageExtraRecord(string entry)
else
{
Program.LogMessage($" Error parsing field {i + 5} (temperature-{i - 4})");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole($" Error parsing field {i + 5} (temperature-{i - 4})", ConsoleColor.Red);
}
}
Expand All @@ -71,6 +73,7 @@ public WdVantageExtraRecord(string entry)
else
{
Program.LogMessage($" Error parsing field {i + 12} (humidity-{i - 11})");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole($" Error parsing field {i + 12} (humidity-{i - 11})", ConsoleColor.Red);
}
}
Expand Down
6 changes: 6 additions & 0 deletions WdVantageRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public WdVantageRecord(string entry)
catch (Exception ex)
{
Program.LogMessage(" Error parsing date/time fields: " + ex.Message);
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing date/time fields: " + ex.Message, ConsoleColor.Red);
return;
}
Expand All @@ -46,6 +47,7 @@ public WdVantageRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 6 (solar rad)");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 6 (solar rad)", ConsoleColor.Red);
}

Expand All @@ -56,6 +58,7 @@ public WdVantageRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 7 (UV-I)");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 7 (UV-I)", ConsoleColor.Red);
}

Expand All @@ -66,6 +69,7 @@ public WdVantageRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 8 (ET)");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 8 (ET)", ConsoleColor.Red);
}

Expand All @@ -77,6 +81,7 @@ public WdVantageRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 9 (soil moisture)");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 9 (soil moisture)", ConsoleColor.Red);
}

Expand All @@ -87,6 +92,7 @@ public WdVantageRecord(string entry)
else
{
Program.LogMessage(" Error parsing field 8 (soil temperature)");
Program.LogMessage(" Error line: " + entry);
Program.LogConsole(" Error parsing field 8 (soil temperature)", ConsoleColor.Red);
}
}
Expand Down

0 comments on commit df0f1cb

Please sign in to comment.