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

Expose child on default logger #1603

Merged
merged 4 commits into from
Feb 26, 2019

Conversation

adrianhopebailie
Copy link
Contributor

This allows use to add child loggers to the default logger.

This makes it easy to establish a pattern for sub-components to scope their logs without needing to call createLogger or be passed the application logger.

Example:

app.js

const winston = require('winston');
winston.configure({
  level: 'info',
  format: winston.format.combine(
    winston.format.colorize(),
    winston.format.json()
  ),
  defaultMeta: { service: 'abc-service' },
  transports: [
    new winston.transports.Console()
  ]
})

component-xyz.js

const logger = require('winston').child({ component: 'xyz-middleware' });

Copy link
Contributor

@DABH DABH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always good to have a consistent interface between regular loggers and the default logger.

And... that call-style looks pretty slick :)

Thanks!

@DABH DABH merged commit 80d3439 into winstonjs:master Feb 26, 2019
@Richard-Walton
Copy link

Richard-Walton commented Mar 6, 2019

Love it, I was just looking for this feature. Ty. Is there an ETA for when this will appear on npm?

@adrianhopebailie adrianhopebailie deleted the feature/expose-child branch March 7, 2019 15:06
@adrianhopebailie
Copy link
Contributor Author

@DABH any ETA on when this will appear in a release? Even a patch would be nice 😬

@DABH
Copy link
Contributor

DABH commented Mar 7, 2019

We’ll probably cut a release in a week or two (sorry for vague estimate). In the meantime feel free to reference the master branch directly in your package.json :) Thanks!

@Richard-Walton
Copy link

@DABH Any update on this release?

@matdehaast
Copy link

@DABH Same as above. Any news on cutting a release with this in?

@adrianhopebailie
Copy link
Contributor Author

@DABH Ping! Last release was on 29 Jan. This is non-breaking could we just get a patch with the latest fixes in master?

@DABH
Copy link
Contributor

DABH commented Jun 27, 2019

You will have to ping @indexzero as I can’t push a new tag to npm unfortunately

@matdehaast
Copy link

@indexzero could we please get a new version of Winston tagged and released?

@Richard-Walton
Copy link

@indexzero ?

@richjyoung
Copy link

Any update on this? @indexzero ? Issue #1767 is still open as well with no response even though this commit looks to resolve it.

Mizumaki pushed a commit to Mizumaki/winston that referenced this pull request Jun 11, 2020
* Add `child` pass-through to type defs

* Add pass-through to defaultLogger.child(...)

* Add test for `winston.child`

* fix: type defs
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

Successfully merging this pull request may close these issues.

5 participants