Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Winston formats screwing things up #107

Open
peebles opened this issue Aug 15, 2018 · 1 comment
Open

Winston formats screwing things up #107

peebles opened this issue Aug 15, 2018 · 1 comment

Comments

@peebles
Copy link

peebles commented Aug 15, 2018

The MESSAGE symbol in the info object seems to get messed up when using "formats".

"winston": "^3.0.0"
"winston-syslog": "^2.0.0"

I place a "console.log( info )" right at the top of the log() method. Consider this example with no formats:

const winston = require( 'winston' );
require( 'winston-syslog' );
let log = winston.createLogger({
  transports: [
    new winston.transports.Syslog({
      host: '192.168.99.100',
      port: 514,
      protocol: 'udp4',
      app_name: 'test'
    })
  ]
});


log.info( 'This is a test!!' );
setTimeout( () => {
  process.exit(0);
}, 1000 );

The console.log shows:

{ message: 'This is a test!!',
  level: 'info',
  [Symbol(level)]: 'info',
  [Symbol(message)]: '{"message":"This is a test!!","level":"info"}' }

and that is good. Now consider this example:

const winston = require( 'winston' );
require( 'winston-syslog' );
let log = winston.createLogger({
  format: winston.format.combine(
    winston.format.label({ label: 'right meow!' }),
  ),
  transports: [
    new winston.transports.Syslog({
      host: '192.168.99.100',
      port: 514,
      protocol: 'udp4',
      app_name: 'test'
    })
  ]
});


log.info( 'This is a test!!' );
setTimeout( () => {
  process.exit(0);
}, 1000 );

The console.log now shows:

{ message: 'This is a test!!',
  level: 'info',
  label: 'right meow!',
  [Symbol(level)]: 'info' }

The [Symbol(message)] has disappeared and now "const output = info[MESSAGE];" on line #117 is undefined!

Not sure if this is a problem inside winston or here in syslog.

@pbadenski
Copy link

+1 Seeing the same problem and looks like this issue has not been acknowledged since last year.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants