Skip to content

Commit 621ad93

Browse files
author
Petty Dev Tigris
committed
Harrison 2721 - PMCL/SWYN - Remove old logging system of uploading a log file, include timestamps in logs
1 parent 84cd6fd commit 621ad93

1 file changed

Lines changed: 4 additions & 22 deletions

File tree

imap_l3_data_processor.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from imap_l3_processing.swe.swe_processor import SweProcessor
2222
from imap_l3_processing.ultra.l3.ultra_processor import UltraProcessor
2323

24+
logger = logging.getLogger(__name__)
2425

2526
def _parse_cli_arguments():
2627
parser = argparse.ArgumentParser()
@@ -111,30 +112,11 @@ def _furnish_spice_kernels(processing_input_collection):
111112

112113
if __name__ == '__main__':
113114
with TemporaryDirectory() as dir:
114-
args = _parse_cli_arguments()
115-
logger = logging.getLogger('application')
116-
logger.setLevel(logging.INFO)
117-
118-
log_path = Path(
119-
dir) / f"imap_{args.instrument}_{args.data_level}_log-{datetime.now().strftime('%Y-%m-%d-%H%M%S-%f')}_{args.start_date}_v001.cdf"
120-
fh = logging.FileHandler(str(log_path))
121-
122-
fh.setLevel(logging.INFO)
123-
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
124-
fh.setFormatter(formatter)
125-
logger.addHandler(fh)
115+
logging.basicConfig(force=True, level=logging.INFO,
116+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
126117

127118
try:
128119
imap_l3_processor()
129120
except Exception as e:
130-
logger.info("Unhandled Exception:", exc_info=e)
131-
print("caught exception")
132-
traceback.print_exc()
133-
logging.shutdown()
121+
logger.error("Unhandled Exception:")
134122
raise e
135-
finally:
136-
should_upload_log = False
137-
if should_upload_log and os.path.exists(log_path) and os.path.getsize(log_path) > 0:
138-
imap_data_access.upload(log_path)
139-
140-
logging.shutdown()

0 commit comments

Comments
 (0)