2
0
mirror of https://github.com/frappe/bench.git synced 2024-11-12 00:06:36 +00:00

Merge pull request #1062 from gavindsouza/log-in-files

fix: Don't show logs in stdout if command run outside bench directory
This commit is contained in:
gavin 2020-09-10 11:37:10 +05:30 committed by GitHub
commit f3a0bfd38a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View File

@ -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)
if sys.argv[1] not in ("src", ):

View File

@ -443,15 +443,18 @@ def setup_logging(bench_path='.'):
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:
hdlr = logging.NullHandler()
return logger
logger = logging.getLogger(bench.PROJECT_NAME)
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)
return logger
def get_process_manager():