From 2abbd2e3cf4335615eb954b8534ad84e34550667 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Wed, 22 Nov 2023 10:13:43 +0000 Subject: [PATCH] switch logger --- api/tacticalrmm/agents/models.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/api/tacticalrmm/agents/models.py b/api/tacticalrmm/agents/models.py index 133d157119..21ddfc0f2e 100644 --- a/api/tacticalrmm/agents/models.py +++ b/api/tacticalrmm/agents/models.py @@ -1,4 +1,5 @@ import asyncio +import logging import re from collections import Counter from contextlib import suppress @@ -7,7 +8,6 @@ import msgpack import nats import validators -from asgiref.sync import sync_to_async from django.conf import settings from django.contrib.postgres.fields import ArrayField from django.core.cache import cache @@ -54,6 +54,8 @@ # type helpers Disk = Union[Dict[str, Any], str] +logger = logging.getLogger("trmm") + class Agent(BaseAuditModel): class Meta: @@ -798,9 +800,6 @@ def get_tasks_from_policies(self) -> "List[AutomatedTask]": cache.set(cache_key, tasks, 600) return tasks - def _do_nats_debug(self, agent: "Agent", message: str) -> None: - DebugLog.error(agent=agent, log_type=DebugLogType.AGENT_ISSUES, message=message) - async def nats_cmd( self, data: Dict[Any, Any], timeout: int = 30, wait: bool = True ) -> Any: @@ -822,9 +821,7 @@ async def nats_cmd( ret = msgpack.loads(msg.data) except Exception as e: ret = str(e) - await sync_to_async(self._do_nats_debug, thread_sensitive=False)( - agent=self, message=ret - ) + logger.error(e) await nc.close() return ret