Prevent invalid values for level
gr2m opened this issue · 3 comments
gr2m commented
Throw an error if a user sets level
to something else but debug
, info
, warn
or error
, by using a getter/setter pair
log.level = 'foo'
// throws InvalidValue error
- claim this issue (comment below)
- start a pull request
- write tests
- implement
- update README
- review & merge
Comment bellow, ping me in the Hoodie Chat or on Twitter if you have any questions
ianstalter123 commented
I should be able to do this one (if its ok to use an if statement to check for log level) like :
Object.defineProperty(api, 'level', {
get: function () {
return state.level
},
set: function (newValue) {
if (['debug', 'error', 'info', 'warn'].indexOf(newValue) > -1) {
state.level = newValue
}
gr2m commented