优化MysqlConnection日志
This commit is contained in:
@@ -10,13 +10,13 @@ class MySQLConnectPool {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.pool = this.createConnectPool();
|
this.pool = this.createConnectPool();
|
||||||
this.logger.info("[MySQL] 数据库连接池已创建")
|
this.logger.info("数据库连接池已创建")
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
let res = await this.testConnection();
|
let res = await this.testConnection();
|
||||||
if (res)
|
if (res)
|
||||||
this.logger.info("[MySQL] 数据库测试成功")
|
this.logger.info("数据库测试成功")
|
||||||
else
|
else
|
||||||
this.logger.error("[MySQL] 数据库测试失败")
|
this.logger.error("数据库测试失败")
|
||||||
}, 10);
|
}, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ class MySQLConnectPool {
|
|||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(`[MySQL] 数据库测试发生了错误:` + error);
|
this.logger.error(`数据库测试发生了错误:` + error);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ class MySQLConnectPool {
|
|||||||
let [rows, fields] = await connection.execute(sql, values);
|
let [rows, fields] = await connection.execute(sql, values);
|
||||||
return rows;
|
return rows;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error("[MySQL] 数据库发生错误:" + error, '\n##', sql, '\n##', JSON.stringify(values));
|
this.logger.error("数据库发生错误:" + error, '\n##', sql, '\n##', JSON.stringify(values));
|
||||||
return undefined;
|
return undefined;
|
||||||
} finally {
|
} finally {
|
||||||
if (database)
|
if (database)
|
||||||
|
|||||||
Reference in New Issue
Block a user