1
0
mirror of https://github.com/esphome/esphome.git synced 2025-06-18 06:15:46 +01:00

Only compile protobuf dumping when very verbose logging is enabled ()

This commit is contained in:
Oxan van Leeuwen
2021-08-09 22:32:06 +02:00
committed by GitHub
parent ea4a458214
commit 926bcc71ae
6 changed files with 364 additions and 1 deletions

@ -661,8 +661,12 @@ def build_message_type(desc):
o += "\n"
o += f" {o2}\n"
o += "}\n"
cpp += f"#ifdef HAS_PROTO_MESSAGE_DUMP\n"
cpp += o
prot = "void dump_to(std::string &out) const override;"
cpp += f"#endif\n"
prot = "#ifdef HAS_PROTO_MESSAGE_DUMP\n"
prot += "void dump_to(std::string &out) const override;\n"
prot += "#endif\n"
public_content.append(prot)
out = f"class {desc.name} : public ProtoMessage {{\n"
@ -774,7 +778,9 @@ def build_service_message_type(mt):
hout += f"bool {func}(const {mt.name} &msg);\n"
cout += f"bool {class_name}::{func}(const {mt.name} &msg) {{\n"
if log:
cout += f'#ifdef HAS_PROTO_MESSAGE_DUMP\n'
cout += f' ESP_LOGVV(TAG, "{func}: %s", msg.dump().c_str());\n'
cout += f'#endif\n'
# cout += f' this->set_nodelay({str(nodelay).lower()});\n'
cout += f" return this->send_message_<{mt.name}>(msg, {id_});\n"
cout += f"}}\n"
@ -788,7 +794,9 @@ def build_service_message_type(mt):
case += f"{mt.name} msg;\n"
case += f"msg.decode(msg_data, msg_size);\n"
if log:
case += f'#ifdef HAS_PROTO_MESSAGE_DUMP\n'
case += f'ESP_LOGVV(TAG, "{func}: %s", msg.dump().c_str());\n'
case += f'#endif\n'
case += f"this->{func}(msg);\n"
if ifdef is not None:
case += f"#endif\n"