Module: Mongo::Logging
- Included in:
- Collection, Cursor, MongoClient
- Defined in:
- lib/mongo/util/logging.rb
Defined Under Namespace
Modules: Instrumenter
Class Method Summary collapse
Instance Method Summary collapse
-
#instrument(name, payload = {}) ⇒ Object
Execute the block and log the operation described by name and payload.
-
#log(level, msg) ⇒ Object
Log a message with the given level.
- #write_logging_startup_message ⇒ Object
Class Method Details
.instrumenter ⇒ Object
62 63 64 |
# File 'lib/mongo/util/logging.rb', line 62 def self.instrumenter @instrumenter end |
.instrumenter=(instrumenter) ⇒ Object
66 67 68 |
# File 'lib/mongo/util/logging.rb', line 66 def self.instrumenter=(instrumenter) @instrumenter = instrumenter end |
Instance Method Details
#instrument(name, payload = {}) ⇒ Object
Execute the block and log the operation described by name and payload.
52 53 54 55 56 57 58 59 60 |
# File 'lib/mongo/util/logging.rb', line 52 def instrument(name, payload = {}) start_time = Time.now res = Logging.instrumenter.instrument(name, payload) do yield end duration = Time.now - start_time log_operation(name, payload, duration) res end |
#log(level, msg) ⇒ Object
Log a message with the given level.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/mongo/util/logging.rb', line 33 def log(level, msg) return unless @logger case level when :fatal then @logger.fatal "MONGODB [FATAL] #{msg}" when :error then @logger.error "MONGODB [ERROR] #{msg}" when :warn then @logger.warn "MONGODB [WARNING] #{msg}" when :info then @logger.info "MONGODB [INFO] #{msg}" when :debug then @logger.debug "MONGODB [DEBUG] #{msg}" else @logger.debug "MONGODB [DEBUG] #{msg}" end end |
#write_logging_startup_message ⇒ Object
26 27 28 29 30 |
# File 'lib/mongo/util/logging.rb', line 26 def log(:debug, "Logging level is currently :debug which could negatively impact " + "client-side performance. You should set your logging level no lower than " + ":info in production.") end |