Created
August 2, 2022 13:56
-
-
Save thiborose/3d00f51a2fe458bf72ede102c45ca554 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = "xxxx" | |
| __version__ = "0.0.0" | |
| __date__ = "January 01, 2000" | |
| import sys, argparse | |
| from loguru import logger | |
| # code.... | |
| # ... | |
| # ... | |
| def main(args): | |
| pass | |
| if __name__ == "__main__": | |
| version = f"xx {__version__} ({__date__})\n\n" | |
| # argparse setup | |
| parser = argparse.ArgumentParser(description=version) | |
| # arguments here.... | |
| parser.add_argument('--debug', action='store_true', help='Log level goes to debug') | |
| args = parser.parse_args() | |
| # logging setup | |
| log_level = "DEBUG" if args.debug else "INFO" | |
| logger.remove() | |
| logger.add("logs.txt", level=log_level, rotation="4MB") | |
| logger.add(sys.stdout, level=log_level) | |
| main(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment