Skip to content

Commit

Permalink
feature dtcenter/METplus-Internal#20 add user ID to log output (#1771)
Browse files Browse the repository at this point in the history
  • Loading branch information
georgemccabe authored Aug 30, 2022
1 parent e8804eb commit 9216c6b
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions metplus/util/met_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')}")
Expand Down Expand Up @@ -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 += '.'
Expand Down

0 comments on commit 9216c6b

Please sign in to comment.