Files
FileFlowsPlugins/BasicNodes/Functions/Log.cs
2021-11-24 17:55:27 +13:00

38 lines
1.2 KiB
C#

namespace FileFlows.BasicNodes.Functions
{
using System.ComponentModel;
using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
using Jint.Runtime;
using Jint.Native.Object;
using Jint;
using System.Text;
using System.ComponentModel.DataAnnotations;
public class Log : Node
{
public override int Inputs => 1;
public override int Outputs => 1;
public override FlowElementType Type => FlowElementType.Logic;
public override string Icon => "far fa-file-alt";
[Enum(1, LogType.Info, LogType.Debug, LogType.Warning, LogType.Error)]
public LogType LogType { get; set; }
[TextArea(2)]
[Required]
public string Message { get; set; }
public override int Execute(NodeParameters args)
{
switch (LogType)
{
case LogType.Error: args.Logger.ELog(Message); break;
case LogType.Warning: args.Logger.WLog(Message); break;
case LogType.Debug: args.Logger.DLog(Message); break;
case LogType.Info: args.Logger.ILog(Message); break;
}
return base.Execute(args);
}
}
}