From 3a21fd80daa0f447f71bf9669abcbe86b78f7f84 Mon Sep 17 00:00:00 2001 From: George McCabe <23407799+georgemccabe@users.noreply.github.com> Date: Mon, 29 Aug 2022 15:48:11 -0600 Subject: [PATCH] per dtcenter/METplus-Internal#20, add user ID to beginning and end of log output --- metplus/util/met_util.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/metplus/util/met_util.py b/metplus/util/met_util.py index 7b458cec93..c904d58459 100644 --- a/metplus/util/met_util.py +++ b/metplus/util/met_util.py @@ -39,9 +39,14 @@ def pre_run_setup(config_inputs): logger = config.logger + try: + uid = f' as user {os.getuid()} ' + except AttributeError: + uid = ' ' + config.set('config', 'METPLUS_VERSION', version_number) - logger.info('Running METplus v%s called with command: %s', - version_number, ' '.join(sys.argv)) + logger.info('Running METplus v%s%swith command: %s', + version_number, uid, ' '.join(sys.argv)) logger.info(f"Log file: {config.getstr('config', 'LOG_METPLUS')}") logger.info(f"METplus Base: {config.getdir('METPLUS_BASE')}") @@ -197,12 +202,17 @@ def post_run_cleanup(config, app_name, total_errors): total_run_time = end_clock_time - start_clock_time logger.debug(f"{app_name} took {total_run_time} to run.") + try: + uid = f' as user {os.getuid()}' + except AttributeError: + uid = '' + if not total_errors: logger.info(log_message) - logger.info(f'{app_name} has successfully finished running.') + logger.info('%s has successfully finished running%s.', app_name, uid) return - error_msg = f"{app_name} has finished running but had {total_errors} error" + error_msg = f"{app_name} has finished running{uid} but had {total_errors} error" if total_errors > 1: error_msg += 's' error_msg += '.'