namespace FileFlows.BasicNodes.Functions;
using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
using System.ComponentModel.DataAnnotations;
///
/// Node that logs a message to the Flow logger
///
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";
///
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/log";
///
public override bool FailureNode => true;
///
/// Gets or sets teh log type
///
[Enum(1, LogType.Info, LogType.Debug, LogType.Warning, LogType.Error)]
public LogType LogType { get; set; }
///
/// Gets the message to log
///
[TextArea(2, variables: true)]
[Required]
public string Message { get; set; }
///
public override int Execute(NodeParameters args)
{
var message = args.ReplaceVariables(Message ?? string.Empty, stripMissing: true);
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 1;
}
}