Skip to content

Commit

Permalink
Audit logger bug fix (#166)
Browse files Browse the repository at this point in the history
change audit logger to a class var to prevent initiating logger multiple times
  • Loading branch information
NogaNHS authored Nov 27, 2023
1 parent a0a03aa commit a2938c0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lambdas/utils/audit_logging_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@


class LoggingService:

audit_logger = None

def __init__(self, name):
self.name = name
self.logger = logging.getLogger(name)
self.logger.setLevel(logging.INFO)

self.audit_logger = logging.getLogger("audit")
self.audit_handler = SensitiveAuditService()
self.configure_audit_logger()
self.formatter = LoggingFormatter()
logging.Formatter.format = self.formatter.format

self.audit_logger.addHandler(self.audit_handler)
self.audit_logger.setLevel(logging.INFO)
def configure_audit_logger(self):
if self.__class__.audit_logger is None:
self.__class__.audit_logger = logging.getLogger("audit")
audit_handler = SensitiveAuditService()
self.__class__.audit_logger.addHandler(audit_handler)
self.__class__.audit_logger.setLevel(logging.INFO)

def audit_splunk_info(self, msg, args: dict = None):
logging.getLogger("audit.{}".format(self.name))
Expand Down

0 comments on commit a2938c0

Please sign in to comment.