Class: Mongoid::LogSubscriber
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::LogSubscriber
- Mongoid::LogSubscriber
- Defined in:
- lib/mongoid/log_subscriber.rb
Overview
A Log subscriber to the moped queries
Instance Method Summary collapse
-
#debug(prefix, operations, runtime) ⇒ Object
Log the provided operations.
-
#logger ⇒ Logger
Get the logger.
-
#query(event) ⇒ Object
Log the query operation on moped.
- #query_cache(event) ⇒ Object
Instance Method Details
#debug(prefix, operations, runtime) ⇒ Object
Log the provided operations.
36 37 38 |
# File 'lib/mongoid/log_subscriber.rb', line 36 def debug(prefix, operations, runtime) Moped::Loggable.log_operations(prefix, operations, runtime) end |
#logger ⇒ Logger
Get the logger.
48 49 50 |
# File 'lib/mongoid/log_subscriber.rb', line 48 def logger Moped.logger end |
#query(event) ⇒ Object
Log the query operation on moped
11 12 13 14 15 16 17 |
# File 'lib/mongoid/log_subscriber.rb', line 11 def query(event) return unless logger.debug? payload = event.payload runtime = ("%.4fms" % event.duration) debug(payload[:prefix], payload[:ops], runtime) end |
#query_cache(event) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/mongoid/log_subscriber.rb', line 19 def query_cache(event) return unless logger.debug? database, collection, selector = event.payload[:key] operation = "%-12s database=%s collection=%s selector=%s" % ["QUERY CACHE", database, collection, selector.inspect] logger.debug operation end |