Class: LogStash::Logging::SlowLogger
- Inherits:
-
Object
- Object
- LogStash::Logging::SlowLogger
- Defined in:
- lib/logstash/logging/logger.rb
Instance Method Summary collapse
- #as_data(plugin_params, event, took_in_nanos) ⇒ Object
-
#initialize(name, warn_threshold, info_threshold, debug_threshold, trace_threshold) ⇒ SlowLogger
constructor
A new instance of SlowLogger.
- #on_event(message, plugin_params, event, took_in_nanos) ⇒ Object
Constructor Details
#initialize(name, warn_threshold, info_threshold, debug_threshold, trace_threshold) ⇒ SlowLogger
Returns a new instance of SlowLogger.
128 129 130 131 132 133 134 135 |
# File 'lib/logstash/logging/logger.rb', line 128 def initialize(name, warn_threshold, info_threshold, debug_threshold, trace_threshold) slowlog_name = ["slowlog", name].join('.') @slowlogger = LogManager.getLogger(slowlog_name) @warn_threshold = warn_threshold @info_threshold = info_threshold @debug_threshold = debug_threshold @trace_threshold = trace_threshold end |
Instance Method Details
#as_data(plugin_params, event, took_in_nanos) ⇒ Object
137 138 139 140 141 142 143 144 |
# File 'lib/logstash/logging/logger.rb', line 137 def as_data(plugin_params, event, took_in_nanos) { :plugin_params => plugin_params, :took_in_nanos => took_in_nanos, :took_in_millis => took_in_nanos / 1000000, :event => event.to_json } end |
#on_event(message, plugin_params, event, took_in_nanos) ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/logstash/logging/logger.rb', line 146 def on_event(, plugin_params, event, took_in_nanos) if @warn_threshold >= 0 and took_in_nanos > @warn_threshold @slowlogger.warn(, as_data(plugin_params, event, took_in_nanos)) elsif @info_threshold >= 0 and took_in_nanos > @info_threshold @slowlogger.info(, as_data(plugin_params, event, took_in_nanos)) elsif @debug_threshold >= 0 and took_in_nanos > @debug_threshold @slowlogger.debug(, as_data(plugin_params, event, took_in_nanos)) elsif @trace_threshold >= 0 and took_in_nanos > @trace_threshold @slowlogger.trace(, as_data(plugin_params, event, took_in_nanos)) end end |