Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "rda_python_common"
version = "1.0.36"
version = "1.0.37"
authors = [
{ name="Zaihua Ji", email="zji@ucar.edu" },
]
Expand Down
16 changes: 7 additions & 9 deletions src/rda_python_common/PgLOG.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,23 +402,20 @@ def pglog(msg, logact = MSGLOG):
if logact&EMLLOG: logact &= ~EMLLOG
if not logact&ERRLOG: logact &= ~EMEROL

if msg: msg = msg.lstrip() # remove leading whitespaces for logging message

msg = msg.lstrip() if msg else '' # remove leading whitespaces for logging message
if logact&EXITLG:
ext = "Exit 1 in {}\n".format(os.getcwd())
if not msg:
msg = ext
else:
msg = msg.rstrip()
msg += "; " + ext
if msg: msg = msg.rstrip() + "; "
msg += ext
else:
if msg and not re.search(r'(\n|\r)$', msg): msg += "\n"
if logact&RETMSG: retmsg = msg

if logact&EMLALL:
if logact&SNDEML or not msg:
title = (msg if msg else "Message from {}-{}".format(PGLOG['HOSTNAME'], get_command()))
msg = send_email(title.rstrip())
msg = title + '\n' + msg
send_email(title.rstrip())
elif msg:
set_email(msg, logact)

Expand All @@ -428,7 +425,8 @@ def pglog(msg, logact = MSGLOG):
if not logact&EMLALL: set_email(msg, logact)
title = "ABORTS {}-{}".format(PGLOG['HOSTNAME'], get_command())
set_email((("ABORTS " + CPID['PID']) if CPID['PID'] else title), EMLTOP)
msg += send_email(title)
msg = title + '\n' + msg
send_email(title)

if logact&LOGERR: # make sure error is always logged
msg = break_long_string(msg)
Expand Down