Skip to content

Commit

Permalink
severity and facility added
Browse files Browse the repository at this point in the history
  • Loading branch information
sametd authored and jameshawkes committed Aug 19, 2024
1 parent 4c50c70 commit cbe5a5e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions polytope_server/common/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def add_indexable_fields(self, record, result):
def calculate_syslog_priority(self, logging_level):
severity = LOGGING_TO_SYSLOG_SEVERITY.get(logging_level, 7) # Default to LOG_DEBUG if level is not found
priority = (LOCAL7 << 3) | severity
return str(priority)
return priority

def format_for_logserver(self, record, result):
software_info = {
Expand All @@ -90,7 +90,10 @@ def format_for_logserver(self, record, result):
if field in result:
message_content[field] = result[field]
result["message"] = json.dumps(message_content, indent=None)

# Add syslog facility
result["syslog_facility"] = LOCAL7
# Add syslog severity
result["syslog_severity"] = LOGGING_TO_SYSLOG_SEVERITY.get(record.levelno, 7)
# Add syslog priority
result["syslog_priority"] = self.calculate_syslog_priority(record.levelno)

Expand Down

0 comments on commit cbe5a5e

Please sign in to comment.