Defer log formatting. (#29888)

pull/29900/head
Alexei Chetroi 2019-12-12 14:16:02 -05:00 committed by GitHub
parent 9d662d6114
commit 7685c76b9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 117 additions and 68 deletions

View File

@ -565,11 +565,15 @@ async def websocket_device_cluster_attributes(hass, connection, msg):
{ID: attr_id, ATTR_NAME: attributes[attr_id][0]} {ID: attr_id, ATTR_NAME: attributes[attr_id][0]}
) )
_LOGGER.debug( _LOGGER.debug(
"Requested attributes for: %s %s %s %s", "Requested attributes for: %s: %s, %s: '%s', %s: %s, %s: %s",
f"{ATTR_CLUSTER_ID}: [{cluster_id}]", ATTR_CLUSTER_ID,
f"{ATTR_CLUSTER_TYPE}: [{cluster_type}]", cluster_id,
f"{ATTR_ENDPOINT_ID}: [{endpoint_id}]", ATTR_CLUSTER_TYPE,
f"{RESPONSE}: [{cluster_attributes}]", cluster_type,
ATTR_ENDPOINT_ID,
endpoint_id,
RESPONSE,
cluster_attributes,
) )
connection.send_result(msg[ID], cluster_attributes) connection.send_result(msg[ID], cluster_attributes)
@ -619,11 +623,15 @@ async def websocket_device_cluster_commands(hass, connection, msg):
} }
) )
_LOGGER.debug( _LOGGER.debug(
"Requested commands for: %s %s %s %s", "Requested commands for: %s: %s, %s: '%s', %s: %s, %s: %s",
f"{ATTR_CLUSTER_ID}: [{cluster_id}]", ATTR_CLUSTER_ID,
f"{ATTR_CLUSTER_TYPE}: [{cluster_type}]", cluster_id,
f"{ATTR_ENDPOINT_ID}: [{endpoint_id}]", ATTR_CLUSTER_TYPE,
f"{RESPONSE}: [{cluster_commands}]", cluster_type,
ATTR_ENDPOINT_ID,
endpoint_id,
RESPONSE,
cluster_commands,
) )
connection.send_result(msg[ID], cluster_commands) connection.send_result(msg[ID], cluster_commands)
@ -663,14 +671,21 @@ async def websocket_read_zigbee_cluster_attributes(hass, connection, msg):
[attribute], allow_cache=False, only_cache=False, manufacturer=manufacturer [attribute], allow_cache=False, only_cache=False, manufacturer=manufacturer
) )
_LOGGER.debug( _LOGGER.debug(
"Read attribute for: %s %s %s %s %s %s %s", "Read attribute for: %s: [%s] %s: [%s] %s: [%s] %s: [%s] %s: [%s] %s: [%s] %s: [%s],",
f"{ATTR_CLUSTER_ID}: [{cluster_id}]", ATTR_CLUSTER_ID,
f"{ATTR_CLUSTER_TYPE}: [{cluster_type}]", cluster_id,
f"{ATTR_ENDPOINT_ID}: [{endpoint_id}]", ATTR_CLUSTER_TYPE,
f"{ATTR_ATTRIBUTE}: [{attribute}]", cluster_type,
f"{ATTR_MANUFACTURER}: [{manufacturer}]", ATTR_ENDPOINT_ID,
"{}: [{}]".format(RESPONSE, str(success.get(attribute))), endpoint_id,
"{}: [{}]".format("failure", failure), ATTR_ATTRIBUTE,
attribute,
ATTR_MANUFACTURER,
manufacturer,
RESPONSE,
str(success.get(attribute)),
"failure",
failure,
) )
connection.send_result(msg[ID], str(success.get(attribute))) connection.send_result(msg[ID], str(success.get(attribute)))
@ -693,9 +708,11 @@ async def websocket_get_bindable_devices(hass, connection, msg):
] ]
_LOGGER.debug( _LOGGER.debug(
"Get bindable devices: %s %s", "Get bindable devices: %s: [%s], %s: [%s]",
f"{ATTR_SOURCE_IEEE}: [{source_ieee}]", ATTR_SOURCE_IEEE,
"{}: [{}]".format("bindable devices:", devices), source_ieee,
"bindable devices",
devices,
) )
connection.send_message(websocket_api.result_message(msg[ID], devices)) connection.send_message(websocket_api.result_message(msg[ID], devices))
@ -719,9 +736,11 @@ async def websocket_bind_devices(hass, connection, msg):
zha_gateway, source_ieee, target_ieee, zdo_types.ZDOCmd.Bind_req zha_gateway, source_ieee, target_ieee, zdo_types.ZDOCmd.Bind_req
) )
_LOGGER.info( _LOGGER.info(
"Issued bind devices: %s %s", "Devices bound: %s: [%s] %s: [%s]",
f"{ATTR_SOURCE_IEEE}: [{source_ieee}]", ATTR_SOURCE_IEEE,
f"{ATTR_TARGET_IEEE}: [{target_ieee}]", source_ieee,
ATTR_TARGET_IEEE,
target_ieee,
) )
@ -743,9 +762,11 @@ async def websocket_unbind_devices(hass, connection, msg):
zha_gateway, source_ieee, target_ieee, zdo_types.ZDOCmd.Unbind_req zha_gateway, source_ieee, target_ieee, zdo_types.ZDOCmd.Unbind_req
) )
_LOGGER.info( _LOGGER.info(
"Issued unbind devices: %s %s", "Devices un-bound: %s: [%s] %s: [%s]",
f"{ATTR_SOURCE_IEEE}: [{source_ieee}]", ATTR_SOURCE_IEEE,
f"{ATTR_TARGET_IEEE}: [{target_ieee}]", source_ieee,
ATTR_TARGET_IEEE,
target_ieee,
) )
@ -848,14 +869,21 @@ def async_load_api(hass):
manufacturer=manufacturer, manufacturer=manufacturer,
) )
_LOGGER.debug( _LOGGER.debug(
"Set attribute for: %s %s %s %s %s %s %s", "Set attribute for: %s: [%s] %s: [%s] %s: [%s] %s: [%s] %s: [%s] %s: [%s] %s: [%s]",
f"{ATTR_CLUSTER_ID}: [{cluster_id}]", ATTR_CLUSTER_ID,
f"{ATTR_CLUSTER_TYPE}: [{cluster_type}]", cluster_id,
f"{ATTR_ENDPOINT_ID}: [{endpoint_id}]", ATTR_CLUSTER_TYPE,
f"{ATTR_ATTRIBUTE}: [{attribute}]", cluster_type,
f"{ATTR_VALUE}: [{value}]", ATTR_ENDPOINT_ID,
f"{ATTR_MANUFACTURER}: [{manufacturer}]", endpoint_id,
f"{RESPONSE}: [{response}]", ATTR_ATTRIBUTE,
attribute,
ATTR_VALUE,
value,
ATTR_MANUFACTURER,
manufacturer,
RESPONSE,
response,
) )
hass.helpers.service.async_register_admin_service( hass.helpers.service.async_register_admin_service(
@ -890,15 +918,23 @@ def async_load_api(hass):
manufacturer=manufacturer, manufacturer=manufacturer,
) )
_LOGGER.debug( _LOGGER.debug(
"Issue command for: %s %s %s %s %s %s %s %s", "Issued command for: %s: [%s] %s: [%s] %s: [%s] %s: [%s] %s: [%s] %s: %s %s: [%s] %s: %s",
f"{ATTR_CLUSTER_ID}: [{cluster_id}]", ATTR_CLUSTER_ID,
f"{ATTR_CLUSTER_TYPE}: [{cluster_type}]", cluster_id,
f"{ATTR_ENDPOINT_ID}: [{endpoint_id}]", ATTR_CLUSTER_TYPE,
f"{ATTR_COMMAND}: [{command}]", cluster_type,
f"{ATTR_COMMAND_TYPE}: [{command_type}]", ATTR_ENDPOINT_ID,
f"{ATTR_ARGS}: [{args}]", endpoint_id,
f"{ATTR_MANUFACTURER}: [{manufacturer}]", ATTR_COMMAND,
f"{RESPONSE}: [{response}]", command,
ATTR_COMMAND_TYPE,
command_type,
ATTR_ARGS,
args,
ATTR_MANUFACTURER,
manufacturer,
RESPONSE,
response,
) )
hass.helpers.service.async_register_admin_service( hass.helpers.service.async_register_admin_service(
@ -925,12 +961,17 @@ def async_load_api(hass):
command, *args, manufacturer=manufacturer, expect_reply=True command, *args, manufacturer=manufacturer, expect_reply=True
) )
_LOGGER.debug( _LOGGER.debug(
"Issue group command for: %s %s %s %s %s", "Issued group command for: %s: [%s] %s: [%s] %s: %s %s: [%s] %s: %s",
f"{ATTR_CLUSTER_ID}: [{cluster_id}]", ATTR_CLUSTER_ID,
f"{ATTR_COMMAND}: [{command}]", cluster_id,
f"{ATTR_ARGS}: [{args}]", ATTR_COMMAND,
f"{ATTR_MANUFACTURER}: [{manufacturer}]", command,
f"{RESPONSE}: [{response}]", ATTR_ARGS,
args,
ATTR_MANUFACTURER,
manufacturer,
RESPONSE,
response,
) )
hass.helpers.service.async_register_admin_service( hass.helpers.service.async_register_admin_service(
@ -954,20 +995,24 @@ def async_load_api(hass):
await channel.squawk(mode, strobe, level) await channel.squawk(mode, strobe, level)
else: else:
_LOGGER.error( _LOGGER.error(
"Squawking IASWD: %s is missing the required IASWD channel!", "Squawking IASWD: %s: [%s] is missing the required IASWD channel!",
"{}: [{}]".format(ATTR_IEEE, str(ieee)), ATTR_IEEE,
str(ieee),
) )
else: else:
_LOGGER.error( _LOGGER.error(
"Squawking IASWD: %s could not be found!", "Squawking IASWD: %s: [%s] could not be found!", ATTR_IEEE, str(ieee)
"{}: [{}]".format(ATTR_IEEE, str(ieee)),
) )
_LOGGER.debug( _LOGGER.debug(
"Squawking IASWD: %s %s %s %s", "Squawking IASWD: %s: [%s] %s: [%s] %s: [%s] %s: [%s]",
"{}: [{}]".format(ATTR_IEEE, str(ieee)), ATTR_IEEE,
"{}: [{}]".format(ATTR_WARNING_DEVICE_MODE, mode), str(ieee),
"{}: [{}]".format(ATTR_WARNING_DEVICE_STROBE, strobe), ATTR_WARNING_DEVICE_MODE,
"{}: [{}]".format(ATTR_LEVEL, level), mode,
ATTR_WARNING_DEVICE_STROBE,
strobe,
ATTR_LEVEL,
level,
) )
hass.helpers.service.async_register_admin_service( hass.helpers.service.async_register_admin_service(
@ -996,20 +1041,24 @@ def async_load_api(hass):
) )
else: else:
_LOGGER.error( _LOGGER.error(
"Warning IASWD: %s is missing the required IASWD channel!", "Warning IASWD: %s: [%s] is missing the required IASWD channel!",
"{}: [{}]".format(ATTR_IEEE, str(ieee)), ATTR_IEEE,
str(ieee),
) )
else: else:
_LOGGER.error( _LOGGER.error(
"Warning IASWD: %s could not be found!", "Warning IASWD: %s: [%s] could not be found!", ATTR_IEEE, str(ieee)
"{}: [{}]".format(ATTR_IEEE, str(ieee)),
) )
_LOGGER.debug( _LOGGER.debug(
"Warning IASWD: %s %s %s %s", "Warning IASWD: %s: [%s] %s: [%s] %s: [%s] %s: [%s]",
"{}: [{}]".format(ATTR_IEEE, str(ieee)), ATTR_IEEE,
"{}: [{}]".format(ATTR_WARNING_DEVICE_MODE, mode), str(ieee),
"{}: [{}]".format(ATTR_WARNING_DEVICE_STROBE, strobe), ATTR_WARNING_DEVICE_MODE,
"{}: [{}]".format(ATTR_LEVEL, level), mode,
ATTR_WARNING_DEVICE_STROBE,
strobe,
ATTR_LEVEL,
level,
) )
hass.helpers.service.async_register_admin_service( hass.helpers.service.async_register_admin_service(