18 lines
419 B
Python
18 lines
419 B
Python
import sys
|
|
|
|
from loguru import logger
|
|
|
|
config = {
|
|
"handlers": [
|
|
{"sink": sys.stdout, "colorize": True},
|
|
{"sink": "file.log", "enqueue": True, "level": "ERROR", "rotation": "20 MB"}
|
|
]
|
|
}
|
|
logger.configure(**config)
|
|
|
|
|
|
def http(request, response, time_s):
|
|
"""http请求日志"""
|
|
logger.info(
|
|
f'{request.method} {request.url.path} {response.status_code} {round(time_s * 1000, 3)} ms')
|