Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected logging outputs after setting log level to debug. #10946

Closed
ghost opened this issue Dec 15, 2017 · 32 comments · Fixed by #14119
Closed

Unexpected logging outputs after setting log level to debug. #10946

ghost opened this issue Dec 15, 2017 · 32 comments · Fixed by #14119

Comments

@ghost
Copy link

ghost commented Dec 15, 2017

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

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)]'}
@vgavro
Copy link

vgavro commented Dec 29, 2017

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 davidhalter/parso#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

@auuron
Copy link

auuron commented Jan 9, 2018

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..

@brandonrobertz
Copy link

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.

@auuron
Copy link

auuron commented Jan 12, 2018

5.5.0 worked for me too

@dolsem
Copy link

dolsem commented Jan 18, 2018

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

@stuaxo
Copy link

stuaxo commented Feb 26, 2018

Thanks ! This has been doing my head in. I still get some messages about pickle, even with the fix, but downgrading works well.

@tcztzy
Copy link

tcztzy commented Feb 27, 2018

I workaround this problem by add the following line in my ipython_config.py

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.

@NewUserHa
Copy link

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?

@ramsrib
Copy link

ramsrib commented Aug 1, 2018

This issue get resolved for me after upgrading to the latest version (6.5.0).

@ramsrib
Copy link

ramsrib commented Aug 4, 2018

I guess this issue can be closed!

@stuaxo
Copy link

stuaxo commented Aug 4, 2018

Sounds good to me, I haven't seen it in a while, we can reopen if it reappears.

@vferraz
Copy link

vferraz commented Aug 19, 2018

I updated Ipython to 6.5.0 and I still have the issue with scrapy shell

@osjerick
Copy link

osjerick commented Dec 5, 2018

I have this issue on Anaconda with IPython 7.2.0. and Scrapy Shell (Scrapy's version 1.5.1).

@armenak-baburyan
Copy link

The issue came back with ipython 7.2

@ghost
Copy link
Author

ghost commented Feb 13, 2019

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

@and-semakin
Copy link

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 fixes this issue for me.

@adelplanque
Copy link

Same problem with ipython 7.2.0 parso 0.3.4
It's a very big problem.

@docker77
Copy link

docker77 commented Apr 4, 2019

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?

@Jonathan-Joe-star
Copy link

Reappears in IPython 7.8.0

@orlp
Copy link

orlp commented Oct 7, 2019

Reproduced today :(

@davidhalter
Copy link

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.

@NewUserHa
Copy link

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.

@jinuskr
Copy link

jinuskr commented Nov 9, 2019

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.

@nealmcb
Copy link

nealmcb commented Nov 23, 2019

This also happens for me in IPython version 7.9.0 and scrapy 1.8.0.
The workaround in #10946 (comment) works, but as everyone here notes, what a hassle!

@2tunnels
Copy link

As a workaround you can configure parso logger in settings.py to show only warning messages:

import logging

logging.getLogger('parso').setLevel(logging.WARNING)

@davidhalter
Copy link

This should probably be part of IPython. Someone of you should just do a pull request there.

kbd added a commit to kbd/setup that referenced this issue Aug 22, 2020
@Ashlett
Copy link

Ashlett commented Oct 30, 2020

Here's a workaround that works for me:

  1. Created a file pythonstartup.py in my home directory with this content:
import logging
 
for lib in ("asyncio", "parso"):
    logging.getLogger(lib).setLevel(logging.WARNING)
  1. Added this line to my .bashrc:
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)

@hmpf
Copy link

hmpf commented Feb 22, 2022

This also happens with IPython 8.0.1/Python 3.10. How far down must I downgrade? This is driving me crazy.

@hmpf
Copy link

hmpf commented Feb 22, 2022

@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.

@blodone
Copy link

blodone commented Jul 14, 2023

ipython==8.14.0
parso==0.8.3
python==3.9.2

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:...```

@drunkwcodes
Copy link
Contributor

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?

@drunkwcodes
Copy link
Contributor

I made a PR: #14119
Please preview and approve my code.

Carreau added a commit that referenced this issue Aug 28, 2023
This PR closes #10946.

We set explicitely the log level of parso so that global changes to log level do not trigger parso logging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.