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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Also allow setting transport level of type (level) => boolean #2433

Open
movahhedi opened this issue Mar 24, 2024 · 0 comments
Labels
Feature Request Request for new functionality to support use cases not already covered Needs Investigation

Comments

@movahhedi
Copy link

movahhedi commented Mar 24, 2024

馃攷 Search Terms

transport, level

The vision

When passing transports to createLogger(), each transport asks for a level of type string, to use to log higher levels of that. e.g. setting it to warn tells it to log warn, error, fatal.
But there is a need to log a specific level or levels, not lower nor higher. I propose adding support for the type (level) => boolean, to tell whether or not the transport should be called.

Winston.createLogger({
	levels: {
		fatal: 0,
		error: 1,
		warn: 2,
		info: 3,
	},
	transports: [
		new Winston.transports.Console({
			// As usual
			level: "warn",
		}),
		new Winston.transports.File({
			level: (level) => ["fatal", "error"].includes(level),
			filename: Path.join(logDir, "important.log"),
		}),
		new Winston.transports.File({
			level: (level) => level === "info",
			filename: Path.join(logDir, "infoOnly.log"),
		}),
	],
});

Use case

No response

Additional information

No response

@movahhedi movahhedi added Feature Request Request for new functionality to support use cases not already covered Needs Investigation labels Mar 24, 2024
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 Needs Investigation
Projects
None yet
Development

No branches or pull requests

1 participant