99from gitingest .output_formatter import format_node
1010from gitingest .schemas import FileSystemNode , FileSystemNodeType , FileSystemStats
1111from gitingest .utils .ingestion_utils import _should_exclude , _should_include
12+ from gitingest .utils .logging_config import get_logger
1213
1314if TYPE_CHECKING :
1415 from gitingest .schemas import IngestionQuery
1516
17+ # Initialize logger for this module
18+ logger = get_logger (__name__ )
19+
1620
1721def ingest_query (query : IngestionQuery ) -> tuple [str , str , str ]:
1822 """Run the ingestion process for a parsed query.
@@ -111,7 +115,14 @@ def _process_node(node: FileSystemNode, query: IngestionQuery, stats: FileSystem
111115 _process_symlink (path = sub_path , parent_node = node , stats = stats , local_path = query .local_path )
112116 elif sub_path .is_file ():
113117 if sub_path .stat ().st_size > query .max_file_size :
114- print (f"Skipping file { sub_path } : would exceed max file size limit" )
118+ logger .warning (
119+ "Skipping file: would exceed max file size limit" ,
120+ extra = {
121+ "file_path" : str (sub_path ),
122+ "file_size" : sub_path .stat ().st_size ,
123+ "max_file_size" : query .max_file_size ,
124+ },
125+ )
115126 continue
116127 _process_file (path = sub_path , parent_node = node , stats = stats , local_path = query .local_path )
117128 elif sub_path .is_dir ():
@@ -133,7 +144,7 @@ def _process_node(node: FileSystemNode, query: IngestionQuery, stats: FileSystem
133144 node .file_count += child_directory_node .file_count
134145 node .dir_count += 1 + child_directory_node .dir_count
135146 else :
136- print ( f"Warning: { sub_path } is an unknown file type, skipping" )
147+ logger . warning ( "Unknown file type, skipping", extra = { "file_path" : str ( sub_path )} )
137148
138149 node .sort_children ()
139150
@@ -186,12 +197,27 @@ def _process_file(path: Path, parent_node: FileSystemNode, stats: FileSystemStat
186197
187198 """
188199 if stats .total_files + 1 > MAX_FILES :
189- print (f"Maximum file limit ({ MAX_FILES } ) reached" )
200+ logger .warning (
201+ "Maximum file limit reached" ,
202+ extra = {
203+ "current_files" : stats .total_files ,
204+ "max_files" : MAX_FILES ,
205+ "file_path" : str (path ),
206+ },
207+ )
190208 return
191209
192210 file_size = path .stat ().st_size
193211 if stats .total_size + file_size > MAX_TOTAL_SIZE_BYTES :
194- print (f"Skipping file { path } : would exceed total size limit" )
212+ logger .warning (
213+ "Skipping file: would exceed total size limit" ,
214+ extra = {
215+ "file_path" : str (path ),
216+ "file_size" : file_size ,
217+ "current_total_size" : stats .total_size ,
218+ "max_total_size" : MAX_TOTAL_SIZE_BYTES ,
219+ },
220+ )
195221 return
196222
197223 stats .total_files += 1
@@ -232,15 +258,33 @@ def limit_exceeded(stats: FileSystemStats, depth: int) -> bool:
232258
233259 """
234260 if depth > MAX_DIRECTORY_DEPTH :
235- print (f"Maximum depth limit ({ MAX_DIRECTORY_DEPTH } ) reached" )
261+ logger .warning (
262+ "Maximum directory depth limit reached" ,
263+ extra = {
264+ "current_depth" : depth ,
265+ "max_depth" : MAX_DIRECTORY_DEPTH ,
266+ },
267+ )
236268 return True
237269
238270 if stats .total_files >= MAX_FILES :
239- print (f"Maximum file limit ({ MAX_FILES } ) reached" )
271+ logger .warning (
272+ "Maximum file limit reached" ,
273+ extra = {
274+ "current_files" : stats .total_files ,
275+ "max_files" : MAX_FILES ,
276+ },
277+ )
240278 return True # TODO: end recursion
241279
242280 if stats .total_size >= MAX_TOTAL_SIZE_BYTES :
243- print (f"Maxumum total size limit ({ MAX_TOTAL_SIZE_BYTES / 1024 / 1024 :.1f} MB) reached" )
281+ logger .warning (
282+ "Maximum total size limit reached" ,
283+ extra = {
284+ "current_size_mb" : stats .total_size / 1024 / 1024 ,
285+ "max_size_mb" : MAX_TOTAL_SIZE_BYTES / 1024 / 1024 ,
286+ },
287+ )
244288 return True # TODO: end recursion
245289
246290 return False
0 commit comments