Simple logger native plugin

This commit is contained in:
Daniel Bulant 2020-03-01 19:26:30 +01:00
parent 0c1bdce0f1
commit 7e68d0e4d6
4 changed files with 18 additions and 14 deletions

15
plugins/logger/index.js Normal file
View 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");
}
}

View file

@ -0,0 +1,3 @@
{
"main": "index.js"
}

View file

@ -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="
}
}
}

View file

@ -10,6 +10,5 @@
"license": "ISC",
"description": "",
"dependencies": {
"fastcgi-client": "0.0.1"
}
}