12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import os
- from logging.config import dictConfig
- from src.core.datasource import SERVE_HOST, MYSQL_PASSWORD
- class BaseConfig(object):
- # 数据库的配置
- DIALCT = "mysql"
- DRITVER = "pymysql"
- HOST = SERVE_HOST
- PORT = "3306"
- USERNAME = "root"
- PASSWORD = MYSQL_PASSWORD
- DBNAME = 'libra_bot'
- SQLALCHEMY_DATABASE_URI = f"{DIALCT}+{DRITVER}://{USERNAME}:{PASSWORD}@{HOST}:{PORT}/{DBNAME}?charset=utf8"
- SQLALCHEMY_TRACK_MODIFICATIONS = False # Disable track modifications
- SQLALCHEMY_ECHO = False # Optional: Log SQL queries
- dictConfig({
- "version": 1,
- "disable_existing_loggers": True, # 不覆盖默认配置
- "formatters": { # 日志输出样式
- "default": {
- "format": "%(asctime)s - %(module)s.%(lineno)d - %(levelname)s - %(threadName)s: %(message)s"
- }
- },
- "handlers": {
- "console": {
- "class": "logging.StreamHandler", # 控制台输出
- "level": "DEBUG",
- "formatter": "default",
- },
- # "log_file": {
- # "class": "logging.handlers.TimedRotatingFileHandler", # 按时间切分日志
- # "level": "DEBUG",
- # "formatter": "default", # 日志输出样式对应formatters
- # "filename": "./logs/flask.log", # 指定log文件目录
- # "when": "midnight", # 按天切分,午夜时分创建新文件
- # "interval": 1, # 间隔1天
- # "backupCount": 10, # 保留10天的日志文件
- # "encoding": "utf8", # 文件编码
- # },
- },
- "root": {
- "level": "DEBUG", # # handler中的level会覆盖掉这里的level
- "handlers": ["console"],
- },
- }
- )
|