Class: GroongaClientModel::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- GroongaClientModel::LogSubscriber
- Defined in:
- lib/groonga_client_model/log_subscriber.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.measure ⇒ Object
39 40 41 42 43 |
# File 'lib/groonga_client_model/log_subscriber.rb', line 39 def measure before_runtime = runtime yield runtime - before_runtime end |
.reset_runtime ⇒ Object
35 36 37 |
# File 'lib/groonga_client_model/log_subscriber.rb', line 35 def reset_runtime self.runtime = 0.0 end |
.runtime ⇒ Object
24 25 26 |
# File 'lib/groonga_client_model/log_subscriber.rb', line 24 def runtime Thread.current["groonga_client_model.log_subscriber.runtime"] end |
.runtime=(value) ⇒ Object
28 29 30 |
# File 'lib/groonga_client_model/log_subscriber.rb', line 28 def runtime=(value) Thread.current["groonga_client_model.log_subscriber.runtime"] = value end |
Instance Method Details
#groonga(event) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/groonga_client_model/log_subscriber.rb', line 46 def groonga(event) self.class.runtime = (self.class.runtime || 0) + event.duration debug do command = event.payload[:command] title = color("#{command.command_name} (#{event.duration.round(1)}ms)", title_color(command), true) formatted_command = color(command.to_command_format, command_color(command), true) " #{title} #{formatted_command}" end end |