Skip to content

Commit

Permalink
fix: save frappe loggers site wise
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza committed Jul 29, 2020
1 parent 1345c2f commit ae3ee5b
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions frappe/utils/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,25 @@ def get_logger(module, with_more_info=False, allow_site=True, filter=None):
<class 'logging.Logger'>: Returns a Python logger object with Site and Bench level logging capabilities.
"""

if allow_site == True:
site = getattr(frappe.local, 'site', None)
elif allow_site:
site = allow_site
else:
site = False

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

if not module:
module = "frappe"
with_more_info = True

logfile = module + '.log'

if allow_site == True:
site = getattr(frappe.local, 'site', None)
elif allow_site:
site = allow_site
else:
site = False

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

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

handler.setFormatter(formatter)

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

return logger

Expand Down

0 comments on commit ae3ee5b

Please sign in to comment.