Public Access
Add logger checks before logging in ProtocolFactory
This commit is contained in:
1 parent
a71b90cf3e
commit
e70c936813
1 file changed
+4
-1
@@ -1,6 +1,7 @@
|
||||
#include "protocol_factory.h"
|
||||
#include "ups_hid.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/components/logger/logger.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace esphome {
|
||||
@@ -25,7 +26,7 @@ void ProtocolFactory::ensure_initialized() {
|
||||
// Registries are initialized on first access due to static storage
|
||||
// This function exists for explicit initialization if needed
|
||||
static bool initialized = false;
|
||||
if (!initialized) {
|
||||
if (esphome::logger::global_logger != nullptr)
|
||||
ESP_LOGD(FACTORY_TAG, "Protocol factory registries initialized");
|
||||
initialized = true;
|
||||
}
|
||||
@@ -44,6 +45,7 @@ void ProtocolFactory::register_protocol_for_vendor(uint16_t vendor_id,
|
||||
return a.priority > b.priority;
|
||||
});
|
||||
|
||||
if (esphome::logger::global_logger != nullptr)
|
||||
ESP_LOGI(FACTORY_TAG, "Registered protocol '%s' for vendor 0x%04X (priority %d)",
|
||||
info.name.c_str(), vendor_id, info.priority);
|
||||
}
|
||||
@@ -60,6 +62,7 @@ void ProtocolFactory::register_fallback_protocol(const ProtocolInfo& info) {
|
||||
return a.priority > b.priority;
|
||||
});
|
||||
|
||||
if (esphome::logger::global_logger != nullptr)
|
||||
ESP_LOGI(FACTORY_TAG, "Registered fallback protocol '%s' (priority %d)",
|
||||
info.name.c_str(), info.priority);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user