Comparing version 9.4.0 to 9.5.0
@@ -283,4 +283,4 @@ 'use strict' | ||
const transmitLevel = opts.transmit.level || self.level | ||
const transmitValue = rootLogger.levels.values[transmitLevel] | ||
const methodValue = rootLogger.levels.values[level] | ||
const transmitValue = levelToValue(transmitLevel, rootLogger) | ||
const methodValue = levelToValue(level, rootLogger) | ||
if (methodValue < transmitValue) return | ||
@@ -326,4 +326,4 @@ } | ||
const transmitLevel = opts.transmit.level || self._level | ||
const transmitValue = rootLogger.levels.values[transmitLevel] | ||
const methodValue = rootLogger.levels.values[level] | ||
const transmitValue = levelToValue(transmitLevel, rootLogger) | ||
const methodValue = levelToValue(level, rootLogger) | ||
if (methodValue < transmitValue) return | ||
@@ -330,0 +330,0 @@ transmit(this, { |
@@ -18,3 +18,3 @@ # Transports | ||
and can be used or configured via the options object passed to `pino` on initialization. | ||
In this case the transports would always operate asynchronously, and logs would be | ||
In this case the transports would always operate asynchronously (unless `options.sync` is set to `true` in transport options), and logs would be | ||
flushed as quickly as possible (there is nothing to do). | ||
@@ -128,2 +128,15 @@ | ||
To make pino log synchronously, pass `sync: true` to transport options. | ||
```js | ||
const pino = require('pino') | ||
const transport = pino.transport({ | ||
targets: [ | ||
{ target: '/absolute/path/to/my-transport.mjs', level: 'error' }, | ||
], | ||
dedupe: true, | ||
sync: true, | ||
}); | ||
pino(transport); | ||
``` | ||
For more details on `pino.transport` see the [API docs for `pino.transport`][pino-transport]. | ||
@@ -415,17 +428,20 @@ | ||
+ [@axiomhq/pino](#@axiomhq/pino) | ||
+ [@logtail/pino](#@logtail/pino) | ||
+ [@macfja/pino-fingers-crossed](#macfja-pino-fingers-crossed) | ||
+ [pino-airbrake-transport](#pino-airbrake-transport) | ||
+ [pino-axiom](#pino-axiom) | ||
+ [pino-datadog-transport](#pino-datadog-transport) | ||
+ [pino-discord-webhook](#pino-discord-webhook) | ||
+ [pino-elasticsearch](#pino-elasticsearch) | ||
+ [pino-hana](#pino-hana) | ||
+ [pino-logfmt](#pino-logfmt) | ||
+ [pino-loki](#pino-loki) | ||
+ [pino-opentelemetry-transport](#pino-opentelemetry-transport) | ||
+ [pino-pretty](#pino-pretty) | ||
+ [pino-loki](#pino-loki) | ||
+ [pino-seq-transport](#pino-seq-transport) | ||
+ [pino-sentry-transport](#pino-sentry-transport) | ||
+ [pino-airbrake-transport](#pino-airbrake-transport) | ||
+ [pino-datadog-transport](#pino-datadog-transport) | ||
+ [pino-slack-webhook](#pino-slack-webhook) | ||
+ [pino-axiom](#pino-axiom) | ||
+ [pino-opentelemetry-transport](#pino-opentelemetry-transport) | ||
+ [@axiomhq/pino](#@axiomhq/pino) | ||
+ [pino-discord-webhook](#pino-discord-webhook) | ||
+ [pino-logfmt](#pino-logfmt) | ||
+ [pino-slack-webhook](#pino-slack-webhook) | ||
+ [pino-telegram-webhook](#pino-telegram-webhook) | ||
+ [pino-yc-transport](#pino-yc-transport) | ||
@@ -458,2 +474,30 @@ ### Legacy | ||
<a id="@axiomhq/pino"></a> | ||
### @axiomhq/pino | ||
[@axiomhq/pino](https://www.npmjs.com/package/@axiomhq/pino) is the official [Axiom](https://axiom.co/) transport for Pino, using [axiom-js](https://github.com/axiomhq/axiom-js). | ||
```javascript | ||
import pino from 'pino'; | ||
const logger = pino( | ||
{ level: 'info' }, | ||
pino.transport({ | ||
target: '@axiomhq/pino', | ||
options: { | ||
dataset: process.env.AXIOM_DATASET, | ||
token: process.env.AXIOM_TOKEN, | ||
}, | ||
}), | ||
); | ||
``` | ||
then you can use the logger as usual: | ||
```js | ||
logger.info('Hello from pino!'); | ||
``` | ||
For further examples, head over to the [examples](https://github.com/axiomhq/axiom-js/tree/main/examples/pino) directory. | ||
<a id="@logtail/pino"></a> | ||
@@ -466,2 +510,52 @@ ### @logtail/pino | ||
<a id="macfja-pino-fingers-crossed"></a> | ||
### @macfja/pino-fingers-crossed | ||
[@macfja/pino-fingers-crossed](https://github.com/MacFJA/js-pino-fingers-crossed) is a Pino v7+ transport that holds logs until a log level is reached, allowing to only have logs when it matters. | ||
```js | ||
const pino = require('pino'); | ||
const { default: fingersCrossed, enable } = require('@macfja/pino-fingers-crossed') | ||
const logger = pino(fingersCrossed()); | ||
logger.info('Will appear immedialty') | ||
logger.error('Will appear immedialty') | ||
logger.setBindings({ [enable]: 50 }) | ||
logger.info('Will NOT appear immedialty') | ||
logger.info('Will NOT appear immedialty') | ||
logger.error('Will appear immedialty as well as the 2 previous messages') // error log are level 50 | ||
logger.info('Will NOT appear') | ||
logger.info({ [enable]: false }, 'Will appear immedialty') | ||
logger.info('Will NOT appear') | ||
``` | ||
<a id="pino-airbrake-transport"></a> | ||
### pino-airbrake-transport | ||
[pino-airbrake-transport][pino-airbrake-transport] is a Pino v7+ compatible transport to forward log events to [Airbrake][Airbrake] | ||
from a dedicated worker: | ||
```js | ||
const pino = require('pino') | ||
const transport = pino.transport({ | ||
target: 'pino-airbrake-transport', | ||
options: { | ||
airbrake: { | ||
projectId: 1, | ||
projectKey: "REPLACE_ME", | ||
environment: "production", | ||
// additional options for airbrake | ||
performanceStats: false, | ||
}, | ||
}, | ||
level: "error", // minimum log level that should be sent to airbrake | ||
}) | ||
pino(transport) | ||
``` | ||
[pino-airbrake-transport]: https://github.com/enricodeleo/pino-airbrake-transport | ||
[Airbrake]: https://airbrake.io/ | ||
<a id="pino-applicationinsights"></a> | ||
@@ -479,2 +573,20 @@ ### pino-applicationinsights | ||
<a id="pino-axiom"></a> | ||
### pino-axiom | ||
[pino-axiom](https://www.npmjs.com/package/pino-axiom) is a transport that will forward logs to [Axiom](https://axiom.co). | ||
```javascript | ||
const pino = require('pino') | ||
const transport = pino.transport({ | ||
target: 'pino-axiom', | ||
options: { | ||
orgId: 'YOUR-ORG-ID', | ||
token: 'YOUR-TOKEN', | ||
dataset: 'YOUR-DATASET', | ||
}, | ||
}) | ||
pino(transport) | ||
``` | ||
<a id="pino-azuretable"></a> | ||
@@ -528,2 +640,83 @@ ### pino-azuretable | ||
<a id="pino-datadog-transport"></a> | ||
### pino-datadog-transport | ||
[pino-datadog-transport][pino-datadog-transport] is a Pino v7+ compatible transport to forward log events to [Datadog][Datadog] | ||
from a dedicated worker: | ||
```js | ||
const pino = require('pino') | ||
const transport = pino.transport({ | ||
target: 'pino-datadog-transport', | ||
options: { | ||
ddClientConf: { | ||
authMethods: { | ||
apiKeyAuth: <your datadog API key> | ||
} | ||
}, | ||
}, | ||
level: "error", // minimum log level that should be sent to datadog | ||
}) | ||
pino(transport) | ||
``` | ||
[pino-datadog-transport]: https://github.com/theogravity/pino-datadog-transport | ||
[Datadog]: https://www.datadoghq.com/ | ||
#### Logstash | ||
The [pino-socket][pino-socket] module can also be used to upload logs to | ||
[Logstash][logstash] via: | ||
``` | ||
$ node app.js | pino-socket -a 127.0.0.1 -p 5000 -m tcp | ||
``` | ||
Assuming logstash is running on the same host and configured as | ||
follows: | ||
``` | ||
input { | ||
tcp { | ||
port => 5000 | ||
} | ||
} | ||
filter { | ||
json { | ||
source => "message" | ||
} | ||
} | ||
output { | ||
elasticsearch { | ||
hosts => "127.0.0.1:9200" | ||
} | ||
} | ||
``` | ||
See <https://www.elastic.co/guide/en/kibana/current/setup.html> to learn | ||
how to setup [Kibana][kibana]. | ||
For Docker users, see | ||
https://github.com/deviantony/docker-elk to setup an ELK stack. | ||
<a id="pino-discord-webhook"></a> | ||
### pino-discord-webhook | ||
[pino-discord-webhook](https://github.com/fabulousgk/pino-discord-webhook) is a Pino v7+ compatible transport to forward log events to a [Discord](http://discord.com) webhook from a dedicated worker. | ||
```js | ||
import pino from 'pino' | ||
const logger = pino({ | ||
transport: { | ||
target: 'pino-discord-webhook', | ||
options: { | ||
webhookUrl: 'https://discord.com/api/webhooks/xxxx/xxxx', | ||
} | ||
} | ||
}) | ||
``` | ||
<a id="pino-elasticsearch"></a> | ||
@@ -579,2 +772,27 @@ ### pino-elasticsearch | ||
<a id="pino-hana"></a> | ||
### pino-hana | ||
[pino-hana](https://github.com/HiImGiovi/pino-hana) is a Pino v7+ transport that save pino logs to a SAP HANA database. | ||
```js | ||
const pino = require('pino') | ||
const logger = pino({ | ||
transport: { | ||
target: 'pino-hana', | ||
options: { | ||
connectionOptions: { | ||
host: <hana db host>, | ||
port: <hana db port>, | ||
user: <hana db user>, | ||
password: <hana db password>, | ||
}, | ||
schema: <schema of the table in which you want to save the logs>, | ||
table: <table in which you want to save the logs>, | ||
}, | ||
}, | ||
}) | ||
logger.info('hi') // this log will be saved into SAP HANA | ||
``` | ||
For more detailed information about its usage please check the official [documentation](https://github.com/HiImGiovi/pino-hana#readme). | ||
<a id="pino-http-send"></a> | ||
@@ -619,2 +837,39 @@ ### pino-http-send | ||
<a id="pino-logfmt"></a> | ||
### pino-logfmt | ||
[pino-logfmt](https://github.com/botflux/pino-logfmt) is a Pino v7+ transport that formats logs into [logfmt](https://brandur.org/logfmt). This transport can output the formatted logs to stdout or file. | ||
```js | ||
import pino from 'pino' | ||
const logger = pino({ | ||
transport: { | ||
target: 'pino-logfmt' | ||
} | ||
}) | ||
``` | ||
<a id="pino-loki"></a> | ||
### pino-loki | ||
pino-loki is a transport that will forwards logs into [Grafana Loki](https://grafana.com/oss/loki/). | ||
Can be used in CLI version in a separate process or in a dedicated worker: | ||
CLI : | ||
```console | ||
node app.js | pino-loki --hostname localhost:3100 --labels='{ "application": "my-application"}' --user my-username --password my-password | ||
``` | ||
Worker : | ||
```js | ||
const pino = require('pino') | ||
const transport = pino.transport({ | ||
target: 'pino-loki', | ||
options: { host: 'localhost:3100' } | ||
}) | ||
pino(transport) | ||
``` | ||
For full documentation and configuration, see the [README](https://github.com/Julien-R44/pino-loki). | ||
<a id="pino-mq"></a> | ||
@@ -648,23 +903,43 @@ ### pino-mq | ||
<a id="pino-loki"></a> | ||
### pino-loki | ||
pino-loki is a transport that will forwards logs into [Grafana Loki](https://grafana.com/oss/loki/). | ||
Can be used in CLI version in a separate process or in a dedicated worker: | ||
<a id="pino-mysql"></a> | ||
### pino-mysql | ||
CLI : | ||
```console | ||
node app.js | pino-loki --hostname localhost:3100 --labels='{ "application": "my-application"}' --user my-username --password my-password | ||
[pino-mysql][pino-mysql] loads pino logs into [MySQL][MySQL] and [MariaDB][MariaDB]. | ||
```sh | ||
$ node app.js | pino-mysql -c db-configuration.json | ||
``` | ||
Worker : | ||
```js | ||
`pino-mysql` can extract and save log fields into corresponding database fields | ||
and/or save the entire log stream as a [JSON Data Type][JSONDT]. | ||
For full documentation and command line switches read the [README][pino-mysql]. | ||
[pino-mysql]: https://www.npmjs.com/package/pino-mysql | ||
[MySQL]: https://www.mysql.com/ | ||
[MariaDB]: https://mariadb.org/ | ||
[JSONDT]: https://dev.mysql.com/doc/refman/8.0/en/json.html | ||
<a id="pino-opentelemetry-transport"></a> | ||
### pino-opentelemetry-transport | ||
[pino-opentelemetry-transport](https://www.npmjs.com/package/pino-opentelemetry-transport) is a transport that will forward logs to an [OpenTelemetry log collector](https://opentelemetry.io/docs/collector/) using [OpenTelemetry JS instrumentation](https://opentelemetry.io/docs/instrumentation/js/). | ||
```javascript | ||
const pino = require('pino') | ||
const transport = pino.transport({ | ||
target: 'pino-loki', | ||
options: { host: 'localhost:3100' } | ||
target: 'pino-opentelemetry-transport', | ||
options: { | ||
resourceAttributes: { | ||
'service.name': 'test-service', | ||
'service.version': '1.0.0' | ||
} | ||
} | ||
}) | ||
pino(transport) | ||
``` | ||
For full documentation and configuration, see the [README](https://github.com/Julien-R44/pino-loki). | ||
Documentation on running a minimal example is available in the [README](https://github.com/Vunovati/pino-opentelemetry-transport#minimalistic-example). | ||
@@ -690,21 +965,2 @@ <a id="pino-papertrail"></a> | ||
<a id="pino-mysql"></a> | ||
### pino-mysql | ||
[pino-mysql][pino-mysql] loads pino logs into [MySQL][MySQL] and [MariaDB][MariaDB]. | ||
```sh | ||
$ node app.js | pino-mysql -c db-configuration.json | ||
``` | ||
`pino-mysql` can extract and save log fields into corresponding database fields | ||
and/or save the entire log stream as a [JSON Data Type][JSONDT]. | ||
For full documentation and command line switches read the [README][pino-mysql]. | ||
[pino-mysql]: https://www.npmjs.com/package/pino-mysql | ||
[MySQL]: https://www.mysql.com/ | ||
[MariaDB]: https://mariadb.org/ | ||
[JSONDT]: https://dev.mysql.com/doc/refman/8.0/en/json.html | ||
<a id="pino-redis"></a> | ||
@@ -736,3 +992,24 @@ ### pino-redis | ||
<a id="pino-sentry-transport"></a> | ||
### pino-sentry-transport | ||
[pino-sentry-transport][pino-sentry-transport] is a Pino v7+ compatible transport to forward log events to [Sentry][Sentry] | ||
from a dedicated worker: | ||
```js | ||
const pino = require('pino') | ||
const transport = pino.transport({ | ||
target: 'pino-sentry-transport', | ||
options: { | ||
sentry: { | ||
dsn: 'https://******@sentry.io/12345', | ||
} | ||
} | ||
}) | ||
pino(transport) | ||
``` | ||
[pino-sentry-transport]: https://github.com/tomer-yechiel/pino-sentry-transport | ||
[Sentry]: https://sentry.io/ | ||
<a id="pino-seq"></a> | ||
@@ -768,6 +1045,6 @@ ### pino-seq | ||
<a id="pino-sentry-transport"></a> | ||
### pino-sentry-transport | ||
<a id="pino-slack-webhook"></a> | ||
### pino-slack-webhook | ||
[pino-sentry-transport][pino-sentry-transport] is a Pino v7+ compatible transport to forward log events to [Sentry][Sentry] | ||
[pino-slack-webhook][pino-slack-webhook] is a Pino v7+ compatible transport to forward log events to [Slack][Slack] | ||
from a dedicated worker: | ||
@@ -778,7 +1055,8 @@ | ||
const transport = pino.transport({ | ||
target: 'pino-sentry-transport', | ||
target: '@youngkiu/pino-slack-webhook', | ||
options: { | ||
sentry: { | ||
dsn: 'https://******@sentry.io/12345', | ||
} | ||
webhookUrl: 'https://hooks.slack.com/services/xxx/xxx/xxx', | ||
channel: '#pino-log', | ||
username: 'webhookbot', | ||
icon_emoji: ':ghost:' | ||
} | ||
@@ -789,33 +1067,9 @@ }) | ||
[pino-sentry-transport]: https://github.com/tomer-yechiel/pino-sentry-transport | ||
[Sentry]: https://sentry.io/ | ||
[pino-slack-webhook]: https://github.com/youngkiu/pino-slack-webhook | ||
[Slack]: https://slack.com/ | ||
[pino-pretty]: https://github.com/pinojs/pino-pretty | ||
<a id="pino-airbrake-transport"></a> | ||
### pino-airbrake-transport | ||
For full documentation of command line switches read the [README](https://github.com/abeai/pino-websocket#readme). | ||
[pino-airbrake-transport][pino-airbrake-transport] is a Pino v7+ compatible transport to forward log events to [Airbrake][Airbrake] | ||
from a dedicated worker: | ||
```js | ||
const pino = require('pino') | ||
const transport = pino.transport({ | ||
target: 'pino-airbrake-transport', | ||
options: { | ||
airbrake: { | ||
projectId: 1, | ||
projectKey: "REPLACE_ME", | ||
environment: "production", | ||
// additional options for airbrake | ||
performanceStats: false, | ||
}, | ||
}, | ||
level: "error", // minimum log level that should be sent to airbrake | ||
}) | ||
pino(transport) | ||
``` | ||
[pino-airbrake-transport]: https://github.com/enricodeleo/pino-airbrake-transport | ||
[Airbrake]: https://airbrake.io/ | ||
<a id="pino-socket"></a> | ||
@@ -843,65 +1097,2 @@ ### pino-socket | ||
<a id="pino-datadog-transport"></a> | ||
### pino-datadog-transport | ||
[pino-datadog-transport][pino-datadog-transport] is a Pino v7+ compatible transport to forward log events to [Datadog][Datadog] | ||
from a dedicated worker: | ||
```js | ||
const pino = require('pino') | ||
const transport = pino.transport({ | ||
target: 'pino-datadog-transport', | ||
options: { | ||
ddClientConf: { | ||
authMethods: { | ||
apiKeyAuth: <your datadog API key> | ||
} | ||
}, | ||
}, | ||
level: "error", // minimum log level that should be sent to datadog | ||
}) | ||
pino(transport) | ||
``` | ||
[pino-datadog-transport]: https://github.com/theogravity/pino-datadog-transport | ||
[Datadog]: https://www.datadoghq.com/ | ||
#### Logstash | ||
The [pino-socket][pino-socket] module can also be used to upload logs to | ||
[Logstash][logstash] via: | ||
``` | ||
$ node app.js | pino-socket -a 127.0.0.1 -p 5000 -m tcp | ||
``` | ||
Assuming logstash is running on the same host and configured as | ||
follows: | ||
``` | ||
input { | ||
tcp { | ||
port => 5000 | ||
} | ||
} | ||
filter { | ||
json { | ||
source => "message" | ||
} | ||
} | ||
output { | ||
elasticsearch { | ||
hosts => "127.0.0.1:9200" | ||
} | ||
} | ||
``` | ||
See <https://www.elastic.co/guide/en/kibana/current/setup.html> to learn | ||
how to setup [Kibana][kibana]. | ||
For Docker users, see | ||
https://github.com/deviantony/docker-elk to setup an ELK stack. | ||
<a id="pino-stackdriver"></a> | ||
@@ -942,143 +1133,2 @@ ### pino-stackdriver | ||
<a id="pino-websocket"></a> | ||
### pino-websocket | ||
[pino-websocket](https://www.npmjs.com/package/@abeai/pino-websocket) is a transport that will forward each log line to a websocket server. | ||
```sh | ||
$ node app.js | pino-websocket -a my-websocket-server.example.com -p 3004 | ||
``` | ||
For full documentation of command line switches read the [README](https://github.com/abeai/pino-websocket#readme). | ||
<a id="pino-slack-webhook"></a> | ||
### pino-slack-webhook | ||
[pino-slack-webhook][pino-slack-webhook] is a Pino v7+ compatible transport to forward log events to [Slack][Slack] | ||
from a dedicated worker: | ||
```js | ||
const pino = require('pino') | ||
const transport = pino.transport({ | ||
target: '@youngkiu/pino-slack-webhook', | ||
options: { | ||
webhookUrl: 'https://hooks.slack.com/services/xxx/xxx/xxx', | ||
channel: '#pino-log', | ||
username: 'webhookbot', | ||
icon_emoji: ':ghost:' | ||
} | ||
}) | ||
pino(transport) | ||
``` | ||
[pino-slack-webhook]: https://github.com/youngkiu/pino-slack-webhook | ||
[Slack]: https://slack.com/ | ||
[pino-pretty]: https://github.com/pinojs/pino-pretty | ||
For full documentation of command line switches read the [README](https://github.com/abeai/pino-websocket#readme). | ||
<a id="pino-axiom"></a> | ||
### pino-axiom | ||
[pino-axiom](https://www.npmjs.com/package/pino-axiom) is a transport that will forward logs to [Axiom](https://axiom.co). | ||
```javascript | ||
const pino = require('pino') | ||
const transport = pino.transport({ | ||
target: 'pino-axiom', | ||
options: { | ||
orgId: 'YOUR-ORG-ID', | ||
token: 'YOUR-TOKEN', | ||
dataset: 'YOUR-DATASET', | ||
}, | ||
}) | ||
pino(transport) | ||
``` | ||
<a id="pino-opentelemetry-transport"></a> | ||
### pino-opentelemetry-transport | ||
[pino-opentelemetry-transport](https://www.npmjs.com/package/pino-opentelemetry-transport) is a transport that will forward logs to an [OpenTelemetry log collector](https://opentelemetry.io/docs/collector/) using [OpenTelemetry JS instrumentation](https://opentelemetry.io/docs/instrumentation/js/). | ||
```javascript | ||
const pino = require('pino') | ||
const transport = pino.transport({ | ||
target: 'pino-opentelemetry-transport', | ||
options: { | ||
resourceAttributes: { | ||
'service.name': 'test-service', | ||
'service.version': '1.0.0' | ||
} | ||
} | ||
}) | ||
pino(transport) | ||
``` | ||
Documentation on running a minimal example is available in the [README](https://github.com/Vunovati/pino-opentelemetry-transport#minimalistic-example). | ||
<a id="@axiomhq/pino"></a> | ||
### @axiomhq/pino | ||
[@axiomhq/pino](https://www.npmjs.com/package/@axiomhq/pino) is the official [Axiom](https://axiom.co/) transport for Pino, using [axiom-js](https://github.com/axiomhq/axiom-js). | ||
```javascript | ||
import pino from 'pino'; | ||
const logger = pino( | ||
{ level: 'info' }, | ||
pino.transport({ | ||
target: '@axiomhq/pino', | ||
options: { | ||
dataset: process.env.AXIOM_DATASET, | ||
token: process.env.AXIOM_TOKEN, | ||
}, | ||
}), | ||
); | ||
``` | ||
then you can use the logger as usual: | ||
```js | ||
logger.info('Hello from pino!'); | ||
``` | ||
For further examples, head over to the [examples](https://github.com/axiomhq/axiom-js/tree/main/examples/pino) directory. | ||
<a id="pino-discord-webhook"></a> | ||
### pino-discord-webhook | ||
[pino-discord-webhook](https://github.com/fabulousgk/pino-discord-webhook) is a Pino v7+ compatible transport to forward log events to a [Discord](http://discord.com) webhook from a dedicated worker. | ||
```js | ||
import pino from 'pino' | ||
const logger = pino({ | ||
transport: { | ||
target: 'pino-discord-webhook', | ||
options: { | ||
webhookUrl: 'https://discord.com/api/webhooks/xxxx/xxxx', | ||
} | ||
} | ||
}) | ||
``` | ||
<a id="pino-logfmt"></a> | ||
### pino-logfmt | ||
[pino-logfmt](https://github.com/botflux/pino-logfmt) is a Pino v7+ transport that formats logs into [logfmt](https://brandur.org/logfmt). This transport can output the formatted logs to stdout or file. | ||
```js | ||
import pino from 'pino' | ||
const logger = pino({ | ||
transport: { | ||
target: 'pino-logfmt' | ||
} | ||
}) | ||
``` | ||
<a id="pino-telegram-webhook"></a> | ||
@@ -1111,2 +1161,40 @@ ### pino-telegram-webhook | ||
<a id="pino-websocket"></a> | ||
### pino-websocket | ||
[pino-websocket](https://www.npmjs.com/package/@abeai/pino-websocket) is a transport that will forward each log line to a websocket server. | ||
```sh | ||
$ node app.js | pino-websocket -a my-websocket-server.example.com -p 3004 | ||
``` | ||
For full documentation of command line switches read the [README](https://github.com/abeai/pino-websocket#readme). | ||
<a id="pino-yc-transport"></a> | ||
### pino-yc-transport | ||
[pino-yc-transport](https://github.com/Jhon-Mosk/pino-yc-transport) is a Pino v7+ transport for writing to [Yandex Cloud Logging](https://yandex.cloud/ru/services/logging) from serveless functions or containers. | ||
```js | ||
const pino = require("pino"); | ||
const config = { | ||
level: "debug", | ||
transport: { | ||
target: "pino-yc-transport", | ||
}, | ||
}; | ||
const logger = pino(config); | ||
logger.debug("some message") | ||
logger.debug({ foo: "bar" }); | ||
logger.debug("some message %o, %s", { foo: "bar" }, "baz"); | ||
logger.info("info"); | ||
logger.warn("warn"); | ||
logger.error("error"); | ||
logger.error(new Error("error")); | ||
logger.fatal("fatal"); | ||
``` | ||
<a id="communication-between-pino-and-transport"></a> | ||
@@ -1113,0 +1201,0 @@ ## Communication between Pino and Transports |
'use strict' | ||
module.exports = { version: '9.4.0' } | ||
module.exports = { version: '9.5.0' } |
@@ -20,7 +20,8 @@ 'use strict' | ||
function buildStream (filename, workerData, workerOpts) { | ||
function buildStream (filename, workerData, workerOpts, sync) { | ||
const stream = new ThreadStream({ | ||
filename, | ||
workerData, | ||
workerOpts | ||
workerOpts, | ||
sync | ||
}) | ||
@@ -75,3 +76,3 @@ | ||
function transport (fullOptions) { | ||
const { pipeline, targets, levels, dedupe, worker = {}, caller = getCallers() } = fullOptions | ||
const { pipeline, targets, levels, dedupe, worker = {}, caller = getCallers(), sync = false } = fullOptions | ||
@@ -131,3 +132,3 @@ const options = { | ||
return buildStream(fixTarget(target), options, worker) | ||
return buildStream(fixTarget(target), options, worker, sync) | ||
@@ -134,0 +135,0 @@ function fixTarget (origin) { |
{ | ||
"name": "pino", | ||
"version": "9.4.0", | ||
"version": "9.5.0", | ||
"description": "super fast, all natural json logger", | ||
@@ -66,3 +66,3 @@ "main": "pino.js", | ||
"@types/tap": "^15.0.6", | ||
"@yao-pkg/pkg": "5.12.1", | ||
"@yao-pkg/pkg": "5.15.0", | ||
"airtap": "4.0.4", | ||
@@ -109,3 +109,3 @@ "benchmark": "^2.1.4", | ||
"on-exit-leak-free": "^2.1.0", | ||
"pino-abstract-transport": "^1.2.0", | ||
"pino-abstract-transport": "^2.0.0", | ||
"pino-std-serializers": "^7.0.0", | ||
@@ -112,0 +112,0 @@ "process-warning": "^4.0.0", |
@@ -370,1 +370,49 @@ 'use strict' | ||
}) | ||
test('silent level prevents logging even with transmit', ({ end, fail }) => { | ||
const logger = pino({ | ||
level: 'silent', | ||
browser: { | ||
write () { | ||
fail('no data should be logged by the write method') | ||
}, | ||
transmit: { | ||
send () { | ||
fail('no data should be logged by the send method') | ||
} | ||
} | ||
} | ||
}) | ||
Object.keys(pino.levels.values).forEach((level) => { | ||
logger[level]('ignored') | ||
}) | ||
end() | ||
}) | ||
test('does not call send when transmit.level is set to silent', ({ end, fail, is }) => { | ||
let c = 0 | ||
const logger = pino({ | ||
level: 'trace', | ||
browser: { | ||
write () { | ||
c++ | ||
}, | ||
transmit: { | ||
level: 'silent', | ||
send () { | ||
fail('no data should be logged by the transmit method') | ||
} | ||
} | ||
} | ||
}) | ||
const levels = Object.keys(pino.levels.values) | ||
levels.forEach((level) => { | ||
logger[level]('message') | ||
}) | ||
is(c, levels.length, 'write must be called exactly once per level') | ||
end() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
742615
199
14847
22
+ Addedpino-abstract-transport@2.0.0(transitive)
- Removedabort-controller@3.0.0(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbuffer@6.0.3(transitive)
- Removedevent-target-shim@5.0.1(transitive)
- Removedevents@3.3.0(transitive)
- Removedieee754@1.2.1(transitive)
- Removedpino-abstract-transport@1.2.0(transitive)
- Removedprocess@0.11.10(transitive)
- Removedreadable-stream@4.5.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedstring_decoder@1.3.0(transitive)