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

Feature request: create child logger we prebound meta data #913

Closed
nickcarenza opened this issue Aug 23, 2016 · 14 comments
Closed

Feature request: create child logger we prebound meta data #913

nickcarenza opened this issue Aug 23, 2016 · 14 comments
Labels
Feature Request Request for new functionality to support use cases not already covered Important

Comments

@nickcarenza
Copy link

I would like to create a child logger with some prebound meta data. I pass around the logger to different parts of my applications and find it very convenient to bind some information about that process just once.

@parthgandhi7
Copy link

parthgandhi7 commented Sep 6, 2016

yes. something like this is needed. +1

@ORusak
Copy link

ORusak commented Sep 9, 2016

+1

@FastNinja
Copy link

there is a serious need for that. For example - in any API web serviceyou want to log request ID along with log message. But you don't want to pass this information to your objects - all you want to pass is a child logger.
There are projects that are trying to close that gap - but looks they are a bit outdated/not used and they don't work with logging exceptions:
https://github.com/citrix-research/node-winston-context

@felimartina
Copy link

felimartina commented Dec 29, 2016

I have the same problem!
Anyone knows at least a work around for this?
Probably creating a custom formatter like the following (haven't tried...just brain storming)
FYI...I need it for json logging

    var fixedMetas = {appName: 'APP_1'} // Example of a fixed meta
formatter(params) {
        // It's general properties are: timestamp, level, message, meta.
        var meta = params.meta || {};
        for (var metaKey in fixedMetas) {
            meta[metaKey] = fixedMetas[key];
        }
        const meta = params.meta !== undefined ? util.inspect(params.meta, { depth: null }) : '';
        return params
      },

Any thoughts?

@FastNinja
Copy link

FastNinja commented Jan 27, 2017 via email

@sinedied
Copy link

Still no love for this one? This seems a pretty basic need other loggers implements since ages :/

@gswalden
Copy link

Second 👍 for winston-context

@sinedied
Copy link

winston-context is outdated does not solves the issue problem, it's more of a hack than a real solution.

It's really a "standard" feature for loggers, I really wonder how it got missed out in the design...
node-bunyan had this since the beginning, and if it wasn't for the json output I would have switched already 😕

@bertho-zero
Copy link

+1

3 similar comments
@GGYaX
Copy link

GGYaX commented Dec 20, 2017

+1

@antoniusostermann
Copy link

antoniusostermann commented Jan 16, 2018

+1

@birbird
Copy link

birbird commented Jan 26, 2018

+1

@kibertoad
Copy link
Contributor

@indexzero I am thinking about picking this one up, could you share some of your design vision how this could look within existing architecture and where the appropriate code should go?

@indexzero indexzero added this to In review in winston@3.2.0 Dec 7, 2018
@indexzero indexzero moved this from In review to In progress in winston@3.2.0 Dec 7, 2018
@indexzero indexzero moved this from In progress to Done in winston@3.2.0 Dec 23, 2018
@indexzero
Copy link
Member

Fixed in #1471. Will be released in winston@3.2.0. Follow the remaining items for that release here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Request for new functionality to support use cases not already covered Important
Projects
No open projects
winston@3.2.0
  
Done
Development

No branches or pull requests