diff options
author | Matthieu Coudron <mcoudron@hotmail.com> | 2021-05-15 14:16:00 +0200 |
---|---|---|
committer | Matthieu Coudron <mcoudron@hotmail.com> | 2021-05-17 00:40:25 +0200 |
commit | 0a9e9c09659dff66f40829d5161b8b71931dbeee (patch) | |
tree | 97bc0f65bdb23765610acc7823e86fb73ed35677 /maintainers | |
parent | 8c63ac789359e1a0a7199229809bdd0673752805 (diff) |
pkgs/misc/vim-plugins/update.py: add logging
there was a 404 error, having basic logging makes it easier to troubleshoot
Diffstat (limited to 'maintainers')
-rw-r--r-- | maintainers/scripts/pluginupdate.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/maintainers/scripts/pluginupdate.py b/maintainers/scripts/pluginupdate.py index e7a183952b085..91c5214d15394 100644 --- a/maintainers/scripts/pluginupdate.py +++ b/maintainers/scripts/pluginupdate.py @@ -13,6 +13,7 @@ import http import json import os import subprocess +import logging import sys import time import traceback @@ -34,6 +35,14 @@ ATOM_ENTRY = "{http://www.w3.org/2005/Atom}entry" # " vim gets confused here ATOM_LINK = "{http://www.w3.org/2005/Atom}link" # " ATOM_UPDATED = "{http://www.w3.org/2005/Atom}updated" # " +LOG_LEVELS = { + logging.getLevelName(level): level for level in [ + logging.DEBUG, logging.INFO, logging.WARN, logging.ERROR ] +} + +log = logging.getLogger() +log.addHandler(logging.StreamHandler()) + def retry(ExceptionToCheck: Any, tries: int = 4, delay: float = 3, backoff: float = 2): """Retry calling the decorated function using an exponential backoff. @@ -235,6 +244,7 @@ def prefetch_plugin( alias: Optional[str], cache: "Optional[Cache]" = None, ) -> Tuple[Plugin, Dict[str, str]]: + log.info("Prefetching plugin %s", repo_name) repo = Repo(user, repo_name, branch, alias) commit, date = repo.latest_commit() has_submodules = repo.has_submodules() @@ -464,6 +474,11 @@ def parse_args(editor: Editor): "--no-commit", "-n", action="store_true", default=False, help="Whether to autocommit changes" ) + parser.add_argument( + "--debug", "-d", choices=LOG_LEVELS.keys(), + default=logging.getLevelName(logging.WARN), + help="Adjust log level" + ) return parser.parse_args() @@ -503,6 +518,9 @@ def update_plugins(editor: Editor): """The main entry function of this module. All input arguments are grouped in the `Editor`.""" args = parse_args(editor) + log.setLevel(LOG_LEVELS[args.debug]) + + log.info("Start updating plugins") nixpkgs_repo = git.Repo(editor.root, search_parent_directories=True) update = get_update(args.input_file, args.outfile, args.proc, editor) |