store icon indicating copy to clipboard operation
store copied to clipboard

Logger plugin nests log data for actions when dispatching multiple actions

Open mflorence99 opened this issue 8 years ago β€’ 12 comments

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!

mflorence99 avatar Apr 02 '18 21:04 mflorence99

Good catch, things can execute out of sequence so I can see how this might happen.

amcdnl avatar Apr 02 '18 22:04 amcdnl

@mflorence99 I can see this is fixed now. Can you try again with latest code?

tsawan avatar Apr 07 '18 18:04 tsawan

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?

mflorence99 avatar Apr 08 '18 11:04 mflorence99

Yep, at some point, all other logs are nested.

screen shot 2018-04-09 at 12 13 05 pm

Also, it would be nice to make the option logger: any -> logger?: any. In most cases, the console is the default choice.

un33k avatar Apr 09 '18 16:04 un33k

The fix for this is it only needs to log on success, the before logger is getting messed up by async actions.

amcdnl avatar Apr 09 '18 16:04 amcdnl

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.

markwhitfeld avatar Apr 10 '18 09:04 markwhitfeld

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.

markwhitfeld avatar Apr 10 '18 09:04 markwhitfeld

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.

mflorence99 avatar Apr 10 '18 09:04 mflorence99

@markwhitfeld as of 3.0.0-dev.4e68823, the problem persists.

un33k avatar Apr 11 '18 21:04 un33k

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

amcdnl avatar Apr 11 '18 22:04 amcdnl

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.

un33k avatar Apr 11 '18 22:04 un33k

Opened a new issue to track this. Gonna close this one.

amcdnl avatar Apr 12 '18 13:04 amcdnl