class LogStash::Filters::Ruby::Script
Attributes
content[R]
script_path[R]
Public Class Methods
new(script_path, parameters)
click to toggle source
# File lib/logstash/filters/ruby/script.rb, line 7 def initialize(script_path, parameters) @content = File.read(script_path) @script_path = script_path @context = Context.new(self, parameters) end
Public Instance Methods
execute(event)
click to toggle source
# File lib/logstash/filters/ruby/script.rb, line 29 def execute(event) @context.execute_filter(event) end
load()
click to toggle source
# File lib/logstash/filters/ruby/script.rb, line 13 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
register()
click to toggle source
# File lib/logstash/filters/ruby/script.rb, line 23 def register @context.execute_register rescue => e raise ::LogStash::Filters::Ruby::ScriptError.new("Error during register of '#{script_path}': #{e.inspect}") end
test()
click to toggle source
# File lib/logstash/filters/ruby/script.rb, line 33 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