From c318a629419fc7f9a38a11054a906ae7fe56c9e4 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Wed, 8 Mar 2023 22:11:29 +0100 Subject: [PATCH] logging --- catcli/catcli.py | 2 -- catcli/fuser.py | 12 ------------ catcli/logger.py | 13 ------------- catcli/walker.py | 9 --------- 4 files changed, 36 deletions(-) diff --git a/catcli/catcli.py b/catcli/catcli.py index 87c65a9..65da0d6 100755 --- a/catcli/catcli.py +++ b/catcli/catcli.py @@ -112,8 +112,6 @@ def cmd_index(args: Dict[str, Any], Logger.err('aborted') return node = noder.get_storage_node(top, name) - Logger.debug(f'top node: {top}') - Logger.debug(f'storage node: {node}') node.parent = None start = datetime.datetime.now() diff --git a/catcli/fuser.py b/catcli/fuser.py index 177c075..6f220a5 100644 --- a/catcli/fuser.py +++ b/catcli/fuser.py @@ -6,7 +6,6 @@ fuse for catcli """ import os -import logging from time import time from stat import S_IFDIR, S_IFREG from typing import List, Dict, Any, Optional @@ -19,14 +18,6 @@ from catcli.utils import path_to_search_all, path_to_top from catcli import nodes -# build custom logger to log in /tmp -logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) -fh = logging.FileHandler('/tmp/fuse-catcli.log') -fh.setLevel(logging.DEBUG) -logger.addHandler(fh) - - class Fuser: """fuse filesystem mounter""" @@ -114,8 +105,6 @@ class CatcliFilesystem(fuse.LoggingMixIn, fuse.Operations): # type: ignore def getattr(self, path: str, _fh: Any = None) -> Dict[str, Any]: """return attr of file pointed by path""" - logger.info('getattr path: %s', path) - if path == '/': # mountpoint curt = time() @@ -135,7 +124,6 @@ class CatcliFilesystem(fuse.LoggingMixIn, fuse.Operations): # type: ignore def readdir(self, path: str, _fh: Any) -> List[str]: """read directory content""" - logger.info('readdir path: %s', path) content = ['.', '..'] entries = self._get_entries(path) for entry in entries: diff --git a/catcli/logger.py b/catcli/logger.py index b56cabe..645b6ba 100644 --- a/catcli/logger.py +++ b/catcli/logger.py @@ -69,16 +69,3 @@ class Logger: """make it bold""" string = fix_badchars(string) return f'{Colors.BOLD}{string}{Colors.RESET}' - - @classmethod - def log_to_file(cls: Type[CLASSTYPE], - path: str, - string: str, - append: bool = True) -> None: - """log to file""" - string = fix_badchars(string) - mode = 'w' - if append: - mode = 'a' - with open(path, mode, encoding='UTF-8') as file: - file.write(string) diff --git a/catcli/walker.py b/catcli/walker.py index ee93b4b..5942a5b 100644 --- a/catcli/walker.py +++ b/catcli/walker.py @@ -118,7 +118,6 @@ class Walker: if node: node.flag() continue - self._log2file(f'update catalog for \"{sub}\"') node = self.noder.new_file_node(os.path.basename(file), sub, parent, storagepath) if node: @@ -131,7 +130,6 @@ class Walker: treepath = os.path.join(storagepath, adir) reindex, dummy = self._need_reindex(parent, sub, treepath) if reindex: - self._log2file(f'update catalog for \"{sub}\"') dummy = self.noder.new_dir_node(base, sub, parent, storagepath) cnt += 1 @@ -189,10 +187,3 @@ class Walker: if len(string) > self.MAXLINELEN: string = string[:self.MAXLINELEN] + '...' Logger.progr(f'indexing: {string:80}') - - def _log2file(self, string: str) -> None: - """log to file""" - if not self.lpath: - return - line = f'{string}\n' - Logger.log_to_file(self.lpath, line, append=True)