question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Logging is too verbose

See original GitHub issue

Right now all websocket messages are being sent at INFO level, and there’s no way to change it for graphql-python (only globally). Useful information is often emitted at INFO level, but it becomes hard to read with all the websocket traffic. Especially when it fetches the initial schema (which in my case is large enough that it sometimes crashes my IDE).

It would be helpful if either:

  1. Websocket traffic is emitted at DEBUG (which seems reasonable to me, as they’re only needed when debugging).
  2. Logging levels could be overriden just for this package.

I’m happy to make the pull request if you’re open to one or the other option.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

3reactions
faberchricommented, Nov 12, 2021

For async I/O, I had to use from gql.transport.aiohttp import log as requests_logger.

3reactions
leszekhanuszcommented, Dec 12, 2020

Here is a small example on how to disable the logs (for the requests transport but it should work the same way for other transports)

It works by getting the logger from the transport file and changing the level for this logger only (so that all the other logs in your code are not affected).

I’ll make a PR to improve the documentation about this.

import logging                                                                                                          
                                                                                                                        
logging.basicConfig(level=logging.INFO)                                                                                 
                                                                                                                        
from gql import Client, gql                                                                                             
from gql.transport.requests import RequestsHTTPTransport                                                                
from gql.transport.requests import log as requests_logger                                                               
                                                                                                                        
requests_logger.setLevel(logging.WARNING)                                                                               
                                                                                                                        
transport = RequestsHTTPTransport(                                                                                      
    url="https://countries.trevorblades.com/", verify=True, retries=3,                                                  
)                                                                                                                       
                                                                                                                        
client = Client(transport=transport, fetch_schema_from_transport=True)                                                  
                                                                                                                        
query = gql(                                                                                                            
    """                                                                                                                 
    query getContinents {                                                                                               
      continents {                                                                                                      
        code                                                                                                            
        name                                                                                                            
      }                                                                                                                 
    }                                                                                                                   
"""                                                                                                                     
)                                                                                                                       
                                                                                                                        
result = client.execute(query)                                                                                          
logging.info(f'We received the result: {result}')
Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core logging too verbose - Stack Overflow
When you set Debug , it will log Critical, Error, Warning, Information, Debug levels. It will not log Trace (highest verbosity). If you...
Read more >
Default logging too verbose #1126 - go-swagger/go ... - GitHub
When looking at the logs of a server generated by go-swagger, I notice a lot of verbose (and for production unnecessary) output.
Read more >
Filebeat logs are too verbose - Beats - Discuss the Elastic Stack
I deployed filebeat to a Docker host, everything works as expected, all container logs are sent to Elasticsearch. However, after a few days, ......
Read more >
Reducing log verbosity with Serilog RequestLogging
The down side to this is that sometimes you can get too many logs. In this short series I describe how to use...
Read more >
Logging - Gradle User Manual
The log is the main 'UI' of a build tool. If it is too verbose, real warnings and problems are easily hidden by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found