Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

plugable logger instrument #131

Merged
merged 1 commit into from

3 participants

@timoschilling

new version of #130, sorry for the fuckup, i don't have seen the rebase in master

@TylerBrock TylerBrock merged commit 881ff7f into from
@timoschilling

Can we make a new gem version? I've written a gem that need's this pull request.
THX

@brandonblack

@timoschilling we have a new release coming out real soon. it was scheduled for today, but was pushed to next week. hang tight.

@timoschilling

@brandonblack next week would be nice :+1: THX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 14, 2012
  1. @timoschilling
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 1 deletion.
  1. +16 −1 lib/mongo/util/logging.rb
View
17 lib/mongo/util/logging.rb
@@ -29,12 +29,22 @@ def log(level, msg)
# Execute the block and log the operation described by name and payload.
def instrument(name, payload = {})
start_time = Time.now
- res = yield
+ res = Logging.instrumenter.instrument(name, payload) do
+ yield
+ end
duration = Time.now - start_time
log_operation(name, payload, duration)
res
end
+ def self.instrumenter
+ @instrumenter || Instrumenter
+ end
+
+ def self.instrumenter=(instrumenter)
+ @instrumenter = instrumenter
+ end
+
protected
def log_operation(name, payload, duration)
@@ -50,5 +60,10 @@ def log_operation(name, payload, duration)
end
end
+ module Instrumenter
+ def self.instrument(name, payload = {})
+ yield
+ end
+ end
end
end
Something went wrong with that request. Please try again.