Class: LogStash::Filters::Ruby::Script
- Inherits:
-
Object
- Object
- LogStash::Filters::Ruby::Script
- Includes:
- Util::Loggable
- Defined in:
- lib/logstash/filters/ruby/script.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#script_path ⇒ Object
readonly
Returns the value of attribute script_path.
Instance Method Summary collapse
- #execute(event) ⇒ Object
-
#initialize(script_path, parameters) ⇒ Script
constructor
A new instance of Script.
- #load ⇒ Object
- #register ⇒ Object
- #test ⇒ Object
Constructor Details
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
5 6 7 |
# File 'lib/logstash/filters/ruby/script.rb', line 5 def content @content end |
#script_path ⇒ Object (readonly)
Returns the value of attribute script_path.
5 6 7 |
# File 'lib/logstash/filters/ruby/script.rb', line 5 def script_path @script_path end |
Instance Method Details
#execute(event) ⇒ Object
29 30 31 |
# File 'lib/logstash/filters/ruby/script.rb', line 29 def execute(event) @context.execute_filter(event) end |
#load ⇒ Object
13 14 15 16 17 18 19 20 21 |
# 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 ⇒ Object
23 24 25 26 27 |
# 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 ⇒ Object
33 34 35 36 37 38 39 |
# 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 |