Skip to content

Commit

Permalink
fix: Log in ~/bench.log if not running inside bench directory
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza committed Sep 3, 2020
1 parent a1b4dc4 commit 28302f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bench/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def cli():
command = " ".join(sys.argv)

change_working_directory()
logger = setup_logging() or logging.getLogger(bench.PROJECT_NAME)
logger = setup_logging()
logger.info(command)
check_uid()
change_dir()
Expand Down
17 changes: 10 additions & 7 deletions bench/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,15 +443,18 @@ def logv(self, message, *args, **kws):
logging.Logger.log = logv

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)
else:
log_file = os.path.join(os.path.expanduser("~"), 'bench.log')

logger = logging.getLogger(bench.PROJECT_NAME)
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr = logging.FileHandler(log_file)
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)

return logger
return logger


def get_process_manager():
Expand Down

0 comments on commit 28302f6

Please sign in to comment.