question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Meta data doesn't get passed to info object after the update

See original GitHub issue

Please tell us about your environment:

  • _winston version: “^3.0.0”,
    • winston@2
    • winston@3
  • _node -v outputs: v9.8.0
  • Operating System? (Linux)

What is the problem?

After updating to the latest version of Winston, 2 days ago, meta data is not added to the info object anymore in some cases!

EXAMPLE 1 (This one works fine!!): If you log meta data like this, meta becomes part of ‘message’ object, so it seems to work fine. logger.error('This is a test', { number: 123 });

‘console.log’ of the ‘info’ object looks like this:

{ number: 123,
  level: '\u001b[31merror\u001b[39m',
  message: 'This is a test',
  timestamp: '2018-06-28T09:42:04.036Z',
  [Symbol(level)]: 'error',
  [Symbol(splat)]: [ { number: 123 } ],
  [Symbol(message)]: '{"number":123,"level":"error","message":"This is a test"}' }

EXAMPLE 2 (This one doesn’t seem to work properly!!): If there is an additional argument included ( in this case ‘first’ ), meta data becomes an empty array in the info object and also it is not anywhere else in the ‘message’ object at all. logger.error('This is a test %s', 'first', { number: 123 });

‘console.log’ of the ‘info’ object looks like this:

{ level: '\u001b[31merror\u001b[39m',
  message: 'This is a test first',
  timestamp: '2018-06-28T09:48:46.616Z',
  meta: [],
  [Symbol(level)]: 'error',
  [Symbol(splat)]: [ 'first' ],
  [Symbol(message)]: '{"level":"error","message":"This is a test %s"}' }

What do you expect to happen instead?

As you can see, meta data doesn’t exist in the ‘info’ object at all, so there is no way to access it and print it to the console or to log it into the file or anything. This used to work fine before i updated winston npm package 2 days ago.

Thanks for the good work guys, the project is amazing! Best regards!

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:9
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
teneoncommented, Jun 29, 2018

I did some more tests and things are even more out of order regarding ‘meta data’, at least this is how i feel. If you test the examples below and you print out the ‘info’ object for each of them, you should see that ‘meta’ sometimes appear as info object property ,sometimes it appears as part of the ‘message’ object and if you test example 2 in my first post, you should see that sometimes meta data isn’t passed to the info object at all.

// meta data logger.error('This is a test', { number: 123 });

// 1 splat + meta data logger.error('This is a test %s', 'first', { number: 123 });

// 2 splats logger.error('This is a test %s %s', 'first', { number: 123 });

// Interpolation: meta data logger.error(`Testing interpolation`,{ name: 'john'});

// Interpolation: variable + meta data logger.error(`Testing ${12345} interpolation`,{ name: 'john'});

I think ‘meta’ property should always appear in the ‘info’ object at the exactly same place, otherwise it is really hard to check something like: if (info.meta) …do something… because info.meta exists in some scenarios, but appears elsewhere (in the different place or even different form) in another scenario and in some scenarios (which i believe is a bug) is not passed to info object at all.

I had to add lot code in my “logger configuration file” just to detect, if meta data exists or not (in all those different scenarios in the examples above), which i believe is totally unnecessary if the properties of info object were consistent. I simply think it would be easiest if we could always check against: if (info.meta) …do something… else …do something…

I hope that makes sense and keep up the good work, best regards!

0reactions
wbtcommented, Feb 11, 2022

Sounds like a good idea to me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stripe Webhook doesnt capture product data/meta data
I have had a similar problem when using a webhook solution in Stripe. Although I had defined meta data in the product it...
Read more >
update_post_meta() | Function
Post meta values are passed through the stripslashes() function upon being stored, so you will need to be careful when passing in values...
Read more >
View and edit metadata—ArcGIS Pro | Documentation
When you view an item's metadata in the details panel in the catalog view, metadata is created for the item if it doesn't...
Read more >
Entity metadata wrappers - Drupal
You need to set the content type and user ID on a new node entity; and then that can be immediately passed in...
Read more >
Object metadata | Cloud Storage - Google Cloud
You can edit the following metadata for objects, though you must have sufficient ... If an applicable object doesn't have a Cache-Control metadata...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found