99# See https://aboutcode.org for more information about nexB OSS projects.
1010#
1111
12- from typing import Dict
12+ from pathlib import Path
13+ from typing import Dict , Optional
1314
1415import click
1516
@@ -174,7 +175,12 @@ def print_version(ctx, param, value):
174175 callback = print_version ,
175176 help = "Show the version and exit." ,
176177)
177- @click .option ("--ignore-errors" , is_flag = True , default = False , help = "Ignore errors and continue execution." )
178+ @click .option (
179+ "--ignore-errors" ,
180+ is_flag = True ,
181+ default = False ,
182+ help = "Ignore errors and continue execution." ,
183+ )
178184@click .help_option ("-h" , "--help" )
179185@click .option (
180186 "--generic-paths" ,
@@ -183,6 +189,11 @@ def print_version(ctx, param, value):
183189 help = "Use generic or truncated paths in the JSON output header and files sections. "
184190 "Used only for testing to avoid absolute paths and paths changing at each run." ,
185191)
192+ @click .option (
193+ "--log-file" ,
194+ type = click .Path (path_type = Path ),
195+ help = "Write logs to a file." ,
196+ )
186197def resolve_dependencies (
187198 ctx ,
188199 requirement_files ,
@@ -196,6 +207,7 @@ def resolve_dependencies(
196207 netrc_file ,
197208 max_rounds ,
198209 verbose ,
210+ log_file : Optional [Path ],
199211 use_cached_index = False ,
200212 use_pypi_json_api = False ,
201213 analyze_setup_py_insecurely = False ,
@@ -236,15 +248,15 @@ def resolve_dependencies(
236248
237249 # Setup verbose level
238250 if verbose >= 4 :
239- logging .setup_logger ("DEEP" )
251+ logging .setup_logger ("DEEP" , log_file = log_file )
240252 elif verbose == 3 :
241- logging .setup_logger ("TRACE" )
253+ logging .setup_logger ("TRACE" , log_file = log_file )
242254 elif verbose == 2 :
243- logging .setup_logger ("DEBUG" )
255+ logging .setup_logger ("DEBUG" , log_file = log_file )
244256 elif verbose == 1 :
245- logging .setup_logger ("INFO" )
257+ logging .setup_logger ("INFO" , log_file = log_file )
246258 else :
247- logging .setup_logger ()
259+ logging .setup_logger (log_file = log_file )
248260
249261 options = get_pretty_options (ctx , generic_paths = generic_paths )
250262
0 commit comments