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

debug: add ability to specify log levels with log() #1475

Closed
wants to merge 1 commit into from
Closed

Conversation

sohkai
Copy link
Contributor

@sohkai sohkai commented Jul 6, 2020

Bit of an experiment to see how we could add debug levels to our log() utility.

Took a quick look around npm and I swear something similar to this must exist, but I couldn't find it 🤷‍♂️. Any suggestions (more battle tested than this one) welcome!


Couldn't come up with an API that felt nice without the transparent binding, so this is inspired somewhat by the debug API:

log('some message')
log('warn')('a warning')
log('error', 'a bad warning')

@sohkai
Copy link
Contributor Author

sohkai commented Jul 8, 2020

cc @Evalir @bpierre @andy-hook some feedback welcome!

@bpierre
Copy link
Contributor

bpierre commented Jul 8, 2020

Looking good!

I was wondering if the currying mode was really needed, rather than having only one way to use it? I can see how it could be useful to do e.g. .forEach(log('warn')), but we should exclude the index and array parameters anyway, so it would end up being the same. Or do you see another reason?

Also what would you think about making the level a required parameter? I think it could help us to think about the level of every log() call.

Also wondering if we should have a way to optionally tag them, so we could exclude / include the exact logs we want when developing. For example this log() call could look like this:

// assuming [level, tags] when an array is passed as a first param
log(
  ['info', ['aragonjs', 'app']],
  'Apps updated',
  apps
)

// we could also skip the tags by passing a string
log(
  'info',
  'Apps updated',
  apps
)

@Evalir
Copy link
Contributor

Evalir commented Jul 9, 2020

Also wondering if we should have a way to optionally tag them, so we could exclude / include the exact logs we want when developing.

You mean being able to exclude certain logs from the console during development? I think this would be inmensely useful, as especially when making changes to the client / an app, the huge amount of logs slows the whole tab down. :)

@sohkai
Copy link
Contributor Author

sohkai commented Jul 12, 2020

I was wondering if the currying mode was really needed

No, it was mostly just to hide the first parameter if it wasn't wanted.

Also wondering if we should have a way to optionally tag them

Agreed, let's go with that! What do we think about consola?

Screen Shot 2020-07-12 at 7 28 31 PM

@bpierre
Copy link
Contributor

bpierre commented Jul 12, 2020

You mean being able to exclude certain logs from the console during development? I think this would be inmensely useful, as especially when making changes to the client / an app, the huge amount of logs slows the whole tab down. :)

@Evalir yes exactly!

What do we think about consola?

It looks perfect! 👍

@andy-hook
Copy link

andy-hook commented Jul 13, 2020

You mean being able to exclude certain logs from the console during development? I think this would be inmensely usefu

+++ 1, this is going to be very handy! agree with points raised. Consola looks 😎

@stale stale bot added the abandoned label Aug 12, 2020
@aragon aragon deleted a comment from stale bot Aug 12, 2020
@stale stale bot removed the abandoned label Aug 12, 2020
@stale stale bot added the abandoned label Sep 11, 2020
@aragon aragon deleted a comment from stale bot Sep 11, 2020
@stale stale bot removed the abandoned label Sep 11, 2020
@stale stale bot added the abandoned label Oct 11, 2020
@aragon aragon deleted a comment from stale bot Oct 11, 2020
@stale stale bot removed the abandoned label Oct 11, 2020
@sohkai
Copy link
Contributor Author

sohkai commented Nov 13, 2020

Closing for now; it looks like we reached soft consensus on consola and we can bring it back up at a later point :).

@sohkai sohkai closed this Nov 13, 2020
@sohkai sohkai deleted the log-level branch November 13, 2020 11:04
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.

4 participants