Class: LogStash::PluginMixins::Jdbc::CheckedCountLogger
- Inherits:
-
Object
- Object
- LogStash::PluginMixins::Jdbc::CheckedCountLogger
- Defined in:
- lib/logstash/plugin_mixins/jdbc/checked_count_logger.rb
Instance Method Summary collapse
- #check_count_query(query) ⇒ Object
- #execute_count(query) ⇒ Object
-
#initialize(logger) ⇒ CheckedCountLogger
constructor
A new instance of CheckedCountLogger.
- #log_statement_parameters(query, statement, parameters) ⇒ Object
Constructor Details
#initialize(logger) ⇒ CheckedCountLogger
Returns a new instance of CheckedCountLogger.
5 6 7 8 9 10 |
# File 'lib/logstash/plugin_mixins/jdbc/checked_count_logger.rb', line 5 def initialize(logger) @logger = logger @needs_check = true @count_is_supported = false @in_debug = @logger.debug? end |
Instance Method Details
#check_count_query(query) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/logstash/plugin_mixins/jdbc/checked_count_logger.rb', line 22 def check_count_query(query) @needs_check = false begin execute_count(query) @count_is_supported = true rescue Exception => e @logger.warn("Attempting a count query raised an error, the generated count statement is most likely incorrect but check networking, authentication or your statement syntax", "exception" => e.) @logger.warn("Ongoing count statement generation is being prevented") @count_is_supported = false end end |
#execute_count(query) ⇒ Object
34 35 36 |
# File 'lib/logstash/plugin_mixins/jdbc/checked_count_logger.rb', line 34 def execute_count(query) query.count end |
#log_statement_parameters(query, statement, parameters) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/logstash/plugin_mixins/jdbc/checked_count_logger.rb', line 12 def log_statement_parameters(query, statement, parameters) return unless @in_debug check_count_query(query) if @needs_check if @count_is_supported @logger.debug("Executing JDBC query", :statement => statement, :parameters => parameters, :count => execute_count(query)) else @logger.debug("Executing JDBC query", :statement => statement, :parameters => parameters) end end |