implemented debug masking

This commit is contained in:
Tomaae 2022-02-18 07:33:38 +01:00
parent b1d6e7f6a9
commit e62a711bfe
2 changed files with 44 additions and 6 deletions

View file

@ -3,9 +3,38 @@
import logging import logging
from voluptuous import Optional from voluptuous import Optional
from homeassistant.components.diagnostics import async_redact_data
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
TO_REDACT = {
"ip-address",
"address",
"active-address",
"mac-address",
"active-mac-address",
"orig-mac-address",
"client-id",
"active-client-id",
"eeprom",
"sfp-vendor-serial",
"gateway",
"dns-server",
"wins-server",
"ntp-server",
"caps-manager",
"serial-number",
"source",
"from-addresses",
"to-addresses",
"src-address",
"dst-address",
"password",
"caller-id",
"target",
"ssid",
}
# --------------------------- # ---------------------------
# from_entry # from_entry
@ -53,12 +82,16 @@ def parse_api(
skip=None, skip=None,
) -> dict: ) -> dict:
"""Get data from API""" """Get data from API"""
debug = False
if _LOGGER.getEffectiveLevel() == 10:
debug = True
if not source: if not source:
if not key and not key_search: if not key and not key_search:
data = fill_defaults(data, vals) data = fill_defaults(data, vals)
return data return data
if debug:
_LOGGER.debug("Processing source %s", source) _LOGGER.debug("Processing source %s", async_redact_data(source, TO_REDACT))
keymap = generate_keymap(data, key_search) keymap = generate_keymap(data, key_search)
for entry in source: for entry in source:
@ -77,7 +110,9 @@ def parse_api(
if uid not in data: if uid not in data:
data[uid] = {} data[uid] = {}
_LOGGER.debug("Processing entry %s", entry) if debug:
_LOGGER.debug("Processing entry %s", async_redact_data(entry, TO_REDACT))
if vals: if vals:
data = fill_vals(data, entry, uid, vals) data = fill_vals(data, entry, uid, vals)

View file

@ -155,6 +155,10 @@ class MikrotikControllerData:
config_entry.data[CONF_SSL], config_entry.data[CONF_SSL],
) )
self.debug = False
if _LOGGER.getEffectiveLevel() == 10:
self.debug = True
self.nat_removed = {} self.nat_removed = {}
self.mangle_removed = {} self.mangle_removed = {}
self.filter_removed = {} self.filter_removed = {}
@ -527,9 +531,8 @@ class MikrotikControllerData:
if uid in self.data["arp"] and self.data["arp"][uid]["bridge"] != "": if uid in self.data["arp"] and self.data["arp"][uid]["bridge"] != "":
tmp_interface = self.data["arp"][uid]["bridge"] tmp_interface = self.data["arp"][uid]["bridge"]
_LOGGER.debug( _LOGGER.debug("Ping host: %s", self.data["host"][uid]["address"])
"Ping host: %s (%s)", uid, self.data["host"][uid]["address"]
)
self.data["host"][uid][ self.data["host"][uid][
"available" "available"
] = await self.hass.async_add_executor_job( ] = await self.hass.async_add_executor_job(