@elastic/ecs-pino-format
Advanced tools
Comparing version 1.4.0 to 1.5.0
@@ -51,4 +51,5 @@ import type { LoggerOptions } from "pino"; | ||
declare function createEcsPinoOptions(config?: Config): LoggerOptions; | ||
declare function ecsFormat(config?: Config): LoggerOptions; | ||
export = createEcsPinoOptions; | ||
export default ecsFormat; | ||
export { ecsFormat } |
20
index.js
@@ -35,3 +35,3 @@ // Licensed to Elasticsearch B.V. under one or more contributor | ||
*/ | ||
function createEcsPinoOptions (opts) { | ||
function ecsFormat (opts) { | ||
// istanbul ignore next | ||
@@ -77,4 +77,4 @@ opts = opts || {} | ||
let serviceVersion = opts.serviceVersion | ||
// istanbul ignore next | ||
if (serviceVersion == null && apm) { | ||
// istanbul ignore next | ||
serviceVersion = (apm.getServiceVersion | ||
@@ -216,2 +216,16 @@ ? apm.getServiceVersion() // added in elastic-apm-node@... | ||
module.exports = createEcsPinoOptions | ||
// Exports to support the following import-styles from JS and TS code: | ||
// 1. `const { ecsFormat } = require('@elastic/ecs-pino-format)` in JS and TS. | ||
// The preferred import style for JS code using CommonJS. | ||
// 2. `import { ecsFormat } from '@elastic/ecs-pino-format'` in JS and TS. | ||
// ES module (ESM) import style. This is the preferred style for TypeScript | ||
// code and for JS developers using ESM. | ||
// 3. `const ecsFormat = require('@elastic/ecs-pino-format')` in JS. | ||
// The old, deprecated import method. Still supported for backward compat. | ||
// 4. `import ecsFormat from '@elastic/ecs-pino-format'` in JS and TS. | ||
// This works, but is deprecated. Prefer #2 style. | ||
// 5. `import * as EcsPinoFormat from '@elastic/ecs-pino-format'` in TS. | ||
// One must then use `EcsPinoFormat.ecsFormat()`. | ||
module.exports = ecsFormat // Required to support style 3. | ||
module.exports.ecsFormat = ecsFormat | ||
module.exports.default = ecsFormat // Required to support style 4. |
{ | ||
"name": "@elastic/ecs-pino-format", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "A formatter for the pino logger compatible with Elastic Common Schema.", | ||
@@ -31,7 +31,9 @@ "main": "index.js", | ||
}, | ||
"homepage": "https://github.com/elastic/ecs-logging-nodejs/blob/main/loggers/pino/README.md", | ||
"homepage": "https://github.com/elastic/ecs-logging-nodejs/blob/main/packages/ecs-pino-format/README.md", | ||
"scripts": { | ||
"lint": "standard", | ||
"lint:fix": "standard --fix", | ||
"test": "tap --timeout ${TAP_TIMEOUT:-10} test/*.test.js" | ||
"test": "tap --timeout ${TAP_TIMEOUT:-30} test/*.test.js", | ||
"test:skip-slow": "TEST_SKIP_SLOW=1 tap --no-coverage --timeout ${TAP_TIMEOUT:-10} test/*.test.js # test a subset for a fast test run", | ||
"tav": "tav --quiet" | ||
}, | ||
@@ -42,3 +44,3 @@ "engines": { | ||
"dependencies": { | ||
"@elastic/ecs-helpers": "^1.1.0" | ||
"@elastic/ecs-helpers": "^2.1.1" | ||
}, | ||
@@ -51,8 +53,12 @@ "devDependencies": { | ||
"express": "^4.17.1", | ||
"glob": "^7.2.3", | ||
"pino": "^6.0.0", | ||
"pino-http": "^5.3.0", | ||
"semver": "^7.5.4", | ||
"split2": "^3.1.1", | ||
"standard": "16.x", | ||
"tap": "^15.0.10" | ||
"tap": "^15.0.10", | ||
"test-all-versions": "^5.0.1", | ||
"ts-node": "^10.9.1" | ||
} | ||
} |
@@ -5,6 +5,7 @@ <img align="right" width="auto" height="auto" src="https://www.elastic.co/static-res/images/elastic-logo-200.png"> | ||
[![Build Status](https://apm-ci.elastic.co/buildStatus/icon?job=apm-agent-nodejs%2Fecs-logging-nodejs-mbp%2Fmain)](https://apm-ci.elastic.co/job/apm-agent-nodejs/job/ecs-logging-nodejs-mbp/job/main/) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) | ||
[![npm](https://img.shields.io/npm/v/@elastic/ecs-pino-format.svg)](https://www.npmjs.com/package/@elastic/ecs-pino-format) | ||
[![test](https://github.com/elastic/ecs-logging-nodejs/actions/workflows/test.yml/badge.svg)](https://github.com/elastic/ecs-logging-nodejs/actions/workflows/test.yml) | ||
This Node.js package provides a formatter for the [pino](https://www.npmjs.com/package/pino) | ||
logger compatible with [Elastic Common Schema (ECS) logging](https://www.elastic.co/guide/en/ecs/current/index.html).<br/> | ||
This Node.js package provides a formatter for the [pino](https://getpino.io/) | ||
logger compatible with [Elastic Common Schema (ECS) logging](https://www.elastic.co/guide/en/ecs/current/index.html). | ||
In combination with the [filebeat](https://www.elastic.co/products/beats/filebeat) | ||
@@ -15,2 +16,4 @@ shipper, you can send your logs directly to Elasticsearch and leverage | ||
`pino` 6.x, 7.x, and 8.x versions are supported. | ||
Please see the [Node.js ECS pino documentation](https://www.elastic.co/guide/en/ecs-logging/nodejs/current/pino.html). | ||
@@ -30,3 +33,3 @@ | ||
```js | ||
const ecsFormat = require('@elastic/ecs-pino-format') | ||
const { ecsFormat } = require('@elastic/ecs-pino-format') | ||
const pino = require('pino') | ||
@@ -44,4 +47,4 @@ | ||
```sh | ||
{"log.level":"info","@timestamp":"2023-10-16T18:08:02.601Z","process.pid":74325,"host.hostname":"pink.local","ecs.version":"1.6.0","message":"Hello world"} | ||
{"log.level":"warn","@timestamp":"2023-10-16T18:08:02.602Z","process.pid":74325,"host.hostname":"pink.local","ecs.version":"1.6.0","module":"foo","message":"From child"} | ||
{"log.level":"info","@timestamp":"2023-10-16T18:08:02.601Z","process.pid":74325,"host.hostname":"pink.local","ecs.version":"8.10.0","message":"Hello world"} | ||
{"log.level":"warn","@timestamp":"2023-10-16T18:08:02.602Z","process.pid":74325,"host.hostname":"pink.local","ecs.version":"8.10.0","module":"foo","message":"From child"} | ||
``` | ||
@@ -48,0 +51,0 @@ |
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
24796
250
0
53
14
+ Added@elastic/ecs-helpers@2.1.1(transitive)
- Removed@elastic/ecs-helpers@1.1.0(transitive)
- Removedajv@6.12.6(transitive)
- Removeddeepmerge@4.3.1(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedfast-json-stringify@2.7.13(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedrfdc@1.3.1(transitive)
- Removedstring-similarity@4.0.4(transitive)
- Removeduri-js@4.4.1(transitive)
Updated@elastic/ecs-helpers@^2.1.1