From 5a032da984b753744536af2b18506d65a02018c8 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Thu, 8 Apr 2021 19:49:19 -0700 Subject: [PATCH] try to reduce log spam --- mem_edit/abstract.py | 1 - mem_edit/linux.py | 5 ++--- mem_edit/windows.py | 7 +++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/mem_edit/abstract.py b/mem_edit/abstract.py index f2e6cd1..e086d4e 100644 --- a/mem_edit/abstract.py +++ b/mem_edit/abstract.py @@ -13,7 +13,6 @@ from . import utils from .utils import ctypes_buffer_t -logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) diff --git a/mem_edit/linux.py b/mem_edit/linux.py index 58460b8..18f3b8f 100644 --- a/mem_edit/linux.py +++ b/mem_edit/linux.py @@ -15,7 +15,6 @@ from .abstract import Process as AbstractProcess from .utils import ctypes_buffer_t, MemEditError -logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) @@ -94,14 +93,14 @@ class Process(AbstractProcess): def get_pid_by_name(target_name: str) -> Optional[int]: for pid in Process.list_available_pids(): try: - logger.info('Checking name for pid {}'.format(pid)) + logger.debug('Checking name for pid {}'.format(pid)) with open('/proc/{}/cmdline'.format(pid), 'rb') as cmdline: path = cmdline.read().decode().split('\x00')[0] except FileNotFoundError: continue name = os.path.basename(path) - logger.info('Name was "{}"'.format(name)) + logger.debug('Name was "{}"'.format(name)) if path is not None and name == target_name: return pid diff --git a/mem_edit/windows.py b/mem_edit/windows.py index e3bb013..b945058 100644 --- a/mem_edit/windows.py +++ b/mem_edit/windows.py @@ -14,7 +14,6 @@ from .abstract import Process as AbstractProcess from .utils import ctypes_buffer_t, MemEditError -logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) @@ -229,18 +228,18 @@ class Process(AbstractProcess): def get_pid_by_name(target_name: str) -> Optional[int]: for pid in Process.list_available_pids(): try: - logger.info('Checking name for pid {}'.format(pid)) + logger.debug('Checking name for pid {}'.format(pid)) with Process.open_process(pid) as process: path = process.get_path() name = os.path.basename(path) - logger.info('Name was "{}"'.format(name)) + logger.debug('Name was "{}"'.format(name)) if path is not None and name == target_name: return pid except ValueError: pass except MemEditError as err: - logger.info(repr(err)) + logger.debug(repr(err)) logger.info('Found no process with name {}'.format(target_name)) return None