VL.Syslog by sebl

<PackageReference Include="VL.Syslog" Version="0.3.0" />

 SyslogSplitNode

public class SyslogSplitNode : IPluginEvaluate, IPluginBase
using System.IO; using System.Text; using VVVV.Nodes.Syslog.Parser; using VVVV.PluginInterfaces.V2; namespace VVVV.Nodes.Syslog { [PluginInfo] public class SyslogSplitNode { [Input("Input")] public ISpread<Stream> FStreamIn; [Output("Message")] public ISpread<string> FMessage; [Output("Facility")] public ISpread<SyslogFacility> FFacility; [Output("Severity")] public ISpread<SyslogSeverity> FSeverity; [Output("Timestamp")] public ISpread<string> FTimestamp; [Output("Hostname")] public ISpread<string> FHostname; [Output("AppName")] public ISpread<string> FAppName; [Output("Process ID")] public ISpread<string> FProcId; [Output("Message ID")] public ISpread<string> FMsgId; [Output("Structured Data Name")] public ISpread<ISpread<string>> FStructuredDataName; [Output("Structured Data Value")] public ISpread<ISpread<string>> FStructuredDataValue; public void Evaluate(int spreadMax) { FMessage.set_SliceCount(spreadMax); FFacility.set_SliceCount(spreadMax); FSeverity.set_SliceCount(spreadMax); FTimestamp.set_SliceCount(spreadMax); FHostname.set_SliceCount(spreadMax); FAppName.set_SliceCount(spreadMax); FProcId.set_SliceCount(spreadMax); FMsgId.set_SliceCount(spreadMax); FStructuredDataName.set_SliceCount(spreadMax); FStructuredDataValue.set_SliceCount(spreadMax); for (int i = 0; i < spreadMax; i++) { if (FStreamIn.get_Item(i).Length > 0) { byte[] array = new byte[FStreamIn.get_Item(i).Length]; FStreamIn.get_Item(i).Read(array, 0, (int)FStreamIn.get_Item(i).Length); string string = Encoding.ASCII.GetString(array, 0, array.Length); SyslogMessage syslogMessage = new SyslogParser().Parse(string); if (syslogMessage != null) { FMessage.set_Item(i, syslogMessage.MessageText); FFacility.set_Item(i, syslogMessage.Facility); FSeverity.set_Item(i, syslogMessage.Severity); FTimestamp.set_Item(i, syslogMessage.TimeStamp.ToString()); FHostname.set_Item(i, syslogMessage.HostName); FAppName.set_Item(i, syslogMessage.AppName); FProcId.set_Item(i, syslogMessage.ProcessID); FMsgId.set_Item(i, syslogMessage.MessageID); int count = syslogMessage.StructuredData.Count; FStructuredDataName.get_Item(i).set_SliceCount(0); FStructuredDataValue.get_Item(i).set_SliceCount(0); for (int j = 0; j < count; j++) { int count2 = syslogMessage.StructuredData[j].Properties.Count; for (int k = 0; k < count2; k++) { SpreadExtensions.Add<string>(FStructuredDataName.get_Item(i), syslogMessage.StructuredData[j].Properties.AllKeys[k]); SpreadExtensions.Add<string>(FStructuredDataValue.get_Item(i), syslogMessage.StructuredData[j].Properties.GetValues(k)[0]); } } } else { FMessage.set_Item(i, "corrupt message"); FFacility.set_Item(i, SyslogFacility.Unknown); FSeverity.set_Item(i, SyslogSeverity.Unknown); FTimestamp.set_Item(i, ""); FHostname.set_Item(i, ""); FAppName.set_Item(i, ""); FProcId.set_Item(i, ""); FMsgId.set_Item(i, ""); FStructuredDataName.get_Item(i).set_SliceCount(0); FStructuredDataValue.get_Item(i).set_SliceCount(0); } } } } } }