Skip to content
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 config option lessVerbose #128

Merged
merged 4 commits into from
Jun 8, 2024
Merged

Conversation

srguiwiz
Copy link
Contributor

This is for issue #127 .

When not used, nothing changes compared to previous behavior.

One could think of the function name infoV to mean infoVerbose.

@szymmis
Copy link
Owner

szymmis commented Apr 2, 2024

Hi @srguiwiz, great change! Thanks for submitting a PR for that.
I think that we don't really need infoV function: we can just add the verbosity check into the info function itself with the parameter stating what verbosity level it is printed in. Then instead of having lessVerbose as a boolean we can have an enum to choose from, so let's say that Verbosity.Silent is 0 and Verbosity.Normal is 1. As it is a number we can just compare the current verbosity with the one stated in the parameter.

If we have Verbosity.Silent we only want to print if info("msg", Verbosity.Silent) but it should also be printed in higher verbosities.

I think that the example will make that clearer:

enum Verbosity = {
  Silent = 0,
  Normal = 1
}

function info(msg: string, verbosity = Verbosity.Normal) {
  if (Config.verbosity < verbosity) return;
  ...
}

And then you can only change places when you left info without changes as I suppose those are the places when you want to print messages even with verbosity tuned down. We can even introduce third level of verbocity, that way Verbosity.Silent will be no messages at all.

Tell me what you think!
Again, great suggestion right there, thanks a lot!

@srguiwiz
Copy link
Contributor Author

I don't disagree. After reading your comment I had spent a short amount of time thinking of something optimal. But, time can be short in supply. By now I forgot what I had thought.

Thinking of future compatibility without spending more time: If you would merge as is, then a future implementation could choose to take a truthy value in lessVerbose and use it in its newer and improved ways. I think, almost sure, but I could be wrong.

Btw, the specific style of coding was chosen for minimal diff. Not saying that is always the best choice. It was what I had thought that moment would be the least intrusive. If it had been "my" project I'd probably have chosen different constructs, which the moment I was about the type them I thought they would cause a bigger diff.

I would not be offended if you reject this PR and implement it differently. It's all good.

Thank you

@szymmis
Copy link
Owner

szymmis commented Jun 7, 2024

Hi @srguiwiz. Sorry for leaving it for so long. I've finally found some time to sit down and make the changes I was talking about. I totally get your point of view of wanting to change as little as possible. It was not necessary to reject the PR itself as your idea and code were good starting point for my improvements, so thank you very much for suggesting this feature and taking your time to implement it.

I don't know if you are still interested in it as a long time have passed but I hope so!
If yes, then let me know what you think about this change.
I plan to release it soon, but I would also like to tackle this issue in one release.

@szymmis szymmis merged commit 1fc1922 into szymmis:master Jun 8, 2024
1 check passed
@srguiwiz
Copy link
Contributor Author

srguiwiz commented Jun 8, 2024

@szymmis, thank you for your thoughtful implementation. And yes, this is still a useful package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants