Sha256: 05c87f9d49c75577e4cda562dd0518984ac0059383e4a1510c5d64dd76bd9c97
Contents?: true
Size: 1.25 KB
Versions: 9
Compression:
Stored size: 1.25 KB
Contents
class LogStash::Filters::Ruby::Script include ::LogStash::Util::Loggable require "logstash/filters/ruby/script/context" attr_reader :content, :script_path def initialize(script_path, parameters) @content = File.read(script_path) @script_path = script_path @context = Context.new(self, parameters) end def load @context.load_script if !@context.execution_context.methods.include?(:filter) raise "Script does not define a filter! Please ensure that you have defined a filter method!" end rescue => e raise ::LogStash::Filters::Ruby::ScriptError.new("Error during load of '#{script_path}': #{e.inspect}") end def register @context.execute_register rescue => e raise ::LogStash::Filters::Ruby::ScriptError.new("Error during register of '#{script_path}': #{e.inspect}") end def execute(event) @context.execute_filter(event) end def test results = @context.execute_tests logger.info("Test run complete", :script_path => script_path, :results => results) if results[:failed] > 0 || results[:errored] > 0 raise ::LogStash::Filters::Ruby::ScriptError.new("Script '#{script_path}' had #{results[:failed] + results[:errored]} failing tests! Check the error log for details.") end end end
Version data entries
9 entries across 9 versions & 1 rubygems