Small improvements to CLI experience (#2136)
* Small improvements to CLI experience * Add tests * Add test server for cli testing * Add LOGO logging to reloader and some additional context to logging debug * Cleanup tests
This commit is contained in:
32
tests/fake/server.py
Normal file
32
tests/fake/server.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import json
|
||||
import logging
|
||||
|
||||
from sanic import Sanic, text
|
||||
from sanic.log import LOGGING_CONFIG_DEFAULTS, logger
|
||||
|
||||
|
||||
LOGGING_CONFIG = {**LOGGING_CONFIG_DEFAULTS}
|
||||
LOGGING_CONFIG["formatters"]["generic"]["format"] = "%(message)s"
|
||||
LOGGING_CONFIG["loggers"]["sanic.root"]["level"] = "DEBUG"
|
||||
|
||||
app = Sanic(__name__, log_config=LOGGING_CONFIG)
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def handler(request):
|
||||
return text(request.ip)
|
||||
|
||||
|
||||
@app.before_server_start
|
||||
async def app_info_dump(app: Sanic, _):
|
||||
app_data = {
|
||||
"access_log": app.config.ACCESS_LOG,
|
||||
"auto_reload": app.auto_reload,
|
||||
"debug": app.debug,
|
||||
}
|
||||
logger.info(json.dumps(app_data))
|
||||
|
||||
|
||||
@app.after_server_start
|
||||
async def shutdown(app: Sanic, _):
|
||||
app.stop()
|
||||
Reference in New Issue
Block a user