From 26a57d3cb59397a671fd4edcac12c7cd601df7fc Mon Sep 17 00:00:00 2001 From: John Andrews Date: Sun, 17 Apr 2022 20:45:09 +1200 Subject: [PATCH] added message and log with no dates for flow failure node --- BasicNodes/FlowFailure.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/BasicNodes/FlowFailure.cs b/BasicNodes/FlowFailure.cs index 02e42793..a097c2b8 100644 --- a/BasicNodes/FlowFailure.cs +++ b/BasicNodes/FlowFailure.cs @@ -1,4 +1,5 @@ using FileFlows.Plugin; +using System.Text.RegularExpressions; namespace FileFlows.BasicNodes; @@ -17,7 +18,9 @@ public class FlowFailure: Node { { "fail.Flow", "The Flow Name" }, { "fail.Log", "A short tail of the log" }, + { "fail.LogNoDates", "A short tail of the log" }, { "fail.Message", "A formatted message containing the failure details" }, + { "fail.MessageNoDates", "A formatted message containing the failure details" }, { "fail.Node", "FailedNodeName" }, }; } @@ -29,15 +32,24 @@ public class FlowFailure: Node string failedNode = args.GetVariable("FailedNode") as string ?? "Unknown"; string flowName = args.GetVariable("FlowName") as string ?? "Unknown"; + var rgxDateTime = new Regex(@"^[\d]{4}-[\d]{2}\-[\d]{2} [\d]{2}:[\d]{2}:[\d]{2}\.[\d]+ - "); + string logNoDates = string.Join(Environment.NewLine, log.Replace("\r\n", "\n").Split('\n').Select(x => rgxDateTime.Replace(x, ""))); + string message = @$"Failed processing file {args.FileName} Flow: {flowName} Node: {failedNode} {log}"; + string messageNoDates = @$"Failed processing file {args.FileName} +Flow: {flowName} +Node: {failedNode} +{logNoDates}"; Variables.AddOrUpdate("fail.Node", failedNode); Variables.AddOrUpdate("fail.Flow", flowName); Variables.AddOrUpdate("fail.Message", message); + Variables.AddOrUpdate("fail.MessageNoDates", messageNoDates); Variables.AddOrUpdate("fail.Log", log); + Variables.AddOrUpdate("fail.LogNoDates", logNoDates); args.UpdateVariables(Variables); return 1; }