chore: log format
This commit is contained in:
parent
459cd8f698
commit
ca66e251dd
@ -148,7 +148,7 @@ class MediaChunkHolder(object):
|
|||||||
|
|
||||||
|
|
||||||
class MediaChunkHolderManager(object):
|
class MediaChunkHolderManager(object):
|
||||||
MAX_CACHE_SIZE = 2**31 # 2GB
|
MAX_CACHE_SIZE = 2**32 # 4GB
|
||||||
current_cache_size: int = 0
|
current_cache_size: int = 0
|
||||||
# chunk unique id -> ChunkHolder
|
# chunk unique id -> ChunkHolder
|
||||||
disk_chunk_cache: diskcache.Cache
|
disk_chunk_cache: diskcache.Cache
|
||||||
|
@ -3,7 +3,21 @@ disable_existing_loggers: false
|
|||||||
formatters:
|
formatters:
|
||||||
standard:
|
standard:
|
||||||
format: '[%(levelname)s] %(asctime)s [%(name)s:%(lineno)d]:%(message)s'
|
format: '[%(levelname)s] %(asctime)s [%(name)s:%(lineno)d]:%(message)s'
|
||||||
|
default:
|
||||||
|
"()": uvicorn.logging.DefaultFormatter
|
||||||
|
format: "[%(levelname)s] %(asctime)s [uvicorn.default]:%(message)s"
|
||||||
|
access:
|
||||||
|
"()": uvicorn.logging.AccessFormatter
|
||||||
|
format: '[%(levelname)s] %(asctime)s [uvicorn.access]:%(client_addr)s - "%(request_line)s" %(status_code)s'
|
||||||
handlers:
|
handlers:
|
||||||
|
access:
|
||||||
|
class: logging.StreamHandler
|
||||||
|
formatter: access
|
||||||
|
stream: ext://sys.stdout
|
||||||
|
default:
|
||||||
|
class: logging.StreamHandler
|
||||||
|
formatter: default
|
||||||
|
stream: ext://sys.stderr
|
||||||
console:
|
console:
|
||||||
level: INFO
|
level: INFO
|
||||||
class: logging.StreamHandler
|
class: logging.StreamHandler
|
||||||
@ -11,7 +25,7 @@ handlers:
|
|||||||
timed_rotating_file:
|
timed_rotating_file:
|
||||||
class: logging.handlers.TimedRotatingFileHandler
|
class: logging.handlers.TimedRotatingFileHandler
|
||||||
filename: logs/app.log
|
filename: logs/app.log
|
||||||
when: 'D'
|
when: 'midnight'
|
||||||
interval: 1
|
interval: 1
|
||||||
backupCount: 7
|
backupCount: 7
|
||||||
level: INFO
|
level: INFO
|
||||||
@ -22,3 +36,13 @@ loggers:
|
|||||||
handlers: [console, timed_rotating_file]
|
handlers: [console, timed_rotating_file]
|
||||||
level: DEBUG
|
level: DEBUG
|
||||||
propagate: true
|
propagate: true
|
||||||
|
uvicorn:
|
||||||
|
handlers: [default, timed_rotating_file]
|
||||||
|
level: INFO
|
||||||
|
propagate: false
|
||||||
|
uvicorn.access:
|
||||||
|
handlers: [access, timed_rotating_file]
|
||||||
|
level: INFO
|
||||||
|
propagate: false
|
||||||
|
uvicorn.error:
|
||||||
|
level: INFO
|
||||||
|
24
start.py
24
start.py
@ -5,32 +5,16 @@ import yaml
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
from uvicorn.config import LOGGING_CONFIG
|
|
||||||
|
|
||||||
import configParse
|
import configParse
|
||||||
from backend import backendapp
|
from backend import backendapp
|
||||||
|
|
||||||
|
log_config = None
|
||||||
if not os.path.exists(os.path.dirname(__file__) + "/logs"):
|
if not os.path.exists(os.path.dirname(__file__) + "/logs"):
|
||||||
os.mkdir(os.path.dirname(__file__) + "/logs")
|
os.mkdir(os.path.dirname(__file__) + "/logs")
|
||||||
with open("logging_config.yaml", "r") as f:
|
with open("logging_config.yaml", "r") as f:
|
||||||
logging.config.dictConfig(yaml.safe_load(f.read()))
|
log_config = yaml.safe_load(f.read())
|
||||||
|
logging.config.dictConfig(log_config)
|
||||||
LOGGING_CONFIG["formatters"]["default"]["fmt"] = "[%(levelname)s] %(asctime)s [uvicorn.default]:%(message)s"
|
|
||||||
LOGGING_CONFIG["formatters"]["access"][
|
|
||||||
"fmt"
|
|
||||||
] = '[%(levelname)s] %(asctime)s [uvicorn.access]:%(client_addr)s - "%(request_line)s" %(status_code)s'
|
|
||||||
LOGGING_CONFIG["handlers"]["timed_rotating_api_file"] = {
|
|
||||||
"class": "logging.handlers.TimedRotatingFileHandler",
|
|
||||||
"filename": "logs/app.log",
|
|
||||||
"when": "D",
|
|
||||||
"interval": 1,
|
|
||||||
"backupCount": 7,
|
|
||||||
"level": "INFO",
|
|
||||||
"formatter": "default",
|
|
||||||
"encoding": "utf-8",
|
|
||||||
}
|
|
||||||
LOGGING_CONFIG["loggers"]["uvicorn"]["handlers"].append("timed_rotating_api_file")
|
|
||||||
LOGGING_CONFIG["loggers"]["uvicorn.access"]["handlers"].append("timed_rotating_api_file")
|
|
||||||
|
|
||||||
logger = logging.getLogger(__file__.split("/")[-1])
|
logger = logging.getLogger(__file__.split("/")[-1])
|
||||||
|
|
||||||
@ -65,4 +49,4 @@ if __name__ == "__main__":
|
|||||||
if ret == 0:
|
if ret == 0:
|
||||||
asyncio.get_event_loop().run_until_complete(run_web_server())
|
asyncio.get_event_loop().run_until_complete(run_web_server())
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
uvicorn.run(backendapp, host="0.0.0.0", port=param.base.port, app_dir="backend")
|
uvicorn.run(backendapp, host="0.0.0.0", port=param.base.port, app_dir="backend", log_config=log_config)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user