77from cycode .cli .models import Document
88from cycode .cli .utils .path_utils import get_file_content , get_file_dir , get_path_from_context , join_paths
99from cycode .cli .utils .shell_executor import shell
10+ from cycode .logger import get_logger
11+
12+ logger = get_logger ('SCA Restore' )
1013
1114
1215def build_dep_tree_path (path : str , generated_file_name : str ) -> str :
@@ -19,6 +22,16 @@ def execute_commands(
1922 output_file_path : Optional [str ] = None ,
2023 working_directory : Optional [str ] = None ,
2124) -> Optional [str ]:
25+ logger .debug (
26+ 'Executing restore commands, %s' ,
27+ {
28+ 'commands_count' : len (commands ),
29+ 'timeout_sec' : timeout ,
30+ 'working_directory' : working_directory ,
31+ 'output_file_path' : output_file_path ,
32+ },
33+ )
34+
2235 try :
2336 outputs = []
2437
@@ -32,7 +45,8 @@ def execute_commands(
3245 if output_file_path :
3346 with open (output_file_path , 'w' , encoding = 'UTF-8' ) as output_file :
3447 output_file .writelines (joined_output )
35- except Exception :
48+ except Exception as e :
49+ logger .debug ('Unexpected error during command execution' , exc_info = e )
3650 return None
3751
3852 return joined_output
@@ -75,8 +89,21 @@ def try_restore_dependencies(self, document: Document) -> Optional[Document]:
7589 )
7690 if output is None : # one of the commands failed
7791 return None
92+ else :
93+ logger .debug (
94+ 'Lock file already exists, skipping restore commands, %s' ,
95+ {'restore_file_path' : restore_file_path },
96+ )
7897
7998 restore_file_content = get_file_content (restore_file_path )
99+ logger .debug (
100+ 'Restore file loaded, %s' ,
101+ {
102+ 'restore_file_path' : restore_file_path ,
103+ 'content_size' : len (restore_file_content ) if restore_file_content else 0 ,
104+ 'content_empty' : not restore_file_content ,
105+ },
106+ )
80107 return Document (relative_restore_file_path , restore_file_content , self .is_git_diff )
81108
82109 def get_working_directory (self , document : Document ) -> Optional [str ]:
0 commit comments