-
Notifications
You must be signed in to change notification settings - Fork 317
Add logger predicate #5
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
Add logger predicate #5
Conversation
Potentially also solves https://github.com/fcomb/redux-logger/issues/3 and adds foundation for https://github.com/fcomb/redux-logger/issues/1 |
Hey, thanks!
If we can do this, it's will be very handy: we can use |
Let's split the answer into two parts. Why do I think that passing That is because the module's API wouldn't need to be changed in a breaking manner each time we decide that we need some other configuration option: // API is createLogger(options)
const logger = createLogger({
predicate: ...,
collapsed: true
});
// then we decided to add "logFunc" option to specify custom log function instead of console.log
// API is still the same - createLogger(options)
const logger = createLogger({
predicate: ...,
collapsed: true,
logFunc: ...
});
// VS
// API is createLogger(logFunc, logLevel)
const logger = createLogger(diffLogger(), simple('warn'));
// We decided to add "collapsed" parameter to switch to use console.groupCollapsed
// API changed - createLogger(logFunc, logLevel, collapsed);
// We have to bump the package's minor or even major version
const logger = createLogger(diffLogger(), simple('warn'), true); Another question why to use Say we want to disable logs in production: const logger = createLogger({
predicate: () => ! conf.production
}); To log only important actions const logger = createLogger({
predicate: (getState, action) => action.meta.important
}); And so on. It is way more flexible for consumer of the module and nicely fits in with functional paradigm |
Not exactly. In my idea So,
So we can release redux-logger as core library, but But I have one question: do we really need all of these? It looks like meta-middleware for redux's middleware. Why we can't release separate packages and pass them in Don't think I want to reject your PR, of course not. But I want build better API for long-term and future extensions and we need investigate do we really need it or it's overengineering. |
I agree here, we definitely don't want to do the applyMiddleware's job: applyMiddleware(diffLogger, simpleLogger, etc); But we still have to provide a mechanism of bypassing logging for |
@wizardzloy yep. I think we don't need invent another |
@theaqua thanks for the productive discussion |
Implementation for https://github.com/fcomb/redux-logger/issues/4.