1

I'm new to hypercorn+uvloop+quart. I'm trying to create following files and print some info/debug log in the route handler but nothing shows up. I have debugged into the route handler and noticed the dog_server.logger.disabled = True. Does anyone know what's the problem? Thanks!

dog_blueprint.py

from quart import Blueprint
import logging

logging.basicConfig(level=logging.DEBUG)

class DogBlueprint(Blueprint):
    logger = None
    app_config = None

    def register(self, app, options, first_registration: bool = False):
        # app.logger.info('DogBlueprint is registering')
        print('Blueprint registering...')
        self.logger = app.logger 
        self.logger.info("Hello")  # This one working fine
        self.app_config = app.config
        super(DogBlueprint, self).register(app, options, first_registration)
        self.logger.info("World")  # This one working fine

route.py

dog_server = DogBlueprint('dog_server', __name__)
logging.basicConfig(level=logging.DEBUG)

@dog_server.route('/score', methods=['POST'])
async def post_handler():
    received = await _fetch_post_body(request)
    dog_server.logger.info(f'Received size: {len(received)}')  # This one does not work
    ... ... 
NonStatic
  • 951
  • 1
  • 8
  • 27
  • change ```logging.basicConfig(level=logging.DEBUG)``` to ```logging.basicConfig(level=logging.INFO)``` – Riyas Oct 05 '20 at 03:49
  • `DEBUG` suppose giving me more logging. But I did try to use `INFO` instead of `DEBUG`. Same result. I even try to print `critical` error message, but still nothing out, because the logger somehow disabled. – NonStatic Oct 05 '20 at 04:08
  • ```dog_server = DogBlueprint('dog_server', __name__)``` When this line is executed, does it calls register function automatically? – Riyas Oct 05 '20 at 04:14
  • Yes, the `Hello` and `World` could be printed out. – NonStatic Oct 05 '20 at 05:21
  • Instead of ```dog_server.logger.info``` can you try ```DogBlueprint.logger.info``` and see if goes thru. As you defined logger as class variable, see if you are able to make it using the class instead of object. – Riyas Oct 05 '20 at 05:29
  • It will hit null reference issue: `'NoneType' object has no attribute 'info'` – NonStatic Oct 05 '20 at 15:04

1 Answers1

1

This is a bug in Hypercorn, see this discussion. I'd avoid 0.11.0 and use 0.10.2 or 0.11.1. (I'm the Hypercorn author).

pgjones
  • 6,044
  • 1
  • 14
  • 12