Skip to content

Commit

Permalink
add debug logging (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcolivierarsenault authored Dec 9, 2023
1 parent 98b6467 commit 46bbcdd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ tts:
logger:
default: warning
logs:
custom_components.moonraker: warning
custom_components.moonraker: debug
23 changes: 17 additions & 6 deletions custom_components/moonraker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.update_coordinator import (DataUpdateCoordinator,
UpdateFailed)
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed

from .api import MoonrakerApiClient
from .const import (CONF_API_KEY, CONF_PORT, CONF_PRINTER_NAME, CONF_TLS,
CONF_URL, DOMAIN, HOSTNAME, METHODS, OBJ, PLATFORMS,
TIMEOUT)
from .const import (
CONF_API_KEY,
CONF_PORT,
CONF_PRINTER_NAME,
CONF_TLS,
CONF_URL,
DOMAIN,
HOSTNAME,
METHODS,
OBJ,
PLATFORMS,
TIMEOUT,
)
from .sensor import SENSORS

SCAN_INTERVAL = timedelta(seconds=30)
Expand Down Expand Up @@ -215,6 +224,8 @@ async def _async_get_gcode_file_detail(self, gcode_filename):
async def _async_fetch_data(
self, query_path: METHODS, query_object, quiet: bool = False
):
_LOGGER.debug(f"fetching data from: {query_path.value}")
_LOGGER.debug(f"fetching object: {query_object}")
if not self.moonraker.client.is_connected:
_LOGGER.warning("connection to moonraker down, restarting")
await self.moonraker.start()
Expand All @@ -226,7 +237,7 @@ async def _async_fetch_data(
query_path.value, **query_object
)
if not quiet:
_LOGGER.debug(result)
_LOGGER.debug(f"Query Result: {result}")
return result
except Exception as exception:
raise UpdateFailed() from exception
Expand Down

0 comments on commit 46bbcdd

Please sign in to comment.