Created
February 8, 2011 00:37
-
-
Save visnup/815607 to your computer and use it in GitHub Desktop.
# trippy mongodb colorized logging by statement type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Mongoid::Logger | |
def debug message | |
op = | |
case message | |
when /insert/ then "\e[0;32m(C)\e[0m" | |
when /find|cursor/ then "\e[0;34m(R)\e[0m" | |
when /update/ then "\e[0;33m(U)\e[0m" | |
when /remove/ then "\e[0;31m(D)\e[0m" | |
end | |
logger.debug("#{op} #{message}") if logger && logger.respond_to?(:debug) | |
end | |
end | |
ooh good idea. I'm going to wait until the next mongo ruby driver is released for that though. they just updated it with easier to override instrumentation methods for those types of things.
@visnup I too liked the idea. Gonna watch it or have you already started?
ooh, mongo ruby driver 1.2.1 just got released. I'll see if I can update it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great. But I'd love to see colours for any ObjectId in the output and also for the collection names :)