mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 23:21:54 +00:00 
			
		
		
		
	Merge branch 'logger_8266_str_to_flash' into memory_api
This commit is contained in:
		| @@ -246,14 +246,16 @@ void Logger::add_on_log_callback(std::function<void(uint8_t, const char *, const | |||||||
|   this->log_callback_.add(std::move(callback)); |   this->log_callback_.add(std::move(callback)); | ||||||
| } | } | ||||||
| float Logger::get_setup_priority() const { return setup_priority::BUS + 500.0f; } | float Logger::get_setup_priority() const { return setup_priority::BUS + 500.0f; } | ||||||
| static const char *const LOG_LEVELS[] = {"NONE", "ERROR", "WARN", "INFO", "CONFIG", "DEBUG", "VERBOSE", "VERY_VERBOSE"}; | static const LogString *const LOG_LEVELS[] = {LOG_STR("NONE"),    LOG_STR("ERROR"),       LOG_STR("WARN"), | ||||||
|  |                                               LOG_STR("INFO"),    LOG_STR("CONFIG"),      LOG_STR("DEBUG"), | ||||||
|  |                                               LOG_STR("VERBOSE"), LOG_STR("VERY_VERBOSE")}; | ||||||
|  |  | ||||||
| void Logger::dump_config() { | void Logger::dump_config() { | ||||||
|   ESP_LOGCONFIG(TAG, |   ESP_LOGCONFIG(TAG, | ||||||
|                 "Logger:\n" |                 "Logger:\n" | ||||||
|                 "  Max Level: %s\n" |                 "  Max Level: %s\n" | ||||||
|                 "  Initial Level: %s", |                 "  Initial Level: %s", | ||||||
|                 LOG_LEVELS[ESPHOME_LOG_LEVEL], LOG_LEVELS[this->current_level_]); |                 LOG_STR_ARG(LOG_LEVELS[ESPHOME_LOG_LEVEL]), LOG_STR_ARG(LOG_LEVELS[this->current_level_])); | ||||||
| #ifndef USE_HOST | #ifndef USE_HOST | ||||||
|   ESP_LOGCONFIG(TAG, |   ESP_LOGCONFIG(TAG, | ||||||
|                 "  Log Baud Rate: %" PRIu32 "\n" |                 "  Log Baud Rate: %" PRIu32 "\n" | ||||||
| @@ -267,14 +269,14 @@ void Logger::dump_config() { | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   for (auto &it : this->log_levels_) { |   for (auto &it : this->log_levels_) { | ||||||
|     ESP_LOGCONFIG(TAG, "  Level for '%s': %s", it.first.c_str(), LOG_LEVELS[it.second]); |     ESP_LOGCONFIG(TAG, "  Level for '%s': %s", it.first.c_str(), LOG_STR_ARG(LOG_LEVELS[it.second])); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| void Logger::set_log_level(uint8_t level) { | void Logger::set_log_level(uint8_t level) { | ||||||
|   if (level > ESPHOME_LOG_LEVEL) { |   if (level > ESPHOME_LOG_LEVEL) { | ||||||
|     level = ESPHOME_LOG_LEVEL; |     level = ESPHOME_LOG_LEVEL; | ||||||
|     ESP_LOGW(TAG, "Cannot set log level higher than pre-compiled %s", LOG_LEVELS[ESPHOME_LOG_LEVEL]); |     ESP_LOGW(TAG, "Cannot set log level higher than pre-compiled %s", LOG_STR_ARG(LOG_LEVELS[ESPHOME_LOG_LEVEL])); | ||||||
|   } |   } | ||||||
|   this->current_level_ = level; |   this->current_level_ = level; | ||||||
|   this->level_callback_.call(level); |   this->level_callback_.call(level); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user