Skip to content

Commit

Permalink
switch logger
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1te909 committed Nov 22, 2023
1 parent f9387a5 commit 2abbd2e
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions api/tacticalrmm/agents/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
import logging
import re
from collections import Counter
from contextlib import suppress
Expand All @@ -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
Expand Down Expand Up @@ -54,6 +54,8 @@
# type helpers
Disk = Union[Dict[str, Any], str]

logger = logging.getLogger("trmm")


class Agent(BaseAuditModel):
class Meta:
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 2abbd2e

Please sign in to comment.