Skip to Content

O_ops: Better Logging To Solve Problems

Logging helps in pinpointing the code block that threw an error. Only if they are used correctly. During once such failure, a guy noticed that a script lacked logging and ever promptly promoted the updated script with better logging. A part of the script is shown below.

Script before:

1>>${LOG} 2>>${ERRLOG} ${BINPATH}/${PROGRAMNAME}
if [ $? -ne 0 ]; then
  print "ERROR: Something failed"
  exit 101
fi

Script after:

1>>${LOG} 2>>${ERRLOG} ${BINPATH}/${PROGRAMNAME}
echo "Program completed successfully."
if [ $? -ne 0 ]; then
  print "ERROR: Something failed"
  exit 101
fi

The change made it a “better” script for sure - it never failed again!

Thank You!

Your comment has been submitted. It will appear on this page shortly! OK

Yikes, Sorry!

Error occured. Couldn't submit your comment. Please try again. Thank You! OK

Leave a comment