Skip to content

Simplify logging in utils.py #80

@kjstanding

Description

@kjstanding
# Class to be used to add our TaskFieldFilter to any new loggers
class TaskFieldLogger(logging.getLoggerClass()):
    def __init__(self, name):
        super().__init__(name)
        self.addFilter(TaskFieldFilter())


# Set class to be used for instantiating loggers
logging.setLoggerClass(TaskFieldLogger)

logging.getLogger().addFilter(TaskFieldFilter())  # Add filter on root logger
quest_logger = logging.getLogger('quest')  # Create custom quest logger

# Add filter on any existing loggers
for logger_name in logging.root.manager.loggerDict.keys():
    logger = logging.getLogger(logger_name)
    logger.addFilter(TaskFieldFilter())
  • [byubean] For backlog: my hunch is this could be a little more straightforward. This smells like we don't quite know what we're doing, but we found something that worked and ran with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions