dev #5
|
@ -3,7 +3,8 @@ __pycache__
|
||||||
.env
|
.env
|
||||||
.vscode/
|
.vscode/
|
||||||
.venv/
|
.venv/
|
||||||
.log
|
.log/
|
||||||
|
*.log
|
||||||
.idea/
|
.idea/
|
||||||
*.idea
|
*.idea
|
||||||
docker/local_redis_file/data
|
docker/local_redis_file/data
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
OAA_CFG__RUN__HOST=0.0.0.0
|
OAA_CFG__RUN__HOST=0.0.0.0
|
||||||
OAA_CFG__RUN__PORT=8000
|
OAA_CFG__RUN__PORT=8000
|
||||||
OAA_CFG__RUN__RELOAD=True
|
OAA_CFG__RUN__RELOAD=True
|
||||||
|
|
||||||
OAA_CFG__LOG__LEVEL=30
|
OAA_CFG__LOG__LEVEL=30
|
||||||
|
OAA_CFG__LOG__LEVEL_TO_FILE=30
|
||||||
|
|
||||||
OAA_CFG__TOKEN__ADMIN=string
|
OAA_CFG__TOKEN__ADMIN=string
|
||||||
OAA_CFG__TOKEN__USER=string
|
OAA_CFG__TOKEN__USER=string
|
||||||
|
|
|
@ -22,9 +22,10 @@ class RunConfig(BaseModel):
|
||||||
|
|
||||||
class LogConfig(BaseModel):
|
class LogConfig(BaseModel):
|
||||||
level: int = 30
|
level: int = 30
|
||||||
|
level_to_file: int = 30
|
||||||
dateformat: str = "%Y-%m-%d %H:%M:%S"
|
dateformat: str = "%Y-%m-%d %H:%M:%S"
|
||||||
format: str = (
|
format: str = (
|
||||||
"[%(asctime)s.%(msecs)03d] %(module)-25s:%(lineno)4d | %(funcName)-20s| %(levelname)-8s | %(message)s"
|
"[%(asctime)s.%(msecs)03d] %(module)-15s:%(lineno)4d | %(funcName)-20s| %(levelname)-8s | %(message)s"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,8 +88,18 @@ class Settings(BaseSettings):
|
||||||
|
|
||||||
conf = Settings()
|
conf = Settings()
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=conf.log.level,
|
level=conf.log.level,
|
||||||
datefmt=conf.log.dateformat,
|
datefmt=conf.log.dateformat,
|
||||||
format=conf.log.format,
|
format=conf.log.format,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
file_handler = logging.FileHandler(BASE_DIR / "logfile.log")
|
||||||
|
file_handler.setLevel(conf.log.level_to_file)
|
||||||
|
file_handler.setFormatter(
|
||||||
|
logging.Formatter(
|
||||||
|
"[%(asctime)s.%(msecs)03d] %(module)s:%(lineno)4d | %(funcName)s| %(levelname)s | %(message)s"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
logging.getLogger().addHandler(file_handler)
|
||||||
|
|
2
main.py
2
main.py
|
@ -20,7 +20,7 @@ main_app = FastAPI(
|
||||||
lifespan=lifespan,
|
lifespan=lifespan,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
log.warning("test")
|
||||||
main_app.include_router(router)
|
main_app.include_router(router)
|
||||||
|
|
||||||
main_app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")
|
main_app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static")
|
||||||
|
|
Loading…
Reference in New Issue