Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
pino-http-send
Advanced tools
A basic handler for [pino](https://github.com/pinojs/pino) logs that sends batches to a desired endpoint via HTTP or HTTPS.
A basic handler for pino logs that sends batches to a desired endpoint via HTTP or HTTPS.
Pre v1 is subject to breaking changes on minor version change.
$ npm i pino-http-send
$ pino-http-send --help
pino-http-send [options]
Sending
--method, -m
[string] [choices: "POST", "PUT", "PATCH", "GET"] [default: "POST"]
--bodyType, -b type of body to send
[string] [choices: "json", "ndjson"] [default: "json"]
--url url to send logs to [string] [required]
--batchSize, -s how many logs to send at a time [number] [default: 10]
--timeout, -t timeout (in ms) to send logs in bucket that are not filled
[number] [default: 5000]
Basic Auth
--username, -u basic auth username [string]
--password, -p basic auth password [string]
Retry
--retries, -r number of retries to do if failure [number] [default: 5]
--interval, -i interval (in ms) to retry sending if failure
[number] [default: 1000]
Options:
--help Show help [boolean]
--version Show version number [boolean]
--log, -l log to console as well [boolean] [default: false]
--silent silence pino-http-send logs for failures and retries
[boolean] [default: false]
--config, -c path to json config [string]
All options can be defined in the environment and are prefixed with PINO_HTTP_SEND_
. All
camel-cased options are parsed with delimiters of _
.
e.g. The option batchSize
as an env var would be PINO_HTTP_SEND_BATCH_SIZE
.
Example
$ node . | pino-http-send --url=http://localhost:8080
You can also do https...
$ node . | pino-http-send --url=https://myserver.com:8080
ndjson
- New-line delimited JSON. See ndjsonjson
- Standard JSON sending of data. Logs are sent in the format of
{
"logs": [...logs]
}
Currently only basic auth is implemented for the CLI usage. For header usage, you can see the API usage.
You can also use this module as a pino destination.
This will use the same batching function like the CLI usage. If the batch length
is not reached within a certain time (timeout
), it will auto "flush".
createWriteStream
The options passed to this follow the same values as the CLI defined above.
Property | Type | Required/Default |
---|---|---|
url | string | REQUIRED |
log | boolean | false |
silent | boolean | false |
method | string | "POST" |
bodyType | string | "json" |
username | string | |
password | string | |
headers | Record<string,string> | |
batchSize | number | 10 |
retries | number | 5 |
interval | number | 1000 |
timeout | number | 5000 |
config | string |
import { createWriteStream } from 'pino-http-send';
const stream = createWriteStream({
url: 'http://localhost:8080',
});
const logger = pino(
{
level: 'info',
},
stream,
);
logger.info('test log!');
FAQs
A basic handler for [pino](https://github.com/pinojs/pino) logs that sends batches to a desired endpoint via HTTP or HTTPS.
The npm package pino-http-send receives a total of 4,929 weekly downloads. As such, pino-http-send popularity was classified as popular.
We found that pino-http-send demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.