Sanic: Disabling debug mode?

Created on 23 Aug 2017  ยท  5Comments  ยท  Source: sanic-org/sanic

I can't seem to disable the debug mode, is this normal?

from rise.server.wsgi import app, config

# config['debug'] = False
app.run(**config)
{'port': 5000, 'debug': False, 'host': '0.0.0.0'}
2017-08-22 23:59:32 - (sanic)[DEBUG]:
                 โ–„โ–„โ–„โ–„โ–„
        โ–€โ–€โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–„โ–„โ–„       _______________
      โ–„โ–„โ–„โ–„โ–„  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–„  /                 \
     โ–€โ–€โ–€โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ โ–€โ–โ–„ โ–€โ–โ–ˆ |   Gotta go fast!  |
   โ–€โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–„โ–„ โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–„โ–ˆโ–ˆ | _________________/
   โ–€โ–„โ–„โ–„โ–„โ–„  โ–€โ–€โ–ˆโ–„โ–€โ–ˆโ•โ•โ•โ•โ–ˆโ–€ |/
        โ–€โ–€โ–€โ–„  โ–€โ–€โ–ˆโ–ˆโ–ˆ โ–€       โ–„โ–„
     โ–„โ–ˆโ–ˆโ–ˆโ–€โ–€โ–ˆโ–ˆโ–„โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–„ โ–„โ–€โ–€โ–€โ–€โ–€โ–€โ–ˆโ–Œ
   โ–ˆโ–ˆโ–€โ–„โ–„โ–„โ–ˆโ–ˆโ–€โ–„โ–ˆโ–ˆโ–ˆโ–€ โ–€โ–€โ–ˆโ–ˆโ–ˆโ–ˆ      โ–„โ–ˆโ–ˆ
โ–„โ–€โ–€โ–€โ–„โ–ˆโ–ˆโ–„โ–€โ–€โ–Œโ–ˆโ–ˆโ–ˆโ–ˆโ–’โ–’โ–’โ–’โ–’โ–’โ–ˆโ–ˆโ–ˆ     โ–Œโ–„โ–„โ–€
โ–Œ    โ–โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–โ–ˆโ–ˆโ–ˆโ–’โ–’โ–’โ–’โ–’โ–โ–ˆโ–ˆโ–Œ
โ–€โ–„โ–„โ–„โ–„โ–€   โ–€โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–’โ–’โ–’โ–’โ–„โ–ˆโ–ˆโ–€
          โ–€โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–€
        โ–„โ–„โ–ˆโ–ˆโ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–€โ–ˆ
      โ–„โ–ˆโ–ˆโ–€     โ–€โ–€โ–€  โ–ˆ
     โ–„โ–ˆ             โ–โ–Œ
 โ–„โ–„โ–„โ–„โ–ˆโ–Œ              โ–€โ–ˆโ–„โ–„โ–„โ–„โ–€โ–€โ–„
โ–Œ     โ–                โ–€โ–€โ–„โ–„โ–„โ–€
 โ–€โ–€โ–„โ–„โ–€

DEBUG:sanic:
                 โ–„โ–„โ–„โ–„โ–„
        โ–€โ–€โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–„โ–„โ–„       _______________
      โ–„โ–„โ–„โ–„โ–„  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–„  /                 \
     โ–€โ–€โ–€โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ โ–€โ–โ–„ โ–€โ–โ–ˆ |   Gotta go fast!  |
   โ–€โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–„โ–„ โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–„โ–ˆโ–ˆ | _________________/
   โ–€โ–„โ–„โ–„โ–„โ–„  โ–€โ–€โ–ˆโ–„โ–€โ–ˆโ•โ•โ•โ•โ–ˆโ–€ |/
        โ–€โ–€โ–€โ–„  โ–€โ–€โ–ˆโ–ˆโ–ˆ โ–€       โ–„โ–„
     โ–„โ–ˆโ–ˆโ–ˆโ–€โ–€โ–ˆโ–ˆโ–„โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–„ โ–„โ–€โ–€โ–€โ–€โ–€โ–€โ–ˆโ–Œ
   โ–ˆโ–ˆโ–€โ–„โ–„โ–„โ–ˆโ–ˆโ–€โ–„โ–ˆโ–ˆโ–ˆโ–€ โ–€โ–€โ–ˆโ–ˆโ–ˆโ–ˆ      โ–„โ–ˆโ–ˆ
โ–„โ–€โ–€โ–€โ–„โ–ˆโ–ˆโ–„โ–€โ–€โ–Œโ–ˆโ–ˆโ–ˆโ–ˆโ–’โ–’โ–’โ–’โ–’โ–’โ–ˆโ–ˆโ–ˆ     โ–Œโ–„โ–„โ–€
โ–Œ    โ–โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–โ–ˆโ–ˆโ–ˆโ–’โ–’โ–’โ–’โ–’โ–โ–ˆโ–ˆโ–Œ
โ–€โ–„โ–„โ–„โ–„โ–€   โ–€โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–’โ–’โ–’โ–’โ–„โ–ˆโ–ˆโ–€
          โ–€โ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–€
        โ–„โ–„โ–ˆโ–ˆโ–€โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–€โ–ˆ
      โ–„โ–ˆโ–ˆโ–€     โ–€โ–€โ–€  โ–ˆ
     โ–„โ–ˆ             โ–โ–Œ
 โ–„โ–„โ–„โ–„โ–ˆโ–Œ              โ–€โ–ˆโ–„โ–„โ–„โ–„โ–€โ–€โ–„
โ–Œ     โ–                โ–€โ–€โ–„โ–„โ–„โ–€
 โ–€โ–€โ–„โ–„โ–€

2017-08-22 23:59:32 - (sanic)[INFO]: Goin' Fast @ http://0.0.0.0:5000
INFO:sanic:Goin' Fast @ http://0.0.0.0:5000
2017-08-22 23:59:32 - (sanic)[INFO]: Starting worker [39513]
INFO:sanic:Starting worker [39513]
bug urgent

Most helpful comment

I think this is not only a logging issue. The whole handling of debug is kinda messy. There is a debug variable in the Sanic class which you can set. It is then overwritten by anything that you pass (or don't pass) into run() but also not really used. I think there should be only one way to set the debug mode and this should then be in sync with the logging. What do you think? I think I could spare some time to make a PR for this. That would probably include to refactor that weird _helper() method.

All 5 comments

hmm.. logging issue again..
But this could be a simple fix, though. i will push a fix.

well, maybe take the chance to refactor logging... it may be better than adding lots of workarounds.

Same here

Same here, any workaround for this?

I think this is not only a logging issue. The whole handling of debug is kinda messy. There is a debug variable in the Sanic class which you can set. It is then overwritten by anything that you pass (or don't pass) into run() but also not really used. I think there should be only one way to set the debug mode and this should then be in sync with the logging. What do you think? I think I could spare some time to make a PR for this. That would probably include to refactor that weird _helper() method.

Was this page helpful?
0 / 5 - 0 ratings