Repository: ipython/ipython

Issue:
Unexpected logging outputs after setting log level to debug.
I got unexcepted outputs to console after set log level to debug while using tab to autocomplete, and it breaks my typing.
Here's my screenshot:
![ipython-logging](https://user-images.githubusercontent.com/3499226/34044755-3f976878-e1e1-11e7-82ae-d178039a8642.png)

Reproduce:
```
In [1]: import logging

In [2]: logging.getLogger().setLevel(logging.DEBUG)

In [3]: logging.info("xxxx")
INFO:root:xxxx

In [4]: logging.<TAB>DEBUG:parso.python.diff:diff parser start
DEBUG:parso.python.diff:diff parser calculated
DEBUG:parso.python.diff:diff: line_lengths old: 1, new: 1
DEBUG:parso.python.diff:diff replace old[1:1] new[1:1]
DEBUG:parso.python.diff:parse_part from 1 to 1 (to 0 in part parser)
DEBUG:parso.python.diff:diff parser end
DEBUG:parso.cache:pickle loaded: /Users/uushuo/.pyenv/versions/3.6.3/lib/python3.6/collections/__init__.py
DEBUG:parso.cache:pickle loaded: /Users/uushuo/.pyenv/versions/3.6.3/lib/python3.6/io.py
DEBUG:parso.cache:pickle loaded: /Users/uushuo/.pyenv/versions/3.6.3/lib/python3.6/os.py
DEBUG:parso.cache:pickle loaded: /Users/uushuo/.pyenv/versions/3.6.3/lib/python3.6/string.py
DEBUG:parso.cache:pickle loaded: /Users/uushuo/.pyenv/versions/3.6.3/lib/python3.6/threading.py
DEBUG:parso.cache:pickle loaded: /Users/uushuo/.pyenv/versions/3.6.3/lib/python3.6/traceback.py
DEBUG:parso.cache:pickle loaded: /Users/uushuo/.pyenv/versions/3.6.3/lib/python3.6/warnings.py
DEBUG:parso.cache:pickle loaded: /Users/uushuo/.pyenv/versions/3.6.3/lib/python3.6/weakref.py
```

Version info
```
{'commit_hash': 'ca5443062',
 'commit_source': 'installation',
 'default_encoding': 'UTF-8',
 'ipython_path': '/Users/uushuo/.pyenv/versions/3.6.3/envs/next/lib/python3.6/site-packages/IPython',
 'ipython_version': '6.2.1',
 'os_name': 'posix',
 'platform': 'Darwin-17.0.0-x86_64-i386-64bit',
 'sys_executable': '/Users/uushuo/.pyenv/versions/next/bin/python',
 'sys_platform': 'darwin',
 'sys_version': '3.6.3 (default, Dec 15 2017, 20:17:37) \n'
                '[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]'}
```


Discussion:
First of all, you should update to parso 0.1.1 in case you're receiving this messages in ROOT level (like I did). This is related to https://github.com/davidhalter/parso/issues/9
But seems from your logs you have parso 0.1.1 already.
Second, this should fix this:
```
logging.getLogger('parso.python.diff').disabled = True
```
I have same issue - with parso 0.1.1 and ipython 6.2.1 (django shell console)

edit:
` 'parso': {
            'handlers': ['console'],
            'level': 'INFO',
            'propagate': False,
        },`
worked for me, but it's definitely workaround..
I downgraded to ipython 5.2.1 to get around this. This may not be an option for you, but it worked for me as a stopgap until this is fixed in ipython.
5.5.0 worked for me too
I had the same issue with ptpython. vgavro's solution fixed it for me; I put that line in the beginning of ~/.local/lib/python2.7/site-packages/parso/python/diff.py
Thanks !  This has been doing my head in.    I still get some messages about pickle, even with the fix, but downgrading works well.
I workaround this problem by add the following line in my ipython_config.py

```python
c.Application.log_level = logging.INFO
```

But I think it is only a workaround, we do not need any more configuration for fixing this flaw.
I have the same issue with ipython 6.2.1 that I just pip installed.
all my python stuffs are newly installed include scrapy.
but in `scrapy shell ..`
it begin spam the DEBUG info
will this be fixed?
This issue get resolved for me after upgrading to the latest version (`6.5.0`). 
I guess this issue can be closed!
Sounds good to me, I haven't seen it in a while, we can reopen if it reappears.
I updated Ipython to `6.5.0` and I still have the issue with `scrapy shell`
I have this issue on Anaconda with IPython 7.2.0. and Scrapy Shell (Scrapy's version 1.5.1).
The issue came back with ipython 7.2
> I updated Ipython to `6.5.0` and I still have the issue with `scrapy shell`

Downgrading to ipython 6.5.0 fixed the problem 

Will wait until this is fix in the latest 
Get unexpected logging when press Tab.

```
Python 3.6.3 (default, Oct  3 2017, 21:45:48) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.3.0 -- An enhanced Interactive Python. Type '?' for help.
```

```
In [3]: p = ais.pro2019-03-04 15:22:53,155 [DEBUG] parso.python.diff: diff parser start
2019-03-04 15:22:53,155 [DEBUG] parso.python.diff: line_lengths old: 1; new: 1
2019-03-04 15:22:53,156 [DEBUG] parso.python.diff: -> code[replace] old[1:1] new[1:1]
2019-03-04 15:22:53,156 [DEBUG] parso.python.diff: parse_part from 1 to 1 (to 0 in part parser)                                                                                                                    
2019-03-04 15:22:53,156 [DEBUG] parso.python.diff: diff parser end
                   jects.Pro2019-03-04 15:22:54,821 [DEBUG] parso.python.diff: diff parser start
2019-03-04 15:22:54,821 [DEBUG] parso.python.diff: line_lengths old: 1; new: 1
2019-03-04 15:22:54,821 [DEBUG] parso.python.diff: -> code[replace] old[1:1] new[1:1]
2019-03-04 15:22:54,822 [DEBUG] parso.python.diff: parse_part from 1 to 1 (to 0 in part parser)
2019-03-04 15:22:54,822 [DEBUG] parso.python.diff: diff parser end
```

[vgavro's answer](https://github.com/ipython/ipython/issues/10946#issuecomment-354501461) fixes this issue for me.
Same problem with ipython 7.2.0 parso 0.3.4
It's a very big problem.
Still have this issue with iptyhon 7.4.0 and scrapy shell
```
import logging
logging.getLogger().setLevel(logging.WARNING);
```

works, but i cant make it work during starting of the shell. Looks like scapy don't loads default_profile
Any workarounds?
Reappears in IPython 7.8.0
Reproduced today :(
It might be a good idea to just disable the parso logger in IPython altogether. I don't really think that it is needed in any case. 

When people are enabling logging, they usually want to see the logs about the stuff they import and not the stuff that IPython imports.
That users change log level in REPL SHELL is a usual thing. How about making debug settings of shell other places to avoid effecting by log level settings.
I always disable the parso log every time when I use the console for debugging, which is very inconvenient and unproductive. I think this should be fixed.
This also happens for me in IPython version 7.9.0 and scrapy 1.8.0.
The workaround in https://github.com/ipython/ipython/issues/10946#issuecomment-479826344 works, but as everyone here notes, what a hassle!

As a workaround you can configure `parso` logger in `settings.py` to show only warning messages:

```python
import logging

logging.getLogger('parso').setLevel(logging.WARNING)
```
This should probably be part of IPython. Someone of you should just do a pull request there.
Here's a workaround that works for me:

1. Created a file `pythonstartup.py` in my home directory with this content:
```python
import logging
 
for lib in ("asyncio", "parso"):
    logging.getLogger(lib).setLevel(logging.WARNING)
```
2. Added this line to my `.bashrc`:
```bash
export PYTHONSTARTUP="$HOME/pythonstartup.py"
```

(I included `asyncio` because I saw some useless logs from it at the startup of Django `shell_plus` with IPython, you can skip it depending on your use case)
This also happens with IPython 8.0.1/Python 3.10. How far down must I downgrade? This is driving me crazy.
@Ashlett's workaround isn't working for me btw, neither is setting anything in the ipython config. Neither is

```
import logging
logger = logging.getLogger()
logger.handlers = []
```

when in IPython itself.

I do NOT want to change loglevel for everything, I just want to shut up parso, asyncio, blib2to3, and the list just keeps growing.
ipython==8.14.0
parso==0.8.3
python==3.9.2

```DEBUG 2023-07-14 12:12:29,491 diff 1985589 140520980756288 diff parser start
DEBUG 2023-07-14 12:12:29,491 diff 1985589 140520980756288 line_lengths old: 1; new: 1
DEBUG 2023-07-14 12:12:29,491 diff 1985589 140520980756288 -> code[replace] old[1:1] new[1:1]
DEBUG 2023-07-14 12:12:29,491 diff 1985589 140520980756288 parse_part from 1 to 1 (to 0 in part parser)
DEBUG 2023-07-14 12:12:29,491 diff 1985589 140520980756288 diff parser end
DEBUG 2023-07-14 12:12:29,501 cache 1985589 140520980756288 pickle loaded:...```
I suggest to put that line (`logging.getLogger('parso').setLevel(logging.WARNING)`) in this module.

https://github.com/ipython/ipython/blob/main/IPython/core/logger.py

It is imported by interactiveshell.py. Though I didn't test it.

Does someone want to make a PR?

Resolving patch:
diff --git a/IPython/core/logger.py b/IPython/core/logger.py
--- a/IPython/core/logger.py
+++ b/IPython/core/logger.py
@@ -15,10 +15,15 @@
 # Python standard modules
 import glob
 import io
+import logging
 import os
 import time
 
 
+
+# prevent jedi/parso's debug messages pipe into interactiveshell
+logging.getLogger("parso").setLevel(logging.WARNING)
+
 #****************************************************************************
 # FIXME: This class isn't a mixin anymore, but it still needs attributes from
 # ipython and does input cache management.  Finish cleanup later...


Test patch: