From 23d09504bd1fd0a18d5f3627038e35e98054971f Mon Sep 17 00:00:00 2001 From: heedaeshin Date: Mon, 14 Oct 2024 16:51:34 +0900 Subject: [PATCH] Fix : rdbc mysql logger change --- pkg/rdbms/mysql/mysql.go | 4 ++-- service/rdbc/rdbc.go | 10 +++++----- web/templates/mig-mysql.html | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/rdbms/mysql/mysql.go b/pkg/rdbms/mysql/mysql.go index 596b89a..bfe3fdb 100644 --- a/pkg/rdbms/mysql/mysql.go +++ b/pkg/rdbms/mysql/mysql.go @@ -75,7 +75,7 @@ func (d *MysqlDBMS) Exec(query string) error { FormatNCPDatabaseCreateSQL(d.provider, &query) _, retryErr := d.db.Exec(query) if retryErr != nil { - log.Error().Err(retryErr).Str("targetProvider", string(d.provider)).Str("query", query).Msg("Failed to execute transformed NCP SQL query") + log.Error().Err(retryErr).Str("Provider", string(d.provider)).Str("tagetProvider", string(d.provider)).Str("query", query).Msg("Failed to execute transformed NCP SQL query") return retryErr } } @@ -336,7 +336,7 @@ func extractDatabaseInfo(sql string) (string, string, string) { // extract DBname func extractDatabaseName(sql string) string { - re := regexp.MustCompile(`(?i)CREATE\s+DATABASE\s+(?:/\*.*?\*/\s*)?(?:IF\s+NOT\s+EXISTS\s+)?\s*` + `([^\s;]+)`) + re := regexp.MustCompile(`(?i)CREATE\s+DATABASE\s+(?:/\*.*?\*/\s*)?(?:IF\s+NOT\s+EXISTS\s+)?\s*` + "`?" + `([^\s;` + "`" + `]+)` + "`?") match := re.FindStringSubmatch(sql) if len(match) >= 2 { // Remove any trailing semicolon if present diff --git a/service/rdbc/rdbc.go b/service/rdbc/rdbc.go index cb2e4fe..4ef668a 100644 --- a/service/rdbc/rdbc.go +++ b/service/rdbc/rdbc.go @@ -63,6 +63,7 @@ func WithLogger(logger *zerolog.Logger) Option { } func New(rdb RDBMS, opts ...Option) (*RDBController, error) { + rdbc := &RDBController{ client: rdb, logger: nil, @@ -98,7 +99,7 @@ func (rdb *RDBController) Put(sql string) error { if line != "" { err = rdb.client.Exec(line) if err != nil { - rdb.logger.Error().Msgf("err Line : %+v", line) + log.Error().Msgf("err Line : %+v", line) rdb.logWrite("Error", "sql exec error", err) return err } @@ -116,7 +117,7 @@ func (rdb *RDBController) Put(sql string) error { func (rdb *RDBController) PutDoc(sql string) error { err := rdb.client.Exec(sql) if err != nil { - rdb.logger.Error().Msgf("err SQL : %+v", sql) + log.Error().Msgf("err SQL : %+v", sql) rdb.logWrite("Error", "sql exec error", err) return err } @@ -131,7 +132,6 @@ func (rdb *RDBController) Copy(dst *RDBController) error { rdb.logWrite("Error", "ListDB error", err) return err } - for _, db := range dbList { sql = "" rdb.client.SetTargetProvdier(dst.client.GetProvdier()) @@ -223,9 +223,9 @@ func (rdbc *RDBController) logWrite(logLevel, msg string, err error) { if rdbc.logger != nil { switch logLevel { case "Info": - rdbc.logger.Info().Msg(msg) + log.Info().Msg(msg) case "Error": - rdbc.logger.Error().Msgf("%s : %v", msg, err) + log.Error().Msgf("%s : %v", msg, err) } } } diff --git a/web/templates/mig-mysql.html b/web/templates/mig-mysql.html index 29185be..1916126 100644 --- a/web/templates/mig-mysql.html +++ b/web/templates/mig-mysql.html @@ -20,7 +20,7 @@

마이그레이션 MySQL

- @@ -64,7 +64,7 @@

마이그레이션 MySQL

-