Example #1
0
def to_code(config):
    rhs = App.init_log(config.get(CONF_BAUD_RATE))
    log = Pvariable(config[CONF_ID], rhs)
    if CONF_TX_BUFFER_SIZE in config:
        add(log.set_tx_buffer_size(config[CONF_TX_BUFFER_SIZE]))
    if CONF_LEVEL in config:
        add(log.set_global_log_level(LOG_LEVELS[config[CONF_LEVEL]]))
    for tag, level in config.get(CONF_LOGS, {}).iteritems():
        add(log.set_log_level(tag, LOG_LEVELS[level]))
Example #2
0
def to_code(config):
    rhs = App.init_log(config.get(CONF_BAUD_RATE))
    log = Pvariable(u'LogComponent', config[CONF_ID], rhs)
    if CONF_TX_BUFFER_SIZE in config:
        add(log.set_tx_buffer_size(config[CONF_TX_BUFFER_SIZE]))
    if CONF_LEVEL in config:
        add(log.set_global_log_level(exp_log_level(config[CONF_LEVEL])))
    for tag, level in config.get(CONF_LOGS, {}).iteritems():
        global_level = config.get(CONF_LEVEL, 'DEBUG')
        if LOG_LEVELS.index(level) > LOG_LEVELS.index(global_level):
            raise ESPHomeYAMLError(
                u"The local log level {} for {} must be less severe than the "
                u"global log level {}.".format(level, tag, global_level))
        add(log.set_log_level(tag, exp_log_level(level)))