Log helper snippet: determine_log_stacklevel
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2
- Forks
- 6
- Avg merge
- 7d 11h
- Merged PRs (30d)
- 1
Description
Snippet
Could be useful for some applications - determining dynamically how to configure Logger.log(..., stacklevel=_) when your message is sourced from some utility script
import inspect
def determine_log_stacklevel(*files_to_ignore: str) -> int:
"""
Determine the stack level for logging exceptions, based on the current
code stack.
"""
stacklevel = 1
# stack()[1:] skips determine_log_stacklevel()
for frame_info in inspect.stack()[1:]:
if frame_info.filename not in files_to_ignore:
break
stacklevel += 1
return stacklevel
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no repository file, entry point, or test; it only provides a Python helper using inspect.stack() for Logger.log(..., stacklevel=_). Start by reviewing the utility modules and test layout, then clarify where this helper belongs and what integration is expected. Done should include an agreed location and coverage for the intended stack-level behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100