|
@@ -73,15 +73,17 @@ TEMPLATES = [
|
|
WSGI_APPLICATION = 'Ansjer.local_wsgi.application'
|
|
WSGI_APPLICATION = 'Ansjer.local_wsgi.application'
|
|
|
|
|
|
# 服务器类型
|
|
# 服务器类型
|
|
-DATABASE_DATA = 'AnsjerTest'
|
|
|
|
|
|
+DATABASE_DATA = 'ansjerlocal'
|
|
SERVER_HOST = '127.0.0.1'
|
|
SERVER_HOST = '127.0.0.1'
|
|
DATABASES_USER = 'root'
|
|
DATABASES_USER = 'root'
|
|
-DATABASES_PASS = 'mysqlfyzs9wl'
|
|
|
|
|
|
+DATABASES_PASS = '123456'
|
|
|
|
|
|
-DATABASE_DATA2 = 'AnsjerTest'
|
|
|
|
|
|
+DATABASE_DATA2 = 'ansjerpush'
|
|
SERVER_HOST2 = '127.0.0.1'
|
|
SERVER_HOST2 = '127.0.0.1'
|
|
DATABASES_USER2 = 'root'
|
|
DATABASES_USER2 = 'root'
|
|
-DATABASES_PASS2 = 'mysqlfyzs9wl'
|
|
|
|
|
|
+DATABASES_PASS2 = '123456'
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
DATABASES = {
|
|
DATABASES = {
|
|
'default': {
|
|
'default': {
|
|
@@ -94,20 +96,20 @@ DATABASES = {
|
|
'OPTIONS': {'charset': 'utf8mb4', 'use_unicode': True, 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"},
|
|
'OPTIONS': {'charset': 'utf8mb4', 'use_unicode': True, 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"},
|
|
'AUTOCOMMIT': True
|
|
'AUTOCOMMIT': True
|
|
},
|
|
},
|
|
- # 'mysql02': {
|
|
|
|
- # 'ENGINE': 'django.db.backends.mysql',
|
|
|
|
- # 'NAME': DATABASE_DATA2,
|
|
|
|
- # 'USER': DATABASES_USER2,
|
|
|
|
- # 'PASSWORD': DATABASES_PASS2,
|
|
|
|
- # 'HOST': SERVER_HOST2,
|
|
|
|
- # 'PORT': '3306',
|
|
|
|
- # 'OPTIONS': {'charset': 'utf8mb4', 'use_unicode': True, 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"},
|
|
|
|
- # 'AUTOCOMMIT': True
|
|
|
|
- # }
|
|
|
|
|
|
+ 'mysql02': {
|
|
|
|
+ 'ENGINE': 'django.db.backends.mysql',
|
|
|
|
+ 'NAME': DATABASE_DATA2,
|
|
|
|
+ 'USER': DATABASES_USER2,
|
|
|
|
+ 'PASSWORD': DATABASES_PASS2,
|
|
|
|
+ 'HOST': SERVER_HOST2,
|
|
|
|
+ 'PORT': '3306',
|
|
|
|
+ 'OPTIONS': {'charset': 'utf8mb4', 'use_unicode': True, 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"},
|
|
|
|
+ 'AUTOCOMMIT': True
|
|
|
|
+ }
|
|
}
|
|
}
|
|
DATABASE_ROUTERS = ['Ansjer.database_router.DatabaseAppsRouter']
|
|
DATABASE_ROUTERS = ['Ansjer.database_router.DatabaseAppsRouter']
|
|
DATABASE_APPS_MAPPING = {
|
|
DATABASE_APPS_MAPPING = {
|
|
- 'db1': 'default',
|
|
|
|
|
|
+ 'Model': 'default',
|
|
'db2': 'mysql02',
|
|
'db2': 'mysql02',
|
|
}
|
|
}
|
|
|
|
|
|
@@ -195,6 +197,12 @@ LOGGING = {
|
|
# 'format': '{"asctime":"%(asctime)s","thread":"%(threadName)s:%(thread)d","errorline":"%(lineno)d","errorlevel":"%(levelname)s","errorcontent":"%(message)s"}'
|
|
# 'format': '{"asctime":"%(asctime)s","thread":"%(threadName)s:%(thread)d","errorline":"%(lineno)d","errorlevel":"%(levelname)s","errorcontent":"%(message)s"}'
|
|
'format': '%(asctime)s %(threadName)s %(thread)d %(lineno)d %(levelname)s %(message)s'
|
|
'format': '%(asctime)s %(threadName)s %(thread)d %(lineno)d %(levelname)s %(message)s'
|
|
},
|
|
},
|
|
|
|
+ 'standard': {
|
|
|
|
+ 'format': '[%(asctime)s] [%(filename)s:%(lineno)d] [%(module)s:%(funcName)s] '
|
|
|
|
+ '[%(levelname)s]- %(message)s'},
|
|
|
|
+ 'simple': { # 简单格式
|
|
|
|
+ 'format': '%(levelname)s %(message)s'
|
|
|
|
+ },
|
|
},
|
|
},
|
|
'filters': {
|
|
'filters': {
|
|
},
|
|
},
|
|
@@ -218,6 +226,16 @@ LOGGING = {
|
|
'class': 'logging.StreamHandler',
|
|
'class': 'logging.StreamHandler',
|
|
'formatter': 'error_format'
|
|
'formatter': 'error_format'
|
|
},
|
|
},
|
|
|
|
+ # 输出info日志
|
|
|
|
+ 'info': {
|
|
|
|
+ 'level': 'INFO',
|
|
|
|
+ 'class': 'logging.handlers.RotatingFileHandler',
|
|
|
|
+ 'filename': BASE_DIR + '/static/log/info.log',
|
|
|
|
+ 'maxBytes': 1024 * 1024 * 5,
|
|
|
|
+ 'backupCount': 5,
|
|
|
|
+ 'formatter': 'standard',
|
|
|
|
+ 'encoding': 'utf-8', # 设置默认编码
|
|
|
|
+ },
|
|
},
|
|
},
|
|
'loggers': {
|
|
'loggers': {
|
|
'django': {
|
|
'django': {
|
|
@@ -227,6 +245,12 @@ LOGGING = {
|
|
'level': 'DEBUG',
|
|
'level': 'DEBUG',
|
|
'propagate': True
|
|
'propagate': True
|
|
},
|
|
},
|
|
|
|
+ # log 调用时需要当作参数传入
|
|
|
|
+ 'log': {
|
|
|
|
+ 'handlers': ['info', 'console', 'default'],
|
|
|
|
+ 'level': 'INFO',
|
|
|
|
+ 'propagate': True
|
|
|
|
+ },
|
|
# 'django.db.backends': {
|
|
# 'django.db.backends': {
|
|
# 'handlers': ['console'],
|
|
# 'handlers': ['console'],
|
|
# 'propagate': True,
|
|
# 'propagate': True,
|