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

Could logging loglevel be configurable? #9

Open
zxdavb opened this issue Oct 14, 2018 · 0 comments
Open

Could logging loglevel be configurable? #9

zxdavb opened this issue Oct 14, 2018 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@zxdavb
Copy link

zxdavb commented Oct 14, 2018

There is a lot of DEBUG log message via logger -p debug... It woudl be great if this was configurable via (say):

uci set hass.global.loglevel=6

...where 6 is equal to INFO, etc. as per the 'standard' logger priorities.

I am unable to submit a PR at the moment (house renovations), but this chunk of code may be a start:

function log_msg {
    local _LEVEL _LEVEL_TEXT=$1
    shift   # remove loglevel param

    config_get hass_loglevel global loglevel 5  # default is NOTICE

    [ "$_LEVEL_TEXT" == "error" ]   && _LEVEL=3
    [ "$_LEVEL_TEXT" == "warning" ] && _LEVEL=4
    [ "$_LEVEL_TEXT" == "notice" ]  && _LEVEL=5
    [ "$_LEVEL_TEXT" == "info" ]    && _LEVEL=6
    [ "$_LEVEL_TEXT" == "debug" ]   && _LEVEL=7

    if [ $_LEVEL -le $hass_loglevel ]; then
        logger -p $_LEVEL -t $0 $@
    fi
}

Then, through the code, you could have, for example:

log_msg error "register_hook() missing interface"
@mueslo mueslo added the enhancement New feature or request label Oct 16, 2018
@mueslo mueslo added this to the 0.2 milestone Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants