Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
chore: updates docs and example to use transports (#49)
Browse files Browse the repository at this point in the history
chore: updates docs and example to use transports

Co-authored-by: Bryan Shell <shellbj@users.noreply.github.com>
  • Loading branch information
aaestrada and shellbj committed Feb 3, 2022
1 parent 9e48217 commit 3aaebb5
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 20 deletions.
43 changes: 25 additions & 18 deletions 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
}
}
}
}
Expand Down
61 changes: 61 additions & 0 deletions 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
```


Binary file added examples/simple/threads-diagram.drawio.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion lib/config.json
Expand Up @@ -48,7 +48,7 @@
"translateTime": true
}
}
}
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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"
Expand Down

0 comments on commit 3aaebb5

Please sign in to comment.