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.rejections is missing #1834

Open
ab-pm opened this issue Aug 12, 2020 · 2 comments
Open

winston.rejections is missing #1834

ab-pm opened this issue Aug 12, 2020 · 2 comments

Comments

@ab-pm
Copy link

ab-pm commented Aug 12, 2020

The docs claim:

If you want to use this feature with the default logger, simply call .rejections.handle() with a transport instance.

//
// You can add a separate rejection logger by passing it to `.rejections.handle`
//
winston.rejections.handle(
  new winston.transports.File({ filename: 'path/to/rejections.log' })
);

This probably was copied verbatim from the respective section on exception handling, but does not work. The winston object does not expose a .rejections property that's forwarded to defaultLogger.rejections, like it does for exceptions:

winston/lib/winston.js

Lines 128 to 137 in 80d3439

/**
* Define getter for `exceptions` which replaces `handleExceptions` and
* `unhandleExceptions`.
* @type {Object}
*/
Object.defineProperty(winston, 'exceptions', {
get() {
return defaultLogger.exceptions;
}
});

@ghost
Copy link

ghost commented Sep 24, 2020

Also, a related issue, the LoggerOptions interface does not define a 'rejectionHandlers' field, though the Readme shows an example of passing a 'rejectionHandlers' option to 'createLogger'.

interface LoggerOptions { levels?: Config.AbstractConfigSetLevels; silent?: boolean; format?: logform.Format; level?: string; exitOnError?: Function | boolean; defaultMeta?: any; transports?: Transport[] | Transport; handleExceptions?: boolean; exceptionHandlers?: any; }

`
// Enable rejection handling when you create your logger.

const logger = createLogger({
transports: [
new transports.File({ filename: 'combined.log' })
],
rejectionHandlers: [
new transports.File({ filename: 'rejections.log' })
]
});
`

@ab-pm
Copy link
Author

ab-pm commented Sep 24, 2020

@wjcampbellcom That's #1801 I think

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

1 participant