Skip to content

Commit 81a6503

Browse files
committed
first commit 🎉
0 parents  commit 81a6503

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

README.md

Whitespace-only changes.

index.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var Debug = require('debug')
2+
var mongo = require('mongodb')
3+
var Logger = mongo.Logger
4+
var debugQuery = Debug('monk:query')
5+
var debugResult = Debug('monk:query')
6+
7+
Logger.setCurrentLogger(function (msg, context) {
8+
if (context.type === 'error') {
9+
return console.error(msg)
10+
}
11+
var logger = Debug('mongo:' + context.className)
12+
logger.log = console.log.bind(console)
13+
logger(context.type.toUpperCase() + ': ' + context.message)
14+
})
15+
Logger.setLevel('debug') // set the level to `debug` so we have everything going through debug
16+
17+
module.exports = function debug (context) {
18+
return function (next) {
19+
return function (args, method) {
20+
debugQuery('%s: %j', method, args)
21+
return next(args, method).then(function (res) {
22+
debugResult('%s: %j', method, res)
23+
return res
24+
})
25+
}
26+
}
27+
}

package.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "monk-plugin-debug",
3+
"description": "A monk plugin to show debug logs",
4+
"version": "0.2.0",
5+
"main": "index.js",
6+
"keywords": [
7+
"monk",
8+
"plugin",
9+
"debug"
10+
],
11+
"repository": {
12+
"type": "git",
13+
"url": "git://github.com/Automattic/monk.git"
14+
},
15+
"license": "MIT",
16+
"dependencies": {
17+
"debug": "*"
18+
},
19+
"peerDependencies": {
20+
"monk": ">=5.0.0",
21+
"mongodb": "*"
22+
}
23+
}

0 commit comments

Comments
 (0)