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

log levels? #21

Open
wmertens opened this issue Jun 13, 2017 · 4 comments
Open

log levels? #21

wmertens opened this issue Jun 13, 2017 · 4 comments
Assignees

Comments

@wmertens
Copy link

instead of log.tag('verbose') it would be nicer to use e.g. log.tag(0) and then set the filter to >1 somehow.

Another option may be const dbg = log.tag('mymodule, debug'); const err = log.tag('mymodule, err'); and then use dbg and err through the file; not sure if they can be reused?

@aretecode aretecode self-assigned this Jun 14, 2017
@aretecode
Copy link
Collaborator

@wmertens done this, just doing some docs

@aretecode
Copy link
Collaborator

@wmertens alongside the wip docs for a bunch of other features

these are some updates ones in filtering, how's this look?

☕ filtering

comma separated strings, or arrays
a function can also be passed in, the argument will be an object containing the entries see flipchain/ChainedMap.entries

🔢 level

filter by log level as a number with simple comparison operators

log.filter('>= 1')
log.level(1).bold('above 1... success').echo()
log.level(0).bold('not above 1...').echo()

🎯 matcher

filter using an Array made up of Functions, Strings, and RegExps!

log.filter(['canada*'])
log.tag('canada-eh').white('canadian, pass.').echo()

more advanced

log.filter(['eh*', '!warm', tag => (/ez/).test(tag)])
log.tag('eh').underline('eh').echo()
log.tag('warm').red('warm').echo()
log.tag('ez').yellow('ez').echo()

❗ important to note, if only a function is passed in, it will have the entire log instance passed to the argument, rather than the array of tags (for compatibility & simplicity.)

filter & tags

  • verbose enables everything
  • silent silences everything
  • ! means disabled
log
  .filter('!nope, yes')

log
  .tag('unrelated,nope')
  .cyan('you will never see me :-(')
  .echo()

log
  .tag('yes')
  .underline('yay!')
  .echo()

@wmertens
Copy link
Author

Looks 🔥🔥🔥

@aretecode
Copy link
Collaborator

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

No branches or pull requests

2 participants