Logger plugin nests log data for actions when dispatching multiple actions
Hey I totally love ngxs for all kinds of reasons, and I have built several large projects with ngrx. So this is not a big feature request in the scale of things.
When dispatching multiple actions at once, the console log grouping is such that the log data for the second action is nested inside the first, the third inside the second and so on. It has tripped me up a couple of times because I look at the log and think I have a bug because it appears that an action is not being dispatched. Of course it is, I just have to click and expand multiple levels of grouping.
Could it be that the log lines are issued serially? So console.group(...) ... console.groupEnd() sequences one after the other, rather than nested inside each other?
Thanks!
Good catch, things can execute out of sequence so I can see how this might happen.
@mflorence99 I can see this is fixed now. Can you try again with latest code?
I tried "@ngxs/store": "2.1.0-beta.9" and "@ngxs/logger-plugin": "latest" if that's what you meant, but the anomaly appears worse, sadly. All the log lines are buried inside of the action @@INIT log (so that you have to expand it to see them). It's as if console.groupEnd() was not being called. Should I have tried the v3 beta?
Yep, at some point, all other logs are nested.

Also, it would be nice to make the option logger: any -> logger?: any.
In most cases, the console is the default choice.
The fix for this is it only needs to log on success, the before logger is getting messed up by async actions.
An aspect of this may have been fixed by this PR: https://github.com/ngxs/store/pull/235 The way I picked up the issue of some actions not firing completion was through seeing the deeply nested logger plugin output in the console. So I think that this explains how it was partially resolved.
I would expect that all actions triggered by a root action would be nested under that action (even if they are async). This may pose a problem when there are multiple root actions that are in progress... I'm not familiar with the console.group(...) API. Can this support writing to multiple groups at the same time? If not, we may need to log the group to the console on action completion and log the dispatched actions to the console without nesting.
I agree with you on nested actions. If an action itself issues a dispatch for another action then fair enough the log lines themselves should appear nested. But the case I initially observed originated from using the dispatch API to trigger multiple actions at once by passing an array. I donβt think of these actions as being nested.
@markwhitfeld as of 3.0.0-dev.4e68823, the problem persists.
We are going to have to remove grouping. Its just not going to work the way we do thing. I'll do this in 3.0
It makes sense. Looking forward to it.
Logs are for development and debugging. It is ideal for the logs to appear as the are triggered. This is since we could have non-ngxs logs show up in-between a Ngxs action group.
On Apr 11, 2018, at 6:48 PM, Austin [email protected] wrote:
We are going to have to remove grouping. Its just not going to work the way we do thing. I'll do this in 3.0
β You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Opened a new issue to track this. Gonna close this one.