Skip to content

Commit

Permalink
fix: suffix logger name with site
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza committed Jul 30, 2020
1 parent 35c539f commit 7bf69c6
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions frappe/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ def get_logger(module, with_more_info=False, allow_site=True, filter=None):
else:
site = False

if module in frappe.loggers:
LOGGER_NAME = "{}-{}".format(module, site or "all")

if LOGGER_NAME in frappe.loggers:
try:
return frappe.loggers[module][site or "all"]
return frappe.loggers[LOGGER_NAME]
except:
pass

Expand All @@ -51,7 +53,7 @@ def get_logger(module, with_more_info=False, allow_site=True, filter=None):

LOG_FILENAME = os.path.join('..', 'logs', logfile)

logger = logging.getLogger(module)
logger = logging.getLogger(LOGGER_NAME)
logger.setLevel(frappe.log_level or default_log_level)
logger.propagate = False

Expand All @@ -73,11 +75,7 @@ def get_logger(module, with_more_info=False, allow_site=True, filter=None):

handler.setFormatter(formatter)

try:
frappe.loggers[module][site or "all"] = logger
except KeyError:
frappe.loggers[module] = {}
frappe.loggers[module][site or "all"] = logger
frappe.loggers[LOGGER_NAME] = logger

return logger

Expand Down

0 comments on commit 7bf69c6

Please sign in to comment.