-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Proposal: createLogger can optionally log actions #987
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Thanks for improving the logger plugin 👍
I just commented about a few things.
src/plugins/logger.js
Outdated
logger.groupEnd() | ||
} catch (e) { | ||
logger.log('—— log end ——') | ||
if (actionFilter(action, currentState)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we don't need to deep copy the state here since not retain prevState
for actions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call 💯
src/plugins/logger.js
Outdated
@@ -7,49 +7,83 @@ export default function createLogger ({ | |||
filter = (mutation, stateBefore, stateAfter) => true, | |||
transformer = state => state, | |||
mutationTransformer = mut => mut, | |||
actionFilter = (action, state) => true, | |||
actionTransformer = act => act, | |||
logActions = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's ok to also enable logActions
in default?
@ktsn Thanks for the review, addressed your comments, let me know if you want me to squash my commits. |
What is the status of this, will it be merged? |
Dangit - should have looked here first - I just wrote the same thing |
Almost 2 years later: |
Sorry for the late response on this one, though it might be nice idea to have this...? It's pretty old so it might not be possible but @deini do you think you can rebase this one to the latest |
@kiaking rebased |
Thanks a lot! Checked locally as well and it's working 👍 |
Proposal
Allow
createLogger
to optionally log actions, added a couple of optionsWith some sane default to keep current functionality by default, this would be an opt-in option.Enabled by default as requested.When enabled you get something like:
It just logs the action type and payload, since we cant tie actions to mutations, which I think its ok.
Note: Also added the
devtoolHook
for actions so we can hook it up later with devtools.PS: I'm about to do a small plugin in case this proposal doesn't get approved and will update this PR with the url just in case someone is looking for this functionality. It would be awesome if we could have it built-in tho.