using FileFlows.Plugin; using FileFlows.Plugin.Attributes; using System.ComponentModel.DataAnnotations; namespace FileFlows.BasicNodes.Logging; /// /// Flow that logs a image to the Flow logger /// public class LogImage : Node { /// public override int Inputs => 1; /// public override int Outputs => 1; /// public override FlowElementType Type => FlowElementType.Logic; /// public override string Icon => "far fa-image"; /// public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/log-image"; /// public override bool FailureNode => true; /// public override string Group => "Logging"; /// /// Gets or sets the file to log /// [TextVariable(1)] [Required] public string ImageFile { get; set; } /// public override int Execute(NodeParameters args) { var file = args.ReplaceVariables(ImageFile ?? string.Empty, stripMissing: true); if (string.IsNullOrWhiteSpace(file)) { args.Logger?.WLog("No image defined"); return 2; } var localFileResult = args.FileService.GetLocalPath(file); if (localFileResult.Failed(out var error)) { args.Logger?.WLog(error); return 2; } var localFile = localFileResult.Value; var info = args.ImageHelper.GetInfo(localFile); if(info.Failed(out error)) { args.Logger?.ILog("Not an image: " + file); args.Logger?.ILog(error); return 2; } args.LogImage(localFile); return 1; } }