Skip to content

Commit

Permalink
Allow for log path (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAplin committed Sep 10, 2024
1 parent aefa665 commit ca67fe9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nndownload/nndownload.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
cmdl_parser.add_argument("--session-cookie", dest="session_cookie", metavar="COOKIE", help="user_session cookie value (string or filepath)")
cmdl_parser.add_argument("-n", "--netrc", action="store_true", dest="netrc", help="use .netrc authentication")
cmdl_parser.add_argument("-q", "--quiet", action="store_true", dest="quiet", help="suppress output to console")
cmdl_parser.add_argument("-l", "--log", action="store_true", dest="log", help="log output to file")
cmdl_parser.add_argument("-l", "--log", nargs="?", const=f"[{MODULE_NAME}] {time.strftime('%Y-%m-%d')}.log", dest="log", metavar="[PATH]", help="log output to file")
cmdl_parser.add_argument("-v", "--version", action="version", version=CMDL_VERSION)
cmdl_parser.add_argument("input", action="store", nargs="*", help="URLs or files")

Expand Down Expand Up @@ -257,7 +257,7 @@ def configure_logger():

if _CMDL_OPTS.log:
logger.setLevel(logging.INFO)
log_handler = logging.FileHandler(f"[{MODULE_NAME}] {time.strftime('%Y-%m-%d')}.log", encoding="utf-8")
log_handler = logging.FileHandler(_CMDL_OPTS.log, encoding="utf-8")
formatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s")
log_handler.setFormatter(formatter)
logger.addHandler(log_handler)
Expand Down

0 comments on commit ca67fe9

Please sign in to comment.