https://github.com/linusu/pino-got
A Got handler that logs all requests to a Pino logger
https://github.com/linusu/pino-got
hacktoberfest http logger nodejs pino
Last synced: 29 days ago
JSON representation
A Got handler that logs all requests to a Pino logger
- Host: GitHub
- URL: https://github.com/linusu/pino-got
- Owner: LinusU
- Created: 2020-10-21T17:01:36.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-09T14:38:25.000Z (12 months ago)
- Last Synced: 2024-12-28T04:46:35.866Z (9 months ago)
- Topics: hacktoberfest, http, logger, nodejs, pino
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Pino: Got
A [Got](https://github.com/sindresorhus/got) handler that logs all requests to a [Pino](https://github.com/pinojs/pino) logger.
## Installation
```sh
npm install --save pino-got
```## Compatibility
`pino-got` | `got` | `pino`
---------- | ------ | ------
**`2.x`** | `14.x`, `13.x`, `12.x` | `9.x`, `8.x`
**`1.x`** | `11.x` | `6.x`## Usage
```js
import got from 'got'
import pino from 'pino'
import pinoGot from 'pino-got'const logger = pino({ level: 'debug' })
const gotLogger = pinoGot(logger)
const client = got.extend({ handlers: [gotLogger] })client.get('https://example.com/')
```Example output with [pino-pretty](https://github.com/pinojs/pino-pretty):
```text
[1603000000227] DEBUG (88800 on Linus-MacBook-Pro.local): Making GET request to https://example.com/
method: "GET"
headers: {
"user-agent": "got (https://github.com/sindresorhus/got)"
}[1603000000694] DEBUG (88800 on Linus-MacBook-Pro.local): Got successful response in 467ms
statusCode: 200
headers: {
"content-encoding": "gzip",
"age": "451741",
"cache-control": "max-age=604800",
"content-type": "text/html; charset=UTF-8",
"date": "Wed, 18 Oct 2020 05:46:40 GMT",
"etag": "\"3147526947+gzip\"",
"expires": "Wed, 25 Oct 2020 05:46:40 GMT",
"last-modified": "Thu, 17 Oct 2019 07:18:26 GMT",
"server": "ECS (nyb/1D1F)",
"vary": "Accept-Encoding",
"x-cache": "HIT",
"content-length": "648",
"connection": "close"
}
body: "..."
duration: "467ms"
```