mirror of
https://github.com/coaidev/coai.git
synced 2025-05-21 14:00:13 +09:00
chore: update mysql connection error message and logger style
This commit is contained in:
parent
84485eae16
commit
fea7442b85
@ -62,6 +62,7 @@
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
touch-action: pan-y;
|
touch-action: pan-y;
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
|
white-space: pre-wrap !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.console-icon {
|
.console-icon {
|
||||||
|
@ -29,11 +29,11 @@ func ConnectMySQL() *sql.DB {
|
|||||||
viper.GetInt("mysql.port"),
|
viper.GetInt("mysql.port"),
|
||||||
viper.GetString("mysql.db"),
|
viper.GetString("mysql.db"),
|
||||||
))
|
))
|
||||||
if err != nil || db.Ping() != nil {
|
if pingErr := db.Ping(); err != nil || pingErr != nil {
|
||||||
|
errMsg := utils.Multi[string](err != nil, utils.GetError(err), utils.GetError(pingErr)) // err.Error() may contain nil pointer
|
||||||
globals.Warn(
|
globals.Warn(
|
||||||
fmt.Sprintf("[connection] failed to connect to mysql server: %s (message: %s), will retry in 5 seconds",
|
fmt.Sprintf("[connection] failed to connect to mysql server: %s (message: %s), will retry in 5 seconds",
|
||||||
viper.GetString("mysql.host"),
|
viper.GetString("mysql.host"), errMsg,
|
||||||
utils.GetError(err), // err.Error() may contain nil pointer
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user