From 4480ea21acc131b6f0074f137bba9c297c04155a Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 21 May 2020 12:45:28 +0530 Subject: [PATCH 1/3] chore(logging) set logging level to INFO --- bench/app.py | 1 + bench/utils.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bench/app.py b/bench/app.py index 1c873c77..3946ec59 100755 --- a/bench/app.py +++ b/bench/app.py @@ -127,6 +127,7 @@ Do you want to continue and overwrite it?'''.format(repo_name)): install_app(app=app_name, bench_path=bench_path, verbose=verbose, skip_assets=skip_assets) sys.exit() + print('\n{0}Getting {1}{2}'.format(color.yellow, repo_name, color.nc)) logger.log('Getting app {0}'.format(repo_name)) exec_cmd("git clone {git_url} {branch} {shallow_clone} --origin upstream".format( git_url=git_url, diff --git a/bench/utils.py b/bench/utils.py index abcf2d2e..92044745 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -455,7 +455,7 @@ def setup_logging(bench_path='.'): logger.addHandler(hdlr) logger.addHandler(log_hndlr) - logger.setLevel(logging.DEBUG) + logger.setLevel(logging.INFO) return logger From 7dc5fdb7b3041d5a6258f8ddfc254b2dc6955605 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 21 May 2020 13:14:16 +0530 Subject: [PATCH 2/3] chore: update APIs, remove duplicate logs --- bench/cli.py | 6 ++++-- bench/utils.py | 13 ++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/bench/cli.py b/bench/cli.py index 0cc53310..bf0b5231 100755 --- a/bench/cli.py +++ b/bench/cli.py @@ -59,8 +59,10 @@ def cli(): try: bench_command() except BaseException as e: - logger.warn("{0} executed with exit code {1}".format(command, getattr(e, "code", None))) - sys.exit(1) + return_code = getattr(e, "code", 0) + if return_code: + logger.warning("{0} executed with exit code {1}".format(command, return_code)) + sys.exit(return_code) def check_uid(): diff --git a/bench/utils.py b/bench/utils.py index 92044745..749a6e18 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -302,7 +302,7 @@ def exec_cmd(cmd, cwd='.'): cmd = shlex.split(cmd) return_code = subprocess.call(cmd, cwd=cwd, universal_newlines=True) if return_code: - logger.warn("{0} executed with exit code {1}".format(cmd_log, return_code)) + logger.warning("{0} executed with exit code {1}".format(cmd_log, return_code)) def which(executable, raise_err = False): @@ -449,13 +449,8 @@ def setup_logging(bench_path='.'): hdlr = logging.FileHandler(log_file) hdlr.setFormatter(formatter) - log_hndlr = logging.StreamHandler(sys.stdout) - log_hndlr.setFormatter(logging.Formatter('%(message)s')) - log_hndlr.addFilter(log_filter(LOG_LEVEL)) - logger.addHandler(hdlr) - logger.addHandler(log_hndlr) - logger.setLevel(logging.INFO) + logger.setLevel(logging.DEBUG) return logger @@ -985,7 +980,7 @@ def migrate_env(python, backup=False): logger.log('Clearing Redis DataBase...') exec_cmd('{redis} FLUSHDB'.format(redis = redis)) except: - logger.warn('Please ensure Redis Connections are running or Daemonized.') + logger.warning('Please ensure Redis Connections are running or Daemonized.') # Backup venv: restore using `virtualenv --relocatable` if needed if backup: @@ -1015,7 +1010,7 @@ def migrate_env(python, backup=False): logger.log('Migration Successful to {}'.format(python)) except: if venv_creation or packages_setup: - logger.warn('Migration Error') + logger.warning('Migration Error') def is_dist_editable(dist): From 0ba5a09975129b2cd926f5419cf47eea3e5e2279 Mon Sep 17 00:00:00 2001 From: Gavin D'souza Date: Thu, 21 May 2020 13:15:19 +0530 Subject: [PATCH 3/3] chore: remove unused class --- bench/utils.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/bench/utils.py b/bench/utils.py index 749a6e18..7914eecd 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -435,20 +435,12 @@ def setup_logging(bench_path='.'): self._log(LOG_LEVEL, message, args, **kws) logging.Logger.log = logv - class log_filter(object): - def __init__(self, level): - self.__level = level - - def filter(self, logRecord): - return logRecord.levelno == self.__level - if os.path.exists(os.path.join(bench_path, 'logs')): logger = logging.getLogger(bench.PROJECT_NAME) log_file = os.path.join(bench_path, 'logs', 'bench.log') formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr = logging.FileHandler(log_file) hdlr.setFormatter(formatter) - logger.addHandler(hdlr) logger.setLevel(logging.DEBUG)