Class: QueryDiet::Logger
- Inherits:
-
Object
- Object
- QueryDiet::Logger
- Defined in:
- lib/query_diet/logger.rb
Class Attribute Summary collapse
-
.bad_count ⇒ Object
Returns the value of attribute bad_count.
-
.bad_time ⇒ Object
Returns the value of attribute bad_time.
-
.count ⇒ Object
Returns the value of attribute count.
-
.time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
Class Attribute Details
.bad_count ⇒ Object
Returns the value of attribute bad_count.
5 6 7 |
# File 'lib/query_diet/logger.rb', line 5 def bad_count @bad_count end |
.bad_time ⇒ Object
Returns the value of attribute bad_time.
5 6 7 |
# File 'lib/query_diet/logger.rb', line 5 def bad_time @bad_time end |
.count ⇒ Object
Returns the value of attribute count.
5 6 7 |
# File 'lib/query_diet/logger.rb', line 5 def count @count end |
.time ⇒ Object
Returns the value of attribute time.
5 6 7 |
# File 'lib/query_diet/logger.rb', line 5 def time @time end |
Class Method Details
.bad? ⇒ Boolean
24 25 26 |
# File 'lib/query_diet/logger.rb', line 24 def bad? count >= bad_count or time >= bad_time end |
.log(query, &execution) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/query_diet/logger.rb', line 12 def log(query, &execution) result = nil seconds = Benchmark.realtime do result = execution.call end if log_query?(query) self.time += (seconds * 1000).to_i self.count += 1 end result end |
.reset ⇒ Object
7 8 9 10 |
# File 'lib/query_diet/logger.rb', line 7 def reset self.count = 0 self.time = 0 end |