Skip to content

Commit

Permalink
Add more logging for service level failures
Browse files Browse the repository at this point in the history
  • Loading branch information
dormant-user committed Aug 17, 2024
1 parent f3463d7 commit 2833be6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pyninja/service.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import logging
import platform
import subprocess
from http import HTTPStatus

from pyninja import exceptions, models

LOGGER = logging.getLogger("uvicorn.default")

current_os = platform.system()

if current_os not in ("Darwin", "Linux", "Windows"):
Expand Down Expand Up @@ -54,7 +57,8 @@ def get_service_status(service_name: str) -> models.ServiceStatus:
return stopped
else:
return unknown
except subprocess.CalledProcessError:
except subprocess.CalledProcessError as error:
LOGGER.error("%d - %s", 404, error)
return unavailable

if current_os == "Linux":
Expand All @@ -71,7 +75,8 @@ def get_service_status(service_name: str) -> models.ServiceStatus:
status_code=HTTPStatus.NOT_IMPLEMENTED.real,
description=f"{service_name} - {output}",
)
except subprocess.CalledProcessError:
except subprocess.CalledProcessError as error:
LOGGER.error("%d - %s", 404, error)
return unavailable

if current_os == "Darwin":
Expand All @@ -83,5 +88,6 @@ def get_service_status(service_name: str) -> models.ServiceStatus:
return running
else:
return stopped
except subprocess.CalledProcessError:
except subprocess.CalledProcessError as error:
LOGGER.error("%d - %s", 404, error)
return unavailable

0 comments on commit 2833be6

Please sign in to comment.