Giter VIP home page Giter VIP logo

pino-logdna's Introduction

pino-logdna

All Contributors

Transport pino logs to LogDNA

Install

npm install --save pino-logdna

Usage

Pino v7+ Transport

This module can be used as a pino transport:

const pino = require('pino')
const transport = pino.transport({
  target: 'pino-logdna',
  options: {
    key // your LogDNA ingestion key
  }
})

const log = pino(transport)

// Logs will now go to LogDNA
log.info('Happy Logging!')

Options

This transport uses @logdna/logger under the hood, and most options are exposed through pino-logdna.

For a full list, please see the createLogger options.

An additional option is supported by pino-logdna:

  • emptyMessage <String> - When logging an object without a message, e.g. log.info({ some: 'data' }), the value of this option will be used for the outgoing message. Default: '<data log>'.

Legacy Transport

Usage as a legacy transport is still supported. The minimal configuration requires only your LogDNA ingestion key:

npm install -g pino-logdna
node ./app.js | pino-logdna --key="YOUR INGESTION KEY"

CLI Options can be supplied to the command:

node ./app.js | pino-logdna --key "YOUR INGESTION KEY" --env staging --tag foo --tag bar

CLI Options

Options for the CLI are the kebab-case equivalent of the @logdna/logger options:

Options:
  -v, --version                   Show version
  -h, --help                      Show usage information
  -m, --message-key [msg]         The field in the `pino` used as the display line in LogDNA
  -e, --empty-message [msg]       String value to use when no "message" property if found

@logdna/logger Options:
      --key                       *REQUIRED* Your ingestion key
  -t, --tag                       Tag to be added to each message; can be supplied multiple times
  -T, --timeout [30000]           Millisecond timeout for each HTTP request
      --app [default]             Arbitrary app name for labeling each message
  -E, --env                       An environment label attached to each message
  -H, --hostname                  Hostname for each HTTP request
      --mac                       MAC address for each HTTP request
      --ip                        IPv4 or IPv6 address for each HTTP request
      --url                       URL of the logging server
      --flush-limit [5000000]     Maximum total line lengths before a flush is forced
      --flush-interval-ms [250]   Mseconds to wait before sending the buffer
      --base-backoff-ms [3000]    Minimum exponential backoff time in milliseconds
      --max-backoff-ms [30000]    Maximum exponential backoff time in milliseconds
      --index-meta [false]        Controls whether meta data for each message is searchable
  -p, --proxy                     The full URL of an http or https proxy to pass through

Contributing

This project is open-sourced, and accepts PRs from the public for bugs or feature enhancements. Please see CONTRIBUTING.md for more information.

Commit Format

The project uses Commitlint and enforces Conventional Commit Standard. Please format your commits based on these guidelines.

An issue must be opened in the repository for any bug, feature, or anything else that will have a PR.

The commit message must reference the issue with an acceptable action tag in the commit footer, e.g. Fixes: #5.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Maciej Ziehlke


Mike Del Tito

💻 📖 💡 🔧

James Sumners

💻 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

License

Copyright © LogDNA, released under an MIT license. See the LICENSE file and https://opensource.org/licenses/MIT

Happy Logging!

pino-logdna's People

Contributors

mdeltito avatar logdnabot avatar jsumners avatar snyk-bot avatar

Stargazers

Carsten Meyer avatar  avatar  avatar Petr Reichl avatar Chirill Ceban avatar Lucas Lopes avatar Wilhelm R. avatar

Watchers

 avatar James Cloos avatar Kevin Chan avatar  avatar

pino-logdna's Issues

onError option does not work

When adding onError option to transporter, I get the following error:

DOMException [DataCloneError]: event => {
  // eslint-disable-next-line no-console
  console.error('LogDNA Error', event);
} could not be cloned.
    at new Worker (internal/worker.js:239:17)
    at createWorker (/Users/andreilisnic/Work/planable-app/node_modules/thread-stream/index.js:50:18)
    at new ThreadStream (/Users/andreilisnic/Work/planable-app/node_modules/thread-stream/index.js:209:19)
    at buildStream (/Users/andreilisnic/Work/planable-app/node_modules/pino/lib/transport.js:40:18)
    at transport (/Users/andreilisnic/Work/planable-app/node_modules/pino/lib/transport.js:124:10)
    at normalizeArgs (/Users/andreilisnic/Work/planable-app/node_modules/pino/lib/tools.js:419:16)
    at pino (/Users/andreilisnic/Work/planable-app/node_modules/pino/pino.js:86:28)

I'm initializing the logger like this:

{
  target: 'pino-logdna',
  level,
  options: {
    key: logdnaKey,
    app: Meteor.settings.public.appName,
    env: process.env.NODE_ENV,
    indexMeta: true,
    onError: onLogDNAError,
    hostname
  }
}

If a test is adjusted to pass this option, the test suite freezes:

diff --git a/test/stream.js b/test/stream.js
index c7e9c11..98d6b98 100644
--- a/test/stream.js
+++ b/test/stream.js
@@ -70,6 +70,7 @@ test('pinoLogdna', async (t) => {
     , tags: 'foo,bar'
     , indexMeta: true
     , messageKey: 'message'
+    , onError: (event)=> { console.log(event) }
     }

Add commitlint tooling

In order to assist with the proper format, we should include the (new) standard commitlint config and apply it to pretest

Pino @7

Pino 7 has made some changes to transports. Any chance this library gets an update?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.