Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature dtcenter/METplus-Internal#20 add user ID to log output #1771

Merged
merged 1 commit into from
Aug 30, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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