I am using a py-elasticsearch to query elasticsearch:
try:
res = es.get(index='unique_names', doc_type='name', id=token, ignore=['404'])
except elasticsearch.exceptions.NotFoundError:
continue
As you can see I use an exception for if the index does not exist, however the errors still get printed to the terminal like this:
GET /unique_names/name/%E4%BD%8F%E6%B0%91%E3%82%89%E9%81%BF%E9%9B%A3 [status:404 request:0.000s] GET /unique_names/name/%E6%95%91%E5%8A%A9%E6%9C%AC%E6%A0%BC%E5%8C%96 [status:404 request:0.000s] GET /unique_names/name/%E3%80%81 [status:404 request:0.000s] GET /unique_names/name/%E5%81%9C%E9%9B%BB%E3%82%82 [status:404 request:0.000s] GET /unique_names/name/%E3%80%82 [status:404 request:0.000s]
I would like it to not print anything, because my terminal gets flooded.
The reason this gets printed out is because of these lines in the base.py
code.
Basically, you're ignoring 404 status codes, so the request gets logged as if it had succeeded.
If you want to get rid of those lines, you need to increase the logging level to WARN instead of INFO.