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.

Rewrite actually modify the source object

See original GitHub issue

The rewriters actually modify the source meta object:

    winston.rewriters.push(function(level, msg, meta) {
      const actionType = meta && meta.data && meta.data.action;
      const valueToHide = meta && meta.data && meta.data.text;
      if (actionType === 'typeText' && valueToHide) {
        console.log('Logs filtering:', actionType, valueToHide)
        meta.data.text = null;
      }

      return meta;
    })

It should be cloned before being passed to the rewriter function.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
netonekocommented, Dec 20, 2016

And this is detrimental to actual apps. Simple call to winston.log('Hello', myBusinessObject) will modify the business object. There should at least be a warning about this behavior.

This is a major issue of data integrity compromised by calling a log function.

0reactions
indexzerocommented, Dec 21, 2016

@lasryaric this is by design. @jcready is correct when he says:

“A deep clone would be detrimental to performance and a shallow clone would not prevent mutation of deeply nested objects. It seems like you would be better off just cloning the meta object yourself if you’re going to be mutating it.”

As to your comment about winston is a fancy console.log @netoneko, I would point out that console.log does not have rewrite functionality built into it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modifying a copy of a JavaScript object is causing the original ...
A normal copy. When you change the original object's properties, the copied object's properties will change too (and vice versa). const a =...
Read more >
Modify series in the object storage via bucket rewrite tool
This is the example command to delete some data in the specified TSDB block from your object store bucket. For example, if k8s_app_metric37 ......
Read more >
ASTRewrite (Eclipse JDT API Specification) - IBM
Converts all modifications recorded by this rewriter into an object representing the the corresponding text edits to the source of a ITypeRoot from...
Read more >
Refactor vs. rewrite: Deciding what to do with problem software
A rewrite allows new developers to instantly implement code they are comfortable with. This advantage is especially attractive after a merger or ...
Read more >
7.6 Git Tools - Rewriting History
Changing your most recent commit is probably the most common rewriting of history that you'll do. You'll often want to do two basic...
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