Giter Club home page Giter Club logo

pino-syslog's Introduction

pino.io project

Running Locally

git clone https://github.com/pinojs/pinojs
cd pinojs
npm install
npm start

pino-syslog's People

Contributors

cmwd avatar dancastillo avatar eleon-sqli avatar eomm avatar fdawgs avatar jsumners avatar loic-b avatar malaupa avatar mcollina avatar zol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pino-syslog's Issues

pino v7 pipelining is not work

Hi!

I made such a configuration as you described in the example:

import pino from 'pino'

const transport = pino.transport({
  pipeline: [
    {
      target: 'pino-syslog',
      level: 'info',
      options: {
        modern: false,
        appname: process.env.npm_package_name,
        enablePipelining: true,
      }
    },
    {
      target: 'pino-socket',
      options: {
        mode: 'tcp',
        address: '127.0.0.1',
        port: 8001
      }
    }
  ]
})

pino(transport)

But I don't get any logs.

I spent a lot of time debugging this issue. And here's what I found out:

Your plugin (pipo-syslog) does not transmit any data further down the pipeline. To be sure of this, I wrote my transport and replaced pino-socket:

const tls = require('tls')
const { pipeline, Writable } = require('stream')
const build = require('pino-abstract-transport')

module.exports = function createTransport(opts) {
  return build(
    function (source) {
      console.log('createTransport', opts) // Console-1

      source.on('error', console.error)
      source.on('close', () => console.info('source close'))

      source.on('data', function (data) {
        console.log('source data', data) // Console-2
        stream.write(JSON.stringify(data))
      })

      const socket = tls.connect(opts, () => {})

      socket.on('data', function (data) {
        console.info('socket data', data)
      })

      socket.on('error', console.error)
      socket.on('close', console.info)

      const stream = new Writable({
        open: true,
        autoDestroy: true,
        close() {
          socket.end()
        },
        write(data, encoding, callback) {
          console.log('tls.connect write', data.toString()) // Console-3
          socket.write(data)
          callback()
        },
      })

      return stream
    },
    {
      enablePipelining: true,
    }
  )
}

After starting the logger, I only see the message of Console-1. When I try to send data to the logger, nothing happens. I don't see a single message.

But if I comment out your plugin in the configuration, then I will receive all messages from the logger (without the transformations that your plugin does, since it is disabled).

You need to fix the data transfer to the next pipeline.

Hope you can help me solve this problem!

Add new line at the end of the log

Currently, transform doesn't add a newline to the end of the log. If it's something required by syslog spec can we add this feature by the flag?

If you agree I can prepare a PR with this feature.

Cheers,
Piotr

Erroneous date format in RFC3164

Hi,

In file lib/rfc3164.js", I see those lines:

const zeroReg = /0/
const tstamp = moment(data.time).tz(options.tz).format('MMM DD HH:mm:ss').replace(zeroReg, ' ')

On Wed Jan 30 13:49:34 CET 2019, the tsstamp will be equal to
"Jan 3 12:43:12" instead of expected
"Jan 30 12:43:12"

The problem is that it replaces any zero in the string while the expected behavior for RFC3164 is to replaced only the leading zero of the day!

So, I guess it will also fail for month equals october...

Support for npm/yarn scripts

This transform works only if an app is executed directly from the node. Because npm/yarn adds own non-json logs to the output it throws SyntaxError: Unexpected end of JSON input.

Maybe we could simply detect if the log comes from pino and if not just ignore it?

Thanks,
Piotr

Usage with promtail

I was unable to use pipelining to send syslog to a running promtail instance; I used the example from the README without any luck.

Did I miss something?

Thanks

Dynamic appname values

I'd like to format the APP-NAME field in the syslog message like this: ${appName}.${loggerName}. Right now the pino-syslog only supports static values as the appname. Does supporting dynamic values sound good?

Compatibility with Pino v8 as Pino Transport

Is the transport available with Pino v8?

I'm trying to use it wit Fastify as described in docs

const fastify = Fastify({
  disableRequestLogging: true,
  logger: {
    enabled: true,
    level: 'info',
    transport: {
      target: 'pino-syslog',
    },
  },
})

but unlike pino-pretty, there is no output.

According to pino docs this is a Legacy transport and should work at least with pipelines - but not for me.

Config file attributes are overriden by default config

The options described in an external configuration file (--config flag) are overriden by the default internal config values.
The final option object should be constructed just before the transport assignment block:

const options = Object.assign({}, defaults, jsonOptions, args);

I would like to create a PR but I can't push a branch on this repo.

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.