Created
March 13, 2013 10:27
-
-
Save fabriziomoscon/5150887 to your computer and use it in GitHub Desktop.
mongoLogger is an object literal to pass to the mongo-node-native driver to produce formatted query log, very useful for development and testing environment. Not suitable for production.
The binary log is present but commented out
This file contains hidden or 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
mongoLogger = | |
error: (message, command) -> | |
console.log('\x1B[0;31mMongo ERR:\x1B[0m %s', message) if message? | |
console.log('\x1B[0;31mMongo ERR:\x1B[0m %s', command) if command? | |
log: (message, command) -> | |
console.log('\x1B[0;33mMongo LOG:\x1B[0m %s', message) if message? | |
console.log('\x1B[0;33mMongo LOG:\x1B[0m %s', command) if command? | |
debug: (message, command) -> | |
if message? | |
console.log '\x1B[0;36mMongo DEBUG:\x1B[0m %s', message | |
if command?.json? | |
console.log "collection [#{command.json.collectionName}]" if command.json.collectionName? | |
console.log 'spec', command.json.spec if command.json.spec? | |
console.log 'query', command.json.query if command.json.query? | |
console.log 'document', command.json.document if command.json.document? | |
# if command?.binary? | |
# console.log 'Mongo DEBUG bin', command.binary | |
doDebug: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment