Skip to content

Commit

Permalink
Merge pull request mbari-org#241 from MBARIMike/main
Browse files Browse the repository at this point in the history
Replace --append_to_log_file with --clobber_log_file & adjust logic
  • Loading branch information
MBARIMike authored May 30, 2024
2 parents 9fbe267 + aec54b0 commit d7274f2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions smdb/scripts/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ def process_command_line(self):
help=f"Read or write a .xlsx or .csv file for the direct sub-directory of {MBARI_DIR}",
)
parser.add_argument(
"--append_to_log_file",
"--clobber_log_file",
action="store_true",
help="Append to existing log file",
help="Remove existing log file and start a new one",
)

self.args = parser.parse_args() # noqa
Expand All @@ -233,7 +233,7 @@ def process_command_line(self):
if not self.logger.handlers:
# Don't add handlers when sub class runs
stream_handler = logging.StreamHandler()
if os.path.exists(self.LOCAL_LOG_FILE) and not self.args.append_to_log_file:
if os.path.exists(self.LOCAL_LOG_FILE) and self.args.clobber_log_file:
os.remove(self.LOCAL_LOG_FILE)
file_handler = logging.FileHandler(self.LOCAL_LOG_FILE)
stream_handler.setFormatter(_formatter)
Expand All @@ -248,10 +248,10 @@ def process_command_line(self):
if line.startswith("/mbari/SeafloorMapping/"):
self.exclude_paths.append(line.strip())

if self.args.append_to_log_file:
self.logger.debug("Appending to local log file: %s", self.LOCAL_LOG_FILE)
else:
if self.args.clobber_log_file:
self.logger.info("Saving to new local log file: %s", self.LOCAL_LOG_FILE)
else:
self.logger.debug("Appending to local log file: %s", self.LOCAL_LOG_FILE)
self.logger.debug(
"Using database at DATABASE_URL = %s", os.environ["DATABASE_URL"]
)
Expand Down

0 comments on commit d7274f2

Please sign in to comment.