Socket
Socket
Sign inDemoInstall

@elastic/ecs-pino-format

Package Overview
Dependencies
10
Maintainers
75
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.0 to 0.2.0

11

CHANGELOG.md

@@ -1,4 +0,13 @@

# Changelog
# @elastic/ecs-pino-format Changelog
## v0.2.0
- Serialize "log.level" as a top-level dotted field per
https://github.com/elastic/ecs-logging/pull/33 and
set ["log.logger"](https://www.elastic.co/guide/en/ecs/current/ecs-log.html#field-log-logger)
to the logger ["name"](https://getpino.io/#/docs/api?id=name-string) if given.
([#23](https://github.com/elastic/ecs-logging-js/pull/23))
## v0.1.0
Initial release.

35

index.js

@@ -17,19 +17,36 @@ // Licensed to Elasticsearch B.V under one or more agreements.

level (label, number) {
return {
log: {
level: label,
logger: 'pino'
}
}
return { 'log.level': label }
},
// Add the following ECS fields:
// - https://www.elastic.co/guide/en/ecs/current/ecs-process.html#field-process-pid
// - https://www.elastic.co/guide/en/ecs/current/ecs-host.html#field-host-hostname
// - https://www.elastic.co/guide/en/ecs/current/ecs-log.html#field-log-logger
//
// This is called once at logger creation, and for each child logger creation.
bindings (bindings) {
return {
const {
// We assume the default `pid` and `hostname` bindings
// (https://getpino.io/#/docs/api?id=bindings) will be always be
// defined because currently one cannot use this package *and*
// pass a custom `formatters` to a pino logger.
pid,
hostname,
// name is defined if `log = pino({name: 'my name', ...})`
name
} = bindings
const ecsBindings = {
process: {
pid: bindings.pid
pid: pid
},
host: {
hostname: bindings.hostname
hostname: hostname
}
}
if (name !== undefined) {
ecsBindings.log = { logger: name }
}
return ecsBindings
},

@@ -36,0 +53,0 @@

{
"name": "@elastic/ecs-pino-format",
"version": "0.1.0",
"version": "0.2.0",
"description": "A formatter for the pino logger compatible with Elastic Common Schema.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -27,3 +27,3 @@ // Licensed to Elasticsearch B.V under one or more agreements.

const stream = split(JSON.parse).on('data', line => {
t.deepEqual(line.log, { level: 'info', logger: 'pino' })
t.deepEqual(line['log.level'], 'info')
t.true(validate(line))

@@ -36,2 +36,14 @@ })

test('Should map "name" to "log.logger"', t => {
t.plan(2)
const stream = split(JSON.parse).on('data', line => {
t.deepEqual(line.log, { logger: 'myName' })
t.true(validate(line))
})
const pino = Pino({ name: 'myName', ...ecsFormat() }, stream)
pino.info('Hello world')
})
test('Should append any additional property to the log message', t => {

@@ -38,0 +50,0 @@ t.plan(2)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc