370370################################################################################
371371# Helper functions
372372################################################################################
373+ def get_time_prefix ():
374+ """ Return a string to use as a print prefix for output. Currently, a time string for the current time.
375+ """
376+ return "{} " .format (datetime .datetime .now ().strftime ("[%H:%M:%S]" ))
377+
373378def run_and_log (command , log_level = logging .DEBUG ):
374379 """ Return a command and log its output to the debug logger
375380
@@ -381,7 +386,8 @@ def run_and_log(command, log_level=logging.DEBUG):
381386 Process return code
382387 """
383388
384- logging .log (log_level , "Invoking: %s" , " " .join (command ))
389+ print_prefix = get_time_prefix ()
390+ logging .log (log_level , "%sInvoking: %s" , print_prefix , " " .join (command ))
385391 proc = subprocess .Popen (command , stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
386392 stdout_output , _ = proc .communicate ()
387393 for line in stdout_output .decode ('utf-8' , errors = 'replace' ).splitlines (): # There won't be any stderr output since it was piped to stdout
@@ -402,15 +408,15 @@ def write_file_to_log(filepath, log_level=logging.DEBUG):
402408 if not os .path .exists (filepath ):
403409 return
404410
405- logging .log (log_level , "============== Contents of %s" , filepath )
411+ logging .log (log_level , "%s ============== Contents of %s" , get_time_prefix () , filepath )
406412
407413 with open (filepath ) as file_handle :
408414 lines = file_handle .readlines ()
409415 lines = [item .strip () for item in lines ]
410416 for line in lines :
411417 logging .log (log_level , line )
412418
413- logging .log (log_level , "============== End contents of %s" , filepath )
419+ logging .log (log_level , "%s ============== End contents of %s" , get_time_prefix () , filepath )
414420
415421# Functions to verify the OS and architecture. They take an instance of CoreclrArguments,
416422# which is used to find the list of legal OS and architectures
@@ -502,7 +508,7 @@ async def __get_item__(self, item, index, size, async_callback, *extra_args):
502508
503509 print_prefix = ""
504510 if self .verbose :
505- print_prefix = "[{}:{}]: " .format (index , size )
511+ print_prefix = "{} [{}:{}]: " .format (get_time_prefix (), index , size )
506512
507513 await async_callback (print_prefix , item , * extra_args )
508514
@@ -531,7 +537,7 @@ async def __run_to_completion__(self, async_callback, *extra_args):
531537 tasks .append (self .__get_item__ (item , count , size , async_callback , * extra_args ))
532538 count += 1
533539
534- # Inovke all the calls to __get_item__ concurrently and wait for them all to finish.
540+ # Invoke all the calls to __get_item__ concurrently and wait for them all to finish.
535541 await asyncio .gather (* tasks )
536542
537543 def run_to_completion (self , async_callback , * extra_args ):
@@ -731,7 +737,7 @@ def __collect_mc_files__(self):
731737 complus_env ["ZapDisable" ] = "1"
732738 complus_env ["ReadyToRun" ] = "0"
733739
734- logging .debug ("Starting collection." )
740+ logging .debug ("%sStarting collection." , get_time_prefix () )
735741 logging .debug ("" )
736742
737743 def set_and_report_env (env , root_env , complus_env = None ):
@@ -760,7 +766,7 @@ def set_and_report_env(env, root_env, complus_env = None):
760766
761767 ################################################################################################ Do collection using given collection command (e.g., script)
762768 if self .collection_command is not None :
763- logging .debug ("Starting collection using command" )
769+ logging .debug ("%sStarting collection using command" , get_time_prefix () )
764770
765771 collection_command_env = env_copy .copy ()
766772 collection_complus_env = complus_env .copy ()
@@ -782,7 +788,7 @@ def set_and_report_env(env, root_env, complus_env = None):
782788
783789 ################################################################################################ Do collection using PMI
784790 if self .coreclr_args .pmi is True :
785- logging .debug ("Starting collection using PMI" )
791+ logging .debug ("%sStarting collection using PMI" , get_time_prefix () )
786792
787793 async def run_pmi (print_prefix , assembly , self ):
788794 """ Run pmi over all dlls
@@ -854,7 +860,7 @@ async def run_pmi(print_prefix, assembly, self):
854860
855861 ################################################################################################ Do collection using crossgen2
856862 if self .coreclr_args .crossgen2 is True :
857- logging .debug ("Starting collection using crossgen2" )
863+ logging .debug ("%sStarting collection using crossgen2" , get_time_prefix () )
858864
859865 async def run_crossgen2 (print_prefix , assembly , self ):
860866 """ Run crossgen2 over all dlls
0 commit comments