UAL-RE / redata-commons

Commons code used by ReDATA codebases
MIT License
1 stars 2 forks source link

Allow script_end() to take an argument #35

Open jonathannoah opened 1 year ago

jonathannoah commented 1 year ago

The script_end() method currently emits a hard-coded "Exit 0" line to the log:

https://github.com/UAL-RE/redata-commons/blob/40acd5c587168bd0cc2aa656d1c303f097d43a94/redata/commons/logger.py#L183-L186

Adding a parameter to this function will allow the user to pass an exit code for the function to log in place of the default:

def script_end(self, exit_code=0):
    """Log end of script"""
    self.log.info(self.asterisk)
    self.log.info(f"Exit {exit_code}")

This is helpful if the user is calling sys.exit() to pass non-0 exit codes and wishes to record an accurate exit code in the log.