1818# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919#
2020
21+ import logging
2122from pysonar_scanner import app_logging
2223from pysonar_scanner import cache
2324from pysonar_scanner import exceptions
@@ -48,22 +49,21 @@ def scan():
4849
4950def do_scan ():
5051 app_logging .setup ()
51- app_logging . get_logger () .info ("Starting Pysonar, the Sonar scanner CLI for Python" )
52+ logging .info ("Starting Pysonar, the Sonar scanner CLI for Python" )
5253 config = ConfigurationLoader .load ()
5354 set_logging_options (config )
54- app_logging .get_logger ().debug (f"Loaded configuration: { config } " )
5555
5656 ConfigurationLoader .check_configuration (config )
5757
5858 api = build_api (config )
5959 check_version (api )
6060 update_config_with_api_urls (config , api .base_urls )
61- app_logging . get_logger (). debug (f"Configuration after update from API URL : { config } " )
61+ logging . debug (f"Final loaded configuration : { config } " )
6262
6363 cache_manager = cache .get_cache (config )
6464 scanner = create_scanner_engine (api , cache_manager , config )
6565
66- app_logging . get_logger () .info ("Starting the analysis..." )
66+ logging .info ("Starting the analysis..." )
6767 return scanner .run (config )
6868
6969
@@ -78,12 +78,12 @@ def build_api(config: dict[str, any]) -> SonarQubeApi:
7878
7979
8080def check_version (api : SonarQubeApi ):
81- app_logging .get_logger ().info ("Checking SonarQube version..." )
8281 if api .is_sonar_qube_cloud ():
83- app_logging . get_logger (). info ( "Analysis will be run on SonarQube Cloud" )
82+ logging . debug ( f" SonarQube Cloud url: { api . base_urls . base_url } " )
8483 return
8584 version = api .get_analysis_version ()
86- app_logging .get_logger ().info ("Analysis will be run on SonarQube version %s" , version )
85+ logging .debug (f"SonarQube url: { api .base_urls .base_url } " )
86+
8787 if not version .does_support_bootstrapping ():
8888 raise SQTooOldException (
8989 f"This scanner only supports SonarQube versions >= { MIN_SUPPORTED_SQ_VERSION } . \n "
@@ -101,10 +101,9 @@ def update_config_with_api_urls(config, base_urls: BaseUrls):
101101
102102
103103def create_scanner_engine (api , cache_manager , config ):
104- app_logging .get_logger ().info ("Creating the scanner engine..." )
105104 jre_path = create_jre (api , cache_manager , config )
106105 config [SONAR_SCANNER_JAVA_EXE_PATH ] = str (jre_path .path )
107- app_logging . get_logger () .debug (f"JRE path: { jre_path .path } " )
106+ logging .debug (f"JRE path: { jre_path .path } " )
108107 scanner_engine_path = ScannerEngineProvisioner (api , cache_manager ).provision ()
109108 scanner = ScannerEngine (jre_path , scanner_engine_path )
110109 return scanner
0 commit comments