Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Feature request: Evaluate a processor chain at a given set of log levels

Open
#633 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
42/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

The issue describes a ProcessAtLogLevels processor and shows how it would wrap CallsiteParameterAdder, but it does not name implementation or test files. Read the processor documentation and existing processor tests to find where a chain wrapper fits. Done means processors run only for the selected levels and the behavior is covered by tests; the issue has had no comment for 796 days, so expect little guidance.

Written by the indexing model from the issue text.

Description

enhancement

I find myself only wanting certain fields included in my logging at a few select log levels. Something like:

class ProcessAtLogLevels:
    """Evaluate a chain of processors at a given set log levels.

    Args:
        levels: Log levels at which to evaluate processor chain.
        processors: A chain of *structlog* processors that is used to process entries at the given log levels.
    """

    def __init__(self, levels: int | Collection[int], *, processors: Sequence[Processor] = ()):
        self._levels = levels if isinstance(levels, Collection) else (levels,)
        self._processors = processors

    def __call__(self, logger: WrappedLogger, method_name: str, event_dict: EventDict) -> EventDict:
        if structlog.processors.NAME_TO_LEVEL[method_name] in self._levels:
            for processor in self._processors:
                event_dict = processor(logger, method_name, event_dict)
        return event_dict

I'll end up with something like this in my processor chain:

ProcessAtLogLevels(
    {logging.DEBUG, logging.CRITICAL},
    processors=(
        structlog.processors.CallsiteParameterAdder(
            (structlog.processors.CallsiteParameter.LINENO, structlog.processors.CallsiteParameter.PATHNAME)
        ),
    ),
)

This will only add line numbers and pathname at the DEBUG and CRITICAL log levels.

Dominant language
Python
Stars
5k
Forks
302
Avg merge
17m
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hynek/structlog

All issues in hynek/structlog

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.