9
9
10
10
from jupyverse_api import Singleton
11
11
12
- logger = logging .getLogger ("contents" )
12
+ contents_logger = logging .getLogger ("contents" )
13
+ watchfiles_logger = logging .getLogger ("watchfiles" )
14
+ watchfiles_logger .setLevel (logging .WARNING )
13
15
14
16
15
17
class Watcher :
@@ -110,13 +112,13 @@ async def watch_files(self):
110
112
changed_path_str = str (changed_path )
111
113
112
114
if change == Change .deleted :
113
- logger .debug ("File %s was deleted" , changed_path_str )
115
+ contents_logger .debug ("File %s was deleted" , changed_path_str )
114
116
async with db .execute (
115
117
"SELECT COUNT(*) FROM fileids WHERE path = ?" , (changed_path_str ,)
116
118
) as cursor :
117
119
if not (await cursor .fetchone ())[0 ]:
118
120
# path is not indexed, ignore
119
- logger .debug (
121
+ contents_logger .debug (
120
122
"File %s is not indexed, ignoring" , changed_path_str
121
123
)
122
124
continue
@@ -125,20 +127,20 @@ async def watch_files(self):
125
127
db , changed_path_str , deleted_paths , added_paths , False
126
128
)
127
129
elif change == Change .added :
128
- logger .debug ("File %s was added" , changed_path_str )
130
+ contents_logger .debug ("File %s was added" , changed_path_str )
129
131
await maybe_rename (
130
132
db , changed_path_str , added_paths , deleted_paths , True
131
133
)
132
134
elif change == Change .modified :
133
- logger .debug ("File %s was modified" , changed_path_str )
135
+ contents_logger .debug ("File %s was modified" , changed_path_str )
134
136
if changed_path_str == self .db_path :
135
137
continue
136
138
async with db .execute (
137
139
"SELECT COUNT(*) FROM fileids WHERE path = ?" , (changed_path_str ,)
138
140
) as cursor :
139
141
if not (await cursor .fetchone ())[0 ]:
140
142
# path is not indexed, ignore
141
- logger .debug (
143
+ contents_logger .debug (
142
144
"File %s is not indexed, ignoring" , changed_path_str
143
145
)
144
146
continue
@@ -149,7 +151,7 @@ async def watch_files(self):
149
151
)
150
152
151
153
for path in deleted_paths - added_paths :
152
- logger .debug ("Unindexing file %s " , path )
154
+ contents_logger .debug ("Unindexing file %s " , path )
153
155
await db .execute ("DELETE FROM fileids WHERE path = ?" , (path ,))
154
156
await db .commit ()
155
157
@@ -203,7 +205,7 @@ async def maybe_rename(
203
205
path1 , path2 = changed_path , other_path
204
206
if is_added_path :
205
207
path1 , path2 = path2 , path1
206
- logger .debug ("File %s was renamed to %s" , path1 , path2 )
208
+ contents_logger .debug ("File %s was renamed to %s" , path1 , path2 )
207
209
await db .execute ("UPDATE fileids SET path = ? WHERE path = ?" , (path2 , path1 ))
208
210
other_paths .remove (other_path )
209
211
return
0 commit comments