Skip to content

Commit

Permalink
chore: some light README and comment updates (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
trentm authored Oct 26, 2023
1 parent 2a6be30 commit f71a0ab
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 23 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# ecs-logging-nodejs

[![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/)
[![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 set of libraries allows you to transform your application logs to structured logs that comply with the [Elastic Common Schema (ECS)](https://www.elastic.co/guide/en/ecs/current/ecs-reference.html).
In combination with [filebeat](https://www.elastic.co/products/beats/filebeat) you can send your logs directly to Elasticsearch and leverage [Kibana's Logs app](https://www.elastic.co/guide/en/observability/current/monitor-logs.html) to inspect all logs in one single place.
Expand All @@ -12,12 +12,15 @@ Please see the [Node.js ECS logging documentation](https://www.elastic.co/guide/

## Supported logging frameworks

- [Morgan](https://github.com/expressjs/morgan) via [@elastic/ecs-morgan-format](./packages/ecs-morgan-format)
([docs](https://www.elastic.co/guide/en/ecs-logging/nodejs/current/morgan.html))
- [Pino](https://getpino.io/#/) via [@elastic/ecs-pino-format](./packages/ecs-pino-format)
([docs](https://www.elastic.co/guide/en/ecs-logging/nodejs/current/pino.html))
- [Winston](https://github.com/winstonjs/winston) via [@elastic/ecs-winston-format](./packages/ecs-winston-format)
([docs](https://www.elastic.co/guide/en/ecs-logging/nodejs/current/winston.html))
- Pino via [@elastic/ecs-pino-format](./packages/ecs-pino-format)
([docs](https://www.elastic.co/guide/en/ecs-logging/nodejs/current/pino.html),
[changelog](./packages/ecs-pino-format/CHANGELOG.md))
- Winston via [@elastic/ecs-winston-format](./packages/ecs-winston-format)
([docs](https://www.elastic.co/guide/en/ecs-logging/nodejs/current/winston.html),
[changelog](./packages/ecs-winston-format/CHANGELOG.md))
- Morgan via [@elastic/ecs-morgan-format](./packages/ecs-morgan-format)
([docs](https://www.elastic.co/guide/en/ecs-logging/nodejs/current/morgan.html),
[changelog](./packages/ecs-morgan-format/CHANGELOG.md))

## Links

Expand Down
2 changes: 1 addition & 1 deletion docs/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ endif::[]

ifndef::env-github[]
include::./intro.asciidoc[Introduction]
include::./morgan.asciidoc[Logging with Morgan]
include::./pino.asciidoc[Logging with Pino]
include::./winston.asciidoc[Logging with Winston]
include::./morgan.asciidoc[Logging with Morgan]
endif::[]
2 changes: 1 addition & 1 deletion docs/intro.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ See the {ecs-logging-ref}/intro.html[ECS logging guide].

Ready to jump into Node.js ECS logging?

- <<morgan,ECS Logging with Morgan>>
- <<pino,ECS Logging with Pino>>
- <<winston,ECS Logging with Winston>>
- <<morgan,ECS Logging with Morgan>>

If you'd like to try out a tutorial using Node.js ECS logging with winston, see {cloud}/ec-getting-started-search-use-cases-node-logs.html[Ingest logs from a Node.js web application using Filebeat].
2 changes: 1 addition & 1 deletion packages/ecs-helpers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @elastic/ecs-helpers Changelog

## 2.0.0
## v2.0.0

- [Breaking change.] Drop the `serialize` method. Serialization will move to
the individual `@elastic/ecs-*-format` libraries -- and they will be
Expand Down
7 changes: 4 additions & 3 deletions packages/ecs-morgan-format/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

# @elastic/ecs-morgan-format

[![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-morgan-format.svg)](https://www.npmjs.com/package/@elastic/ecs-morgan-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
[morgan](https://www.npmjs.com/package/morgan) logging middleware compatible with
[Elastic Common Schema (ECS) logging](https://www.elastic.co/guide/en/ecs-logging/overview/master/intro.html).<br/>
[morgan](https://github.com/expressjs/morgan) logging middleware compatible with
[Elastic Common Schema (ECS) logging](https://www.elastic.co/guide/en/ecs-logging/overview/master/intro.html).
In combination with the [filebeat](https://www.elastic.co/products/beats/filebeat)
shipper, you can send your logs directly to Elasticsearch and leverage
[Kibana's Logs app](https://www.elastic.co/guide/en/observability/current/monitor-logs.html)
Expand Down
7 changes: 4 additions & 3 deletions packages/ecs-pino-format/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

# @elastic/ecs-pino-format

[![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)
shipper, you can send your logs directly to Elasticsearch and leverage
[Kibana's Logs app](https://www.elastic.co/guide/en/observability/current/monitor-logs.html)
Expand Down
7 changes: 4 additions & 3 deletions packages/ecs-winston-format/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

# @elastic/ecs-winston-format

[![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-winston-format.svg)](https://www.npmjs.com/package/@elastic/ecs-winston-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
[winston](https://www.npmjs.com/package/winston) logger compatible with
[Elastic Common Schema (ECS) logging](https://www.elastic.co/guide/en/ecs-logging/overview/master/intro.html).<br/>
[winston](https://github.com/winstonjs/winston) logger compatible with
[Elastic Common Schema (ECS) logging](https://www.elastic.co/guide/en/ecs-logging/overview/master/intro.html).
In combination with the [filebeat](https://www.elastic.co/products/beats/filebeat)
shipper, you can send your logs directly to Elasticsearch and leverage
[Kibana's Logs app](https://www.elastic.co/guide/en/observability/current/monitor-logs.html)
Expand Down
9 changes: 5 additions & 4 deletions packages/ecs-winston-format/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,17 @@ try {
// Silently ignore.
}

// There are some differences between Winston's `logform.format.json()` and this
// stringifier. They both use `safe-stable-stringify`. Winston's exposes its
// There are some differences between Winston's `logform.json()` and this
// stringifier. They both use `safe-stable-stringify`. Winston exposes its
// options but doesn't doc that at https://github.com/winstonjs/logform#json.
// 1. This one hardcodes `deterministic: false` so fields are serialized in the
// order added, which is helpful for ecs-logging's stated preference of
// having a few fields first:
// having a few specific fields first:
// https://www.elastic.co/guide/en/ecs-logging/overview/current/intro.html#_why_ecs_logging
// 2. Winston provides a `replacer` that converts bigints to strings. Doing
// that is debatable. The argument *for* is that a *JavaScript* JSON parser
// looses precision when parsing a bigint.
// looses precision when parsing a bigint. This stringifier does *not*
// do this same conversion.
// TODO: These differences should make it to docs somewhere.
const stringify = safeStableStringify.configure({ deterministic: false })

Expand Down

0 comments on commit f71a0ab

Please sign in to comment.