Gallopsled / Gallopsled/pwntools
Using logging module directly messes with log context
- Dominant language
- Python
- Stars
- 13.7k
- Forks
- 1.9k
- Avg merge
- 6d 23h
- Merged PRs (30d)
- 3
Description
The following works as expected; silent output:
```python
import pwn
from pwn import *
context.log_level = "error"
log.debug("test log")
with pwn.process(["cat"]) as r:
r.send(b"hello")
```
However, if I mistakenly use `logging` instead of `log`, as here:
```python
import pwn
from pwn import *
context.log_level = "error"
logging.debug("test log")
with pwn.process(["cat"]) as r:
r.send(b"hello")
```
Then my script's output is:
```bash
> python tmp.py
INFO:pwnlib.tubes.process.process.139775979242256:Starting local process '/usr/bin/cat'
INFO:pwnlib.tubes.process.process.139775979242256:Starting local process '/usr/bin/cat': pid 38935
INFO:pwnlib.tubes.process.process.139775979242256:Stopped process '/usr/bin/cat' (pid 38935)
```
You can see that `context.log_level` is essentially ignored. This seems like a bug to me, or if not, maybe something that can be mentioned in the docs. Can anyone help me understand whether this is a bug or proper behavior?
Contributor guide
Research direction
Start with the pwn.process entry point and the context.log_level handling, then inspect the pwnlib.tubes.process.process logging shown in the reproduction. Determine whether direct Python logging should respect the configured context level or whether the behavior needs documentation; verify the chosen outcome with the supplied example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100