feat: enhance logging in RoutingFeedbackManager for better debugging

This commit is contained in:
Neil Dorin 2026-03-12 21:36:21 -06:00
parent 165e8c6d34
commit 3762fc120a

View file

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Core.Routing namespace PepperDash.Essentials.Core.Routing
@ -122,20 +123,16 @@ namespace PepperDash.Essentials.Core.Routing
RoutingInputPort inputPort RoutingInputPort inputPort
) )
{ {
Debug.LogMessage( this.LogDebug(
Serilog.Events.LogEventLevel.Debug,
"Updating destination {destination} with inputPort {inputPort}", "Updating destination {destination} with inputPort {inputPort}",
this,
destination?.Key, destination?.Key,
inputPort?.Key inputPort?.Key
); );
if (inputPort == null) if (inputPort == null)
{ {
Debug.LogMessage( this.LogDebug(
Serilog.Events.LogEventLevel.Debug,
"Destination {destination} has not reported an input port yet", "Destination {destination} has not reported an input port yet",
this,
destination.Key destination.Key
); );
return; return;
@ -153,10 +150,8 @@ namespace PepperDash.Essentials.Core.Routing
if (firstTieLine == null) if (firstTieLine == null)
{ {
Debug.LogMessage( this.LogDebug(
Serilog.Events.LogEventLevel.Debug,
"No tieline found for inputPort {inputPort}. Clearing current source", "No tieline found for inputPort {inputPort}. Clearing current source",
this,
inputPort inputPort
); );
@ -174,7 +169,7 @@ namespace PepperDash.Essentials.Core.Routing
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.LogMessage(ex, "Error getting first tieline: {Exception}", this, ex); this.LogException(ex, "Error getting first tieline: {Exception}", ex.Message);
return; return;
} }
@ -187,8 +182,7 @@ namespace PepperDash.Essentials.Core.Routing
if (sourceTieLine == null) if (sourceTieLine == null)
{ {
Debug.LogMessage( this.LogDebug(
Serilog.Events.LogEventLevel.Debug,
"No route found to source for inputPort {inputPort}. Clearing current source", "No route found to source for inputPort {inputPort}. Clearing current source",
this, this,
inputPort inputPort
@ -207,7 +201,7 @@ namespace PepperDash.Essentials.Core.Routing
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.LogMessage(ex, "Error getting sourceTieLine: {Exception}", this, ex); this.LogException(ex, "Error getting sourceTieLine: {Exception}", ex.Message);
return; return;
} }
@ -246,16 +240,14 @@ namespace PepperDash.Essentials.Core.Routing
if (room == null) if (room == null)
{ {
Debug.LogMessage( this.LogDebug(
Serilog.Events.LogEventLevel.Debug, "No room found for display {destination}",
"No room found for display {destination}", destination.Key
this, );
destination.Key
);
return; return;
} }
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Found room {room} for destination {destination}", this, room.Key, destination.Key); this.LogVerbose("Found room {room} for destination {destination}", room.Key, destination.Key);
Dictionary<string, SourceListItem> sourceList = null; Dictionary<string, SourceListItem> sourceList = null;
@ -263,30 +255,27 @@ namespace PepperDash.Essentials.Core.Routing
{ {
sourceList = roomWithSourceList.SourceList; sourceList = roomWithSourceList.SourceList;
} }
else { else
sourceList = ConfigReader.ConfigObject.GetSourceListForKey(room.SourceListKey); {
} sourceList = ConfigReader.ConfigObject.GetSourceListForKey(room.SourceListKey);
}
if (sourceList == null) if (sourceList == null)
{ {
Debug.LogMessage( this.LogDebug(
Serilog.Events.LogEventLevel.Debug,
"No source list found for source list key {key}. Unable to find source for tieLine {sourceTieLine}", "No source list found for source list key {key}. Unable to find source for tieLine {sourceTieLine}",
this,
room.SourceListKey, room.SourceListKey,
sourceTieLine sourceTieLine
); );
return; return;
} }
// Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Found sourceList for room {room}", this, room.Key); this.LogVerbose("Found sourceList for room {room}", room.Key);
if (sourceTieLine.SourcePort?.ParentDevice == null) if (sourceTieLine.SourcePort?.ParentDevice == null)
{ {
Debug.LogMessage( this.LogDebug(
Serilog.Events.LogEventLevel.Debug,
"********SourcePort or ParentDevice is null for tieLine. Unable to find source for destination {destination}.", "********SourcePort or ParentDevice is null for tieLine. Unable to find source for destination {destination}.",
this,
destination.Key destination.Key
); );
return; return;
@ -296,9 +285,8 @@ namespace PepperDash.Essentials.Core.Routing
{ {
if (sli.Value == null) return false; if (sli.Value == null) return false;
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, this.LogVerbose(
"********SourceListItem {sourceListItem}:{sourceKey} tieLine sourceport device key {sourcePortDeviceKey}", "********SourceListItem {sourceListItem}:{sourceKey} tieLine sourceport device key {sourcePortDeviceKey}",
this,
sli.Key, sli.Key,
sli.Value.SourceKey, sli.Value.SourceKey,
sourceTieLine.SourcePort.ParentDevice.Key); sourceTieLine.SourcePort.ParentDevice.Key);
@ -314,10 +302,8 @@ namespace PepperDash.Essentials.Core.Routing
if (source == null) if (source == null)
{ {
Debug.LogMessage( this.LogDebug(
Serilog.Events.LogEventLevel.Debug,
"No source found for device {key}. Creating transient source for {destination}", "No source found for device {key}. Creating transient source for {destination}",
this,
sourceTieLine.SourcePort.ParentDevice.Key, sourceTieLine.SourcePort.ParentDevice.Key,
destination.Key destination.Key
); );
@ -333,7 +319,7 @@ namespace PepperDash.Essentials.Core.Routing
return; return;
} }
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Got Source {@source} with key {sourceKey}", this, source, sourceKey); this.LogVerbose("Got Source {@source} with key {sourceKey}", source, sourceKey);
destination.CurrentSourceInfoKey = sourceKey; destination.CurrentSourceInfoKey = sourceKey;
destination.CurrentSourceInfo = source; destination.CurrentSourceInfo = source;