| 11 | |
| 12 | |
| 13 | def _set_logger() -> None: |
| 14 | global log |
| 15 | |
| 16 | parser = argparse.ArgumentParser() |
| 17 | parser.add_argument("-d", "--debug", action="store_true", help="Enable logging") |
| 18 | |
| 19 | args = parser.parse_args() |
| 20 | timestamp = datetime.now().strftime("%Y%m%d-%H%M%S") |
| 21 | log_file_path = path.join(gettempdir(), f"recoverpy-{timestamp}.log") |
| 22 | |
| 23 | logging.basicConfig( |
| 24 | level=logging.DEBUG if args.debug else logging.CRITICAL, |
| 25 | format="%(asctime)s - %(levelname)s - [%(threadName)s] - %(message)s", |
| 26 | handlers=( |
| 27 | [logging.FileHandler(log_file_path)] |
| 28 | if args.debug |
| 29 | else [logging.NullHandler()] |
| 30 | ), |
| 31 | ) |
| 32 | log = logging.getLogger() |
| 33 | |
| 34 | |
| 35 | def main() -> None: |