Skip to content

Commit

Permalink
Fix : rdbc mysql logger change
Browse files Browse the repository at this point in the history
  • Loading branch information
heedaeshin committed Oct 14, 2024
1 parent e2fec21 commit 23d0950
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pkg/rdbms/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions service/rdbc/rdbc.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func WithLogger(logger *zerolog.Logger) Option {
}

func New(rdb RDBMS, opts ...Option) (*RDBController, error) {

rdbc := &RDBController{
client: rdb,
logger: nil,
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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())
Expand Down Expand Up @@ -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)
}
}
}
4 changes: 2 additions & 2 deletions web/templates/mig-mysql.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1 class="mt-4">마이그레이션 MySQL</h1>

<div class="input-group mb-3">
<span class="input-group-text"><i class="fa-solid fa-cloud"></i></span>
<select class="form-select" id="srcProvider" name="srcProvider">
<select class="form-select" id="sourcePoint[provider]" name="sourcePoint[provider]">
<option value="aws">AWS</option>
<option value="gcp">GCP</option>
<option value="ncp">NCP</option>
Expand Down Expand Up @@ -64,7 +64,7 @@ <h1 class="mt-4">마이그레이션 MySQL</h1>

<div class="input-group mb-3">
<span class="input-group-text"><i class="fa-solid fa-cloud"></i></span>
<select class="form-select" id="destProvider" name="destProvider">
<select class="form-select" id="targetPoint[provider]" name="targetPoint[provider]">
<option value="aws">AWS</option>
<option value="gcp">GCP</option>
<option value="ncp">NCP</option>
Expand Down

0 comments on commit 23d0950

Please sign in to comment.