graphql-python / gql

A GraphQL client in Python
https://gql.readthedocs.io
MIT License
1.53k stars 178 forks source link

Request/Response payloads logged at level INFO #468

Closed david-waterworth closed 7 months ago

david-waterworth commented 7 months ago

Common problems

My applications log is filled with the payload of every request/response. For example

INFO:gql.transport.requests:>>> {"query": "query IntrospectionQuery {\n  __schema {\n    queryType {\n      name\n    }\n    mutationType {\n      name\n    }\n    subscriptionType {\n      name\n    }\n    types {\n      ...FullType\n    }\n    directives {\n      name\n      description\n      locations\n      args {\n        ...InputValue\n      }\n    }\n  }\n}\n\nfragment FullType on __Type {\n  kind\n  name\n  description\n  fields(includeDeprecated: true) {\n    name\n    description\n    args {\n      ...InputValue\n    }\n    type {\n      ...TypeRef\n    }\n    isDeprecated\n    deprecationReason\n  }\n  inputFields {\n    ...InputValue\n  }\n  interfaces {\n    ...TypeRef\n  }\n  enumValues(includeDeprecated: true) {\n    name\n    description\n    isDeprecated\n    deprecationReason\n  }\n  possibleTypes {\n    ...TypeRef\n  }\n}\n\nfragment InputValue on __InputValue {\n  name\n  description\n  type {\n    ...TypeRef\n  }\n  defaultValue\n}\n\nfragment TypeRef on __Type {\n  kind\n  name\n  ofType {\n    kind\n    name\n    ofType {\n      kind\n      name\n      ofType {\n        kind\n        name\n        ofType {\n          kind\n          name\n          ofType {\n            kind\n            name\n            ofType {\n              kind\n              name\n              ofType {\n                kind\n                name\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}"}
INFO:gql.transport.requests:<<< {"data":{"__schema":{"queryType":{"name":"QueryRoot"},"mutationType":null,"subscriptionType":null,"types":[{"kind":"SCALAR","name":"Boolean","description":null,"fields":null,"inputFields":null,"interfaces":null,"enumValues":null,"possibleTypes":null}

Note this is at log level INFO, specifically https://github.com/graphql-python/gql/blob/48bb94cc4fc0755419c9edc7e8ef1470036c193d/gql/transport/requests.py#L234-L235

Describe the bug Debug messages should not be logged at INFO level

To Reproduce Set log level to INFO

Expected behavior If required this should be logged at DEBUG lebel

System info (please complete the following information):

leszekhanusz commented 7 months ago

Sorry, this can't be changed as it is a breaking change. See Disabling-logs in the docs to modify the log level for gql.

olivierpilotte commented 6 months ago

bumping this issue. I see you've marked as duplicate, but is this being adressed?

david-waterworth commented 6 months ago

@olivierpilotte it doesn't appear so, I don't understand why it cannot be changed but the maintainers consider fixing this a breaking change and closed my issue. You have to manually set the logging level per transport as per the doc link above, i.e.

from gql.transport.requests import log as requests_logger
requests_logger.setLevel(logging.WARNING)
olivierpilotte commented 6 months ago

@david-waterworth I'm running a query from Airflow, and for some reason, disabling the logs this way does not work. Not fixed in 3.6.0b0 nor 3.6.0b1

@leszekhanusz can we have a quick follow-up on this issue? Is there a plan for a permanent fix?

david-waterworth commented 6 months ago

@olivierpilotte yes I'm seeing something similar when I enable logging in a notebook running in vscode - even though I've disabled the transport log it still generates log messages.