np icon indicating copy to clipboard operation
np copied to clipboard

Verbose mode

Open arichiardi opened this issue 7 years ago • 11 comments

Hello folks!

I was wondering whether it is a good idea to introduce a --verbose command line argument that dumps stdout and stderr along.

I have naively did:

streamToObservable(cp.stdout.pipe(split()))
		.forEach(chunk => {
			console.log(chunk); // only the lines containing "hello" - and they will be capitalized
		});

	streamToObservable(cp.stderr.pipe(split()))
		.forEach(chunk => {
			console.log(chunk); // only the lines containing "hello" - and they will be capitalized
		});

while debugging but I haven't put too much time (just wanted to see what was happening).

What do you think?

arichiardi avatar Jun 22 '17 18:06 arichiardi

Why?

sindresorhus avatar Jun 22 '17 20:06 sindresorhus

Debugging purposes, understanding why things are failing and be less opaque. It would be opt-in so no change in current behavior.

arichiardi avatar Jun 22 '17 20:06 arichiardi

What specific problem are you trying to solve? In what situation could you have needed it? We don't add options lightly, so there should be clear benefits and use-cases.

sindresorhus avatar Jun 22 '17 20:06 sindresorhus

The npm publish command was hanging and was not able to understand what was going on because the Observable was still awaiting for things to finish.

Thanks to the --verbose parameter I would have been able to understand what the problem was without having to debug np.

arichiardi avatar Jun 22 '17 20:06 arichiardi

@sindresorhus In the case of npm publish, could we add a prerequisite check that checks of the user is signed in and everything is setup correctly?

SamVerschueren avatar Jun 24 '17 12:06 SamVerschueren

@SamVerschueren See https://github.com/sindresorhus/np/issues/99

sindresorhus avatar Jun 24 '17 12:06 sindresorhus

@arichiardi I'm not sure if verbose would have helped you in that case as it would still have hung because it was waiting for stdin input. We already stream stdout/stdout in the task list.

sindresorhus avatar Jun 30 '17 20:06 sindresorhus

I am sure that it helped, because I basically did change the streaming target of the child observables and saw what was going on 😀

arichiardi avatar Jun 30 '17 20:06 arichiardi

If that's correct, it's a bug in np or listr.

sindresorhus avatar Jun 30 '17 21:06 sindresorhus

I respectfully think your arguments should be more specific and not just distrust what the other party is trying to explain.

I will explain you way it was failing: the bug was neither in np nor in listr. The absence of the output actually led me to think it was. That is not a bug, but a missing feature for improving the UX of your tool, hence the open issue.

It was weird 😀. So I have a scripts section in my package.json that contains publish which basically runs np. Funnily enough, np calls npm publish, which in turn calls the whole thing all over again.

You can try it now. There is no way, a part from a --verbose flag to see what is going on clearly. Even attaching a debugger is confusing 😀

arichiardi avatar Jun 30 '17 21:06 arichiardi

np calls npm publish, which in turn calls the whole thing all over again.

We could mention this problem in the readme, but the issue is mainly configuration-related.

@sindresorhus In general, I think that in many cases you prefer having extensive logging than having to duck-debug weird issues that involve many different modules and steps. What we could do is save a log file (e.g. .np-error.log) in case publishing fails, which would contain the complete log of the entire publishing process. np has grown quite a bit over the last few months, and I think that this feature would be very helpful for debugging, triaging and reporting issues.

itaisteinherz avatar Mar 16 '19 14:03 itaisteinherz