Skip to content

Could logging loglevel be configurable? #9

@zxdavb

Description

@zxdavb

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions