mirror of
https://github.com/danbulant/koa-plugins
synced 2026-05-19 04:08:43 +00:00
Simple logger native plugin
This commit is contained in:
parent
0c1bdce0f1
commit
7e68d0e4d6
4 changed files with 18 additions and 14 deletions
15
plugins/logger/index.js
Normal file
15
plugins/logger/index.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* Simple logging utility
|
||||
*/
|
||||
module.exports = {
|
||||
native: true,
|
||||
async exec(ctx, next){
|
||||
var start = process.hrtime();
|
||||
await next();
|
||||
var end = process.hrtime(start);
|
||||
|
||||
end = (end[0] * 1000) + (end[1] / 10000);
|
||||
|
||||
process.stdout.write("[" + ctx.request.method + "] " + ctx.status + " " + end + "ms " + ctx.request.path + "\n");
|
||||
}
|
||||
}
|
||||
3
plugins/logger/package.json
Normal file
3
plugins/logger/package.json
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"main": "index.js"
|
||||
}
|
||||
13
plugins/php/package-lock.json
generated
13
plugins/php/package-lock.json
generated
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"name": "php",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"fastcgi-client": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fastcgi-client/-/fastcgi-client-0.0.1.tgz",
|
||||
"integrity": "sha1-EEbUL/LO4qmsA/6gRpWz73MRhhw="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,5 @@
|
|||
"license": "ISC",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"fastcgi-client": "0.0.1"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue