################################################################################
# Helper functions
################################################################################
+def get_time_prefix():
+ """ Return a string to use as a print prefix for output. Currently, a time string for the current time.
+ """
+ return "{} ".format(datetime.datetime.now().strftime("[%H:%M:%S]"))
+
def run_and_log(command, log_level=logging.DEBUG):
""" Return a command and log its output to the debug logger
Process return code
"""
- logging.log(log_level, "Invoking: %s", " ".join(command))
+ print_prefix = get_time_prefix()
+ logging.log(log_level, "%sInvoking: %s", print_prefix, " ".join(command))
proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
stdout_output, _ = proc.communicate()
for line in stdout_output.decode('utf-8', errors='replace').splitlines(): # There won't be any stderr output since it was piped to stdout
if not os.path.exists(filepath):
return
- logging.log(log_level, "============== Contents of %s", filepath)
+ logging.log(log_level, "%s============== Contents of %s", get_time_prefix(), filepath)
with open(filepath) as file_handle:
lines = file_handle.readlines()
for line in lines:
logging.log(log_level, line)
- logging.log(log_level, "============== End contents of %s", filepath)
+ logging.log(log_level, "%s============== End contents of %s", get_time_prefix(), filepath)
# Functions to verify the OS and architecture. They take an instance of CoreclrArguments,
# which is used to find the list of legal OS and architectures
print_prefix = ""
if self.verbose:
- print_prefix = "[{}:{}]: ".format(index, size)
+ print_prefix = "{}[{}:{}]: ".format(get_time_prefix(), index, size)
await async_callback(print_prefix, item, *extra_args)
tasks.append(self.__get_item__(item, count, size, async_callback, *extra_args))
count += 1
- # Inovke all the calls to __get_item__ concurrently and wait for them all to finish.
+ # Invoke all the calls to __get_item__ concurrently and wait for them all to finish.
await asyncio.gather(*tasks)
def run_to_completion(self, async_callback, *extra_args):
complus_env["ZapDisable"] = "1"
complus_env["ReadyToRun"] = "0"
- logging.debug("Starting collection.")
+ logging.debug("%sStarting collection.", get_time_prefix())
logging.debug("")
def set_and_report_env(env, root_env, complus_env = None):
################################################################################################ Do collection using given collection command (e.g., script)
if self.collection_command is not None:
- logging.debug("Starting collection using command")
+ logging.debug("%sStarting collection using command", get_time_prefix())
collection_command_env = env_copy.copy()
collection_complus_env = complus_env.copy()
################################################################################################ Do collection using PMI
if self.coreclr_args.pmi is True:
- logging.debug("Starting collection using PMI")
+ logging.debug("%sStarting collection using PMI", get_time_prefix())
async def run_pmi(print_prefix, assembly, self):
""" Run pmi over all dlls
################################################################################################ Do collection using crossgen2
if self.coreclr_args.crossgen2 is True:
- logging.debug("Starting collection using crossgen2")
+ logging.debug("%sStarting collection using crossgen2", get_time_prefix())
async def run_crossgen2(print_prefix, assembly, self):
""" Run crossgen2 over all dlls