Skip to content

Commit

Permalink
feat: 日志记录迁移到 sspeedup
Browse files Browse the repository at this point in the history
  • Loading branch information
FHU-yezi committed Jun 13, 2024
1 parent b6fa09b commit cbe5087
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 21 deletions.
33 changes: 26 additions & 7 deletions backend/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ uvicorn = "^0.30.0"
httptools = "^0.6.0"
uvloop = "^0.19.0"
jkit = "^3.0.0a16"
sshared = "^0.5.0"

[tool.poetry.group.dev.dependencies]
ruff = "^0.4.0"
Expand Down
5 changes: 3 additions & 2 deletions backend/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ nodeenv==1.9.1 ; python_version >= "3.8" and python_version < "4.0"
polyfactory==2.16.0 ; python_version >= "3.8" and python_version < "4.0"
pygments==2.18.0 ; python_version >= "3.8" and python_version < "4.0"
pymongo==4.7.3 ; python_version >= "3.8" and python_version < "4.0"
pyright==1.1.366 ; python_version >= "3.8" and python_version < "4.0"
pyright==1.1.367 ; python_version >= "3.8" and python_version < "4.0"
python-dateutil==2.9.0.post0 ; python_version >= "3.8" and python_version < "4.0"
pyyaml==6.0.1 ; python_version >= "3.8" and python_version < "4.0"
rich-click==1.8.2 ; python_version >= "3.8" and python_version < "4.0"
rich-click==1.8.3 ; python_version >= "3.8" and python_version < "4.0"
rich==13.7.1 ; python_version >= "3.8" and python_version < "4.0"
ruff==0.4.8 ; python_version >= "3.8" and python_version < "4.0"
six==1.16.0 ; python_version >= "3.8" and python_version < "4.0"
sniffio==1.3.1 ; python_version >= "3.8" and python_version < "4.0"
sshared==0.5.1 ; python_version >= "3.8" and python_version < "4.0"
sspeedup[api-litestar,config,logging]==0.25.1 ; python_version >= "3.8" and python_version < "4.0"
typing-extensions==4.12.2 ; python_version >= "3.8" and python_version < "4.0"
uvicorn==0.30.1 ; python_version >= "3.8" and python_version < "4.0"
Expand Down
3 changes: 2 additions & 1 deletion backend/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ pygments==2.18.0 ; python_version >= "3.8" and python_version < "4.0"
pymongo==4.7.3 ; python_version >= "3.8" and python_version < "4.0"
python-dateutil==2.9.0.post0 ; python_version >= "3.8" and python_version < "4.0"
pyyaml==6.0.1 ; python_version >= "3.8" and python_version < "4.0"
rich-click==1.8.2 ; python_version >= "3.8" and python_version < "4.0"
rich-click==1.8.3 ; python_version >= "3.8" and python_version < "4.0"
rich==13.7.1 ; python_version >= "3.8" and python_version < "4.0"
six==1.16.0 ; python_version >= "3.8" and python_version < "4.0"
sniffio==1.3.1 ; python_version >= "3.8" and python_version < "4.0"
sshared==0.5.1 ; python_version >= "3.8" and python_version < "4.0"
sspeedup[api-litestar,config,logging]==0.25.1 ; python_version >= "3.8" and python_version < "4.0"
typing-extensions==4.12.2 ; python_version >= "3.8" and python_version < "4.0"
uvicorn==0.30.1 ; python_version >= "3.8" and python_version < "4.0"
Expand Down
8 changes: 4 additions & 4 deletions backend/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

from utils.config import config

_DB_CLIENT = AsyncIOMotorClient(config.db.host, config.db.port)
_MAIN_DB = _DB_CLIENT[config.db.database]
_JFETCHER_DB = _DB_CLIENT["JFetcherData"]
_CLIENT = AsyncIOMotorClient(config.db.host, config.db.port)
MAIN_DB = _CLIENT[config.db.database]
_JFETCHER_DB = _CLIENT["JFetcherData"]

RUN_LOG_COLLECTION = _MAIN_DB["run_log"]
RUN_LOG_COLLECTION = MAIN_DB["run_log"]
ARTICLE_FP_RANK_COLLECTION = _JFETCHER_DB["article_FP_rank"]
LOTTERY_COLLECTION = _JFETCHER_DB["lottery_data"]
LP_COLLECTIONS_COLLECTION = _JFETCHER_DB["LP_collections"]
Expand Down
15 changes: 9 additions & 6 deletions backend/utils/log.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from sspeedup.logging.run_logger import RunLogger
from pymongo import MongoClient
from sshared.logging import Logger

from utils.config import config
from utils.db import RUN_LOG_COLLECTION

logger = RunLogger(
save_level=config.log.save_level,
print_level=config.log.print_level,
mongo_collection=RUN_LOG_COLLECTION,
_client = MongoClient()

logger = Logger(
# TODO
save_level=config.log.save_level.value, # type: ignore
display_level=config.log.print_level.value, # type: ignore
save_collection=_client[config.db.database].log,
)
Binary file modified frontend/bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"wouter-preact": "^3.2.0"
},
"devDependencies": {
"@biomejs/biome": "^1.8.0",
"@biomejs/biome": "^1.8.1",
"rollup-plugin-visualizer": "^5.12.0"
}
}

0 comments on commit cbe5087

Please sign in to comment.