mirror of
https://github.com/esphome/esphome.git
synced 2026-02-18 15:35:59 -07:00
Merge branch 'logging_cleanup' into integration
This commit is contained in:
@@ -14,7 +14,7 @@ void log_binary_sensor(const char *tag, const char *prefix, const char *type, Bi
|
||||
}
|
||||
|
||||
ESP_LOGCONFIG(tag, "%s%s '%s'", prefix, type, obj->get_name().c_str());
|
||||
log_entity_device_class(tag, prefix, *obj);
|
||||
LOG_ENTITY_DEVICE_CLASS(prefix, *obj);
|
||||
}
|
||||
|
||||
void BinarySensor::publish_state(bool new_state) {
|
||||
|
||||
@@ -12,7 +12,7 @@ void log_button(const char *tag, const char *prefix, const char *type, Button *o
|
||||
}
|
||||
|
||||
ESP_LOGCONFIG(tag, "%s%s '%s'", prefix, type, obj->get_name().c_str());
|
||||
log_entity_icon(tag, prefix, *obj);
|
||||
LOG_ENTITY_ICON(prefix, *obj);
|
||||
}
|
||||
|
||||
void Button::press() {
|
||||
|
||||
@@ -20,7 +20,7 @@ const extern float COVER_CLOSED;
|
||||
if (traits_.get_is_assumed_state()) { \
|
||||
ESP_LOGCONFIG(TAG, "%s Assumed State: YES", prefix); \
|
||||
} \
|
||||
log_entity_device_class(TAG, prefix, *(obj)); \
|
||||
LOG_ENTITY_DEVICE_CLASS(prefix, *(obj)); \
|
||||
}
|
||||
|
||||
class Cover;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace esphome::datetime {
|
||||
#define LOG_DATETIME_DATE(prefix, type, obj) \
|
||||
if ((obj) != nullptr) { \
|
||||
ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
|
||||
log_entity_icon(TAG, prefix, *(obj)); \
|
||||
LOG_ENTITY_ICON(prefix, *(obj)); \
|
||||
}
|
||||
|
||||
class DateCall;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace esphome::datetime {
|
||||
#define LOG_DATETIME_DATETIME(prefix, type, obj) \
|
||||
if ((obj) != nullptr) { \
|
||||
ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
|
||||
log_entity_icon(TAG, prefix, *(obj)); \
|
||||
LOG_ENTITY_ICON(prefix, *(obj)); \
|
||||
}
|
||||
|
||||
class DateTimeCall;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace esphome::datetime {
|
||||
#define LOG_DATETIME_TIME(prefix, type, obj) \
|
||||
if ((obj) != nullptr) { \
|
||||
ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
|
||||
log_entity_icon(TAG, prefix, *(obj)); \
|
||||
LOG_ENTITY_ICON(prefix, *(obj)); \
|
||||
}
|
||||
|
||||
class TimeCall;
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace event {
|
||||
#define LOG_EVENT(prefix, type, obj) \
|
||||
if ((obj) != nullptr) { \
|
||||
ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
|
||||
log_entity_icon(TAG, prefix, *(obj)); \
|
||||
log_entity_device_class(TAG, prefix, *(obj)); \
|
||||
LOG_ENTITY_ICON(prefix, *(obj)); \
|
||||
LOG_ENTITY_DEVICE_CLASS(prefix, *(obj)); \
|
||||
}
|
||||
|
||||
class Event : public EntityBase, public EntityBase_DeviceClass {
|
||||
|
||||
@@ -14,7 +14,7 @@ class Lock;
|
||||
#define LOG_LOCK(prefix, type, obj) \
|
||||
if ((obj) != nullptr) { \
|
||||
ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
|
||||
log_entity_icon(TAG, prefix, *(obj)); \
|
||||
LOG_ENTITY_ICON(prefix, *(obj)); \
|
||||
if ((obj)->traits.get_assumed_state()) { \
|
||||
ESP_LOGCONFIG(TAG, "%s Assumed State: YES", prefix); \
|
||||
} \
|
||||
|
||||
@@ -14,9 +14,9 @@ void log_number(const char *tag, const char *prefix, const char *type, Number *o
|
||||
}
|
||||
|
||||
ESP_LOGCONFIG(tag, "%s%s '%s'", prefix, type, obj->get_name().c_str());
|
||||
log_entity_icon(tag, prefix, *obj);
|
||||
log_entity_unit_of_measurement(tag, prefix, obj->traits);
|
||||
log_entity_device_class(tag, prefix, obj->traits);
|
||||
LOG_ENTITY_ICON(prefix, *obj);
|
||||
LOG_ENTITY_UNIT_OF_MEASUREMENT(prefix, obj->traits);
|
||||
LOG_ENTITY_DEVICE_CLASS(prefix, obj->traits);
|
||||
}
|
||||
|
||||
void Number::publish_state(float state) {
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace esphome::select {
|
||||
#define LOG_SELECT(prefix, type, obj) \
|
||||
if ((obj) != nullptr) { \
|
||||
ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
|
||||
log_entity_icon(TAG, prefix, *(obj)); \
|
||||
LOG_ENTITY_ICON(prefix, *(obj)); \
|
||||
}
|
||||
|
||||
#define SUB_SELECT(name) \
|
||||
|
||||
@@ -22,8 +22,8 @@ void log_sensor(const char *tag, const char *prefix, const char *type, Sensor *o
|
||||
LOG_STR_ARG(state_class_to_string(obj->get_state_class())), prefix,
|
||||
obj->get_unit_of_measurement_ref().c_str(), prefix, obj->get_accuracy_decimals());
|
||||
|
||||
log_entity_device_class(tag, prefix, *obj);
|
||||
log_entity_icon(tag, prefix, *obj);
|
||||
LOG_ENTITY_DEVICE_CLASS(prefix, *obj);
|
||||
LOG_ENTITY_ICON(prefix, *obj);
|
||||
|
||||
if (obj->get_force_update()) {
|
||||
ESP_LOGV(tag, "%s Force Update: YES", prefix);
|
||||
|
||||
@@ -96,14 +96,14 @@ void log_switch(const char *tag, const char *prefix, const char *type, Switch *o
|
||||
LOG_STR_ARG(onoff));
|
||||
|
||||
// Add optional fields separately
|
||||
log_entity_icon(tag, prefix, *obj);
|
||||
LOG_ENTITY_ICON(prefix, *obj);
|
||||
if (obj->assumed_state()) {
|
||||
ESP_LOGCONFIG(tag, "%s Assumed State: YES", prefix);
|
||||
}
|
||||
if (obj->is_inverted()) {
|
||||
ESP_LOGCONFIG(tag, "%s Inverted: YES", prefix);
|
||||
}
|
||||
log_entity_device_class(tag, prefix, *obj);
|
||||
LOG_ENTITY_DEVICE_CLASS(prefix, *obj);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace text {
|
||||
#define LOG_TEXT(prefix, type, obj) \
|
||||
if ((obj) != nullptr) { \
|
||||
ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
|
||||
log_entity_icon(TAG, prefix, *(obj)); \
|
||||
LOG_ENTITY_ICON(prefix, *(obj)); \
|
||||
}
|
||||
|
||||
/** Base-class for all text inputs.
|
||||
|
||||
@@ -15,8 +15,8 @@ void log_text_sensor(const char *tag, const char *prefix, const char *type, Text
|
||||
}
|
||||
|
||||
ESP_LOGCONFIG(tag, "%s%s '%s'", prefix, type, obj->get_name().c_str());
|
||||
log_entity_device_class(tag, prefix, *obj);
|
||||
log_entity_icon(tag, prefix, *obj);
|
||||
LOG_ENTITY_DEVICE_CLASS(prefix, *obj);
|
||||
LOG_ENTITY_ICON(prefix, *obj);
|
||||
}
|
||||
|
||||
void TextSensor::publish_state(const std::string &state) { this->publish_state(state.data(), state.size()); }
|
||||
|
||||
@@ -20,7 +20,7 @@ const extern float VALVE_CLOSED;
|
||||
if (traits_.get_is_assumed_state()) { \
|
||||
ESP_LOGCONFIG(TAG, "%s Assumed State: YES", prefix); \
|
||||
} \
|
||||
log_entity_device_class(TAG, prefix, *(obj)); \
|
||||
LOG_ENTITY_DEVICE_CLASS(prefix, *(obj)); \
|
||||
}
|
||||
|
||||
class Valve;
|
||||
|
||||
@@ -231,10 +231,13 @@ class EntityBase_UnitOfMeasurement { // NOLINT(readability-identifier-naming)
|
||||
};
|
||||
|
||||
/// Log entity icon if set (for use in dump_config)
|
||||
#define LOG_ENTITY_ICON(prefix, obj) log_entity_icon(TAG, prefix, obj)
|
||||
void log_entity_icon(const char *tag, const char *prefix, const EntityBase &obj);
|
||||
/// Log entity device class if set (for use in dump_config)
|
||||
#define LOG_ENTITY_DEVICE_CLASS(prefix, obj) log_entity_device_class(TAG, prefix, obj)
|
||||
void log_entity_device_class(const char *tag, const char *prefix, const EntityBase_DeviceClass &obj);
|
||||
/// Log entity unit of measurement if set (for use in dump_config)
|
||||
#define LOG_ENTITY_UNIT_OF_MEASUREMENT(prefix, obj) log_entity_unit_of_measurement(TAG, prefix, obj)
|
||||
void log_entity_unit_of_measurement(const char *tag, const char *prefix, const EntityBase_UnitOfMeasurement &obj);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user