Skip to content

Commit

Permalink
add subsystem to logging
Browse files Browse the repository at this point in the history
  • Loading branch information
soad003 committed Aug 21, 2024
1 parent 35e85c3 commit b655ce4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/graphsenselib/utils/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ def suppress_log_level(loglevel: int):


def configure_logging(loglevel):
log_format = " | %(message)s"
log_format = "| %(subsystem)s | %(message)s"

def addSubsys(record: logging.LogRecord):
try:
subsys = record.name.split(".")
record.subsystem = (subsys[1:2] or ("",))[0]
except Exception:
record.subsystem = "?"
return record

if loglevel < 10:
# this means the value passed is
Expand All @@ -48,6 +56,9 @@ def configure_logging(loglevel):
console=c,
show_path=False,
)

rh.addFilter(addSubsys)

logging.basicConfig(
format=log_format,
level=loglevel,
Expand Down

0 comments on commit b655ce4

Please sign in to comment.