pinojs / pino-socket

🌲 A transport for sending pino logs to network sockets
43 stars 14 forks source link

CLI seems broken #58

Closed Guid75 closed 2 years ago

Guid75 commented 2 years ago

Since the 4.0.0 version, ./node_modules/.bin/pino-socket -h returns nothing

It's probably due to the following code fragment in psock.js

if (require.main === module) {
  // used as cli
  cli()
}

The if expression is always false because psock.js is never directly called from the CLI.

jsumners commented 2 years ago

Would you like to send a Pull Request to address this issue? Remember to add unit tests.

ggrossetie commented 2 years ago

I cannot reproduce this, I believe this is fixed?

npm init -y
npm i --save-dev pino-socket
$ npx pino-socket -h
  pino-socket

  To send pino logs via udp:

     cat log | pino-socket -a 192.168.1.42 -p 1234

  To send pino logs via tcp:

     cat log | pino-socket -m tcp -a 192.168.1.42 -p 1234

  Flags
  -h  | --help              Display Help
  -v  | --version                   display Version
  -s  | --settings                  read settings from a JSON file (switches take precedence)
  -a  | --address                   the address for the destination socket; default: 127.0.0.1
  -m  | --mode                      the protocol, either 'udp' or 'tcp'; default: 'udp'
  -p  | --port                      the port on the destination socket; default: '514'
  -u  | --unixsocket                the path of unix socket; default: ''
  -r  | --reconnect                 enable tcp mode reconnecting
  -t  | --reconnectTries            number of reconnect attempts to make; default: 'Inifinity'
  -ne | --no-echo                   disable echoing received messages to stdout
      | --recovery                  enable recovery mode
      | --recovery-queue-max-size   maximum size of items added to the recovery queue; default: 1024
$ ./node_modules/.bin/pino-socket -h
  pino-socket

  To send pino logs via udp:

     cat log | pino-socket -a 192.168.1.42 -p 1234

  To send pino logs via tcp:

     cat log | pino-socket -m tcp -a 192.168.1.42 -p 1234

  Flags
  -h  | --help              Display Help
  -v  | --version                   display Version
  -s  | --settings                  read settings from a JSON file (switches take precedence)
  -a  | --address                   the address for the destination socket; default: 127.0.0.1
  -m  | --mode                      the protocol, either 'udp' or 'tcp'; default: 'udp'
  -p  | --port                      the port on the destination socket; default: '514'
  -u  | --unixsocket                the path of unix socket; default: ''
  -r  | --reconnect                 enable tcp mode reconnecting
  -t  | --reconnectTries            number of reconnect attempts to make; default: 'Inifinity'
  -ne | --no-echo                   disable echoing received messages to stdout
      | --recovery                  enable recovery mode
      | --recovery-queue-max-size   maximum size of items added to the recovery queue; default: 1024