diff --git a/examples/simple/manifest.json b/examples/simple/manifest.json index c989f3c..568215c 100644 --- a/examples/simple/manifest.json +++ b/examples/simple/manifest.json @@ -1,27 +1,34 @@ { "server": { + "debug": false // disable Hapi debug console logging }, "register": { "hapi-pino": { "plugin": "require:hapi-pino", - "options": { - "mergeHapiLogData": false, - // "level": "debug", - "ignorePaths": [ - "/health", - "/alive.txt", - "/private" - ], - "tags": { "GET_items": "info", "GET_error": "error" }, - // transport option is not recomended for prod env - "transport": { - "target": "pino-pretty", - "options": { - "singleLine": true, - "colorize": true, - "mkdir": true, - "append": false, - "destination": "logs/output.log" + "options":{ + "$filter": "env.NODE_ENV", + "$default": { + "logRequestComplete": false, + "ignoredEventTags": { "log": ["client"], "request": "*" }, + "logPayload": false, + "transport": { + "targets": [ + { + "target": "pino/file", + "options": { + "destination": 1 + } + } + ] + } + }, + "development": { + "transport": { + "target": "pino-pretty", + "options": { + "colorize": true, + "translateTime": true + } } } } diff --git a/examples/simple/readme.md b/examples/simple/readme.md new file mode 100644 index 0000000..3577743 --- /dev/null +++ b/examples/simple/readme.md @@ -0,0 +1,61 @@ +# Catalyst server log configuration + +The follow diagram explains how our catalyst server manages logs + +![threads-diagram drawio](https://user-images.githubusercontent.com/88118994/149195822-de5d33ad-f29f-48ff-840b-ce2fb41eb08a.png) + +## [Pino-pretty](https://github.com/pinojs/pino-pretty) logs for development mode: + +install pino-pretty as a development dependency. + +` npm install --save-dev pino-pretty ` + +manifest.json +``` + "hapi-pino": { + "plugin": "require:hapi-pino", + "options": { + "$filter": "env.NODE_ENV", + "$default": {}, + "development": { + "transport": { + "target": "pino-pretty", + "options": { + "colorize": true, + "translateTime": true + } + } + } + } + } +``` + +pass the `NODE_ENV` as following: + +``` +NODE_ENV=development node ./examples/simple/index.js +``` + +## [Pino/file](https://github.com/pinojs/pino/blob/HEAD/docs/transports.md#pinofile) transport logs to stdout or file for production. + +``` + "transport": { + "targets": [ + { + "target": "pino/file", + "options": { + "destination": 1 + } + } + ] + } +``` + +## node js profile review + +``` +clinic doctor --autocannon [ /items ] -- node --max-http-header-size=32768 ./examples/simple/index.js | ./node_modules/.bin/pino-pretty --config=./examples/simple/.pino-prettyrc + +``` + + diff --git a/examples/simple/threads-diagram.drawio.png b/examples/simple/threads-diagram.drawio.png new file mode 100644 index 0000000..2ca2768 Binary files /dev/null and b/examples/simple/threads-diagram.drawio.png differ diff --git a/lib/config.json b/lib/config.json index 3b8d910..894c6fc 100644 --- a/lib/config.json +++ b/lib/config.json @@ -48,7 +48,7 @@ "translateTime": true } } - } + } } } } diff --git a/package.json b/package.json index 3410c6d..af3d841 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "@hapi/crumb": "^8.0.0", "@hapi/hoek": "^9.0.4", "@vrbo/steerage": "^12.1.3", - "hapi-pino": "^9.0.0", + "hapi-pino": "^9.1.1", "joi": "^17.2.0", "pino-pretty": "^7.2.0", "shortstop-handlers": "^1.0.1"