From a22737228772a76d577dd6af022bde28f4fb80bc Mon Sep 17 00:00:00 2001 From: David Brochart Date: Wed, 24 Apr 2024 16:34:45 +0200 Subject: [PATCH] Set watchfiles log level to WARNING (#403) --- plugins/contents/fps_contents/fileid.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/plugins/contents/fps_contents/fileid.py b/plugins/contents/fps_contents/fileid.py index f489c59d..e1b401ae 100644 --- a/plugins/contents/fps_contents/fileid.py +++ b/plugins/contents/fps_contents/fileid.py @@ -9,7 +9,9 @@ from jupyverse_api import Singleton -logger = logging.getLogger("contents") +contents_logger = logging.getLogger("contents") +watchfiles_logger = logging.getLogger("watchfiles") +watchfiles_logger.setLevel(logging.WARNING) class Watcher: @@ -110,13 +112,13 @@ async def watch_files(self): changed_path_str = str(changed_path) if change == Change.deleted: - logger.debug("File %s was deleted", changed_path_str) + contents_logger.debug("File %s was deleted", changed_path_str) async with db.execute( "SELECT COUNT(*) FROM fileids WHERE path = ?", (changed_path_str,) ) as cursor: if not (await cursor.fetchone())[0]: # path is not indexed, ignore - logger.debug( + contents_logger.debug( "File %s is not indexed, ignoring", changed_path_str ) continue @@ -125,12 +127,12 @@ async def watch_files(self): db, changed_path_str, deleted_paths, added_paths, False ) elif change == Change.added: - logger.debug("File %s was added", changed_path_str) + contents_logger.debug("File %s was added", changed_path_str) await maybe_rename( db, changed_path_str, added_paths, deleted_paths, True ) elif change == Change.modified: - logger.debug("File %s was modified", changed_path_str) + contents_logger.debug("File %s was modified", changed_path_str) if changed_path_str == self.db_path: continue async with db.execute( @@ -138,7 +140,7 @@ async def watch_files(self): ) as cursor: if not (await cursor.fetchone())[0]: # path is not indexed, ignore - logger.debug( + contents_logger.debug( "File %s is not indexed, ignoring", changed_path_str ) continue @@ -149,7 +151,7 @@ async def watch_files(self): ) for path in deleted_paths - added_paths: - logger.debug("Unindexing file %s ", path) + contents_logger.debug("Unindexing file %s ", path) await db.execute("DELETE FROM fileids WHERE path = ?", (path,)) await db.commit() @@ -203,7 +205,7 @@ async def maybe_rename( path1, path2 = changed_path, other_path if is_added_path: path1, path2 = path2, path1 - logger.debug("File %s was renamed to %s", path1, path2) + contents_logger.debug("File %s was renamed to %s", path1, path2) await db.execute("UPDATE fileids SET path = ? WHERE path = ?", (path2, path1)) other_paths.remove(other_path) return