app: improve endpoint registration logging
Only log registration when verbose (debug) logging is enabled. In addition, log endpoint removal. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
94989b39dc
commit
6dbcdf537f
|
@ -328,8 +328,8 @@ class MoonrakerApp:
|
|||
f"Local endpoint '{endpoint}' already registered"
|
||||
)
|
||||
return
|
||||
logging.debug(f"Registering API: {api_def}")
|
||||
if TransportType.HTTP in transports:
|
||||
logging.info(f"Registering HTTP Endpoint: ({request_types}) {http_path}")
|
||||
params: dict[str, Any] = {}
|
||||
params["api_definition"] = api_def
|
||||
params["wrap_result"] = wrap_result
|
||||
|
@ -339,8 +339,6 @@ class MoonrakerApp:
|
|||
)
|
||||
self.registered_base_handlers.append(http_path)
|
||||
for request_type, method_name in api_def.rpc_items():
|
||||
transports = api_def.transports & ~TransportType.HTTP
|
||||
logging.info(f"Registering RPC Method: ({transports}) {method_name}")
|
||||
self.json_rpc.register_method(method_name, request_type, api_def)
|
||||
|
||||
def register_static_file_handler(
|
||||
|
@ -396,6 +394,7 @@ class MoonrakerApp:
|
|||
def remove_endpoint(self, endpoint: str) -> None:
|
||||
api_def = APIDefinition.pop_cached_def(endpoint)
|
||||
if api_def is not None:
|
||||
logging.debug(f"Removing Endpoint: {endpoint}")
|
||||
if api_def.http_path in self.registered_base_handlers:
|
||||
self.registered_base_handlers.remove(api_def.http_path)
|
||||
self.mutable_router.remove_handler(api_def.http_path)
|
||||
|
|
|
@ -171,6 +171,18 @@ class APIDefinition:
|
|||
auth_required: bool
|
||||
_cache: ClassVar[Dict[str, APIDefinition]] = {}
|
||||
|
||||
def __str__(self) -> str:
|
||||
tprt_str = "|".join([tprt.name for tprt in self.transports if tprt.name])
|
||||
val: str = f"(Transports: {tprt_str})"
|
||||
if TransportType.HTTP in self.transports:
|
||||
req_types = "|".join([rt.name for rt in self.request_types if rt.name])
|
||||
val += f" (HTTP Request: {req_types} {self.http_path})"
|
||||
if self.rpc_methods:
|
||||
methods = " ".join(self.rpc_methods)
|
||||
val += f" (RPC Methods: {methods})"
|
||||
val += f" (Auth Required: {self.auth_required})"
|
||||
return val
|
||||
|
||||
def request(
|
||||
self,
|
||||
args: Dict[str, Any],
|
||||
|
|
Loading…
Reference in New Issue