From afd1e5b25794672bed4ef71e7c046b33ddac4e58 Mon Sep 17 00:00:00 2001 From: Phong Tran Date: Mon, 2 Dec 2024 12:24:06 -0600 Subject: [PATCH] SVCPLAN-6428: Modify error handling --- OutlookCalendar.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OutlookCalendar.py b/OutlookCalendar.py index 7ac2600..8972e43 100644 --- a/OutlookCalendar.py +++ b/OutlookCalendar.py @@ -12,7 +12,8 @@ from msal import PublicClientApplication import IndividualCalendar import GenerateReport - +import sys + def process_args(): parser = argparse.ArgumentParser( prog = 'vacation_calendar_sync', @@ -138,6 +139,9 @@ def main(configs): time.sleep(configs['update_interval']) if __name__ == '__main__': + # Redirects stdout stderr to out.log + sys.stderr = open('out.log', 'w') + configs = utils.get_configurations() formater = logging.Formatter('%(name)s:%(asctime)s:%(filename)s:%(levelname)s:%(message)s') @@ -153,7 +157,7 @@ def main(configs): logger.setLevel(logging.DEBUG) logger.addHandler(rotate_file_handler_info) - stream_handler = logging.StreamHandler() + stream_handler = logging.StreamHandler(sys.stderr) stream_handler.setLevel(logging.DEBUG) stream_handler.setFormatter(fmt=logging.Formatter('%(name)s:%(asctime)s:%(filename)s:%(levelname)s:%(message)s')) logger.addHandler(stream_handler)