Skip to content

Commit

Permalink
Use prefix in all vtorc check and recover logs (vitessio#17526)
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo J. Ortega U. <[email protected]>
  • Loading branch information
ejortegau committed Jan 23, 2025
1 parent bb6271b commit b53e761
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 62 deletions.
91 changes: 91 additions & 0 deletions go/vt/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,94 @@ func (lrms *logRotateMaxSize) String() string {
func (lrms *logRotateMaxSize) Type() string {
return "uint64"
}

type PrefixedLogger struct {
prefix string
}

func NewPrefixedLogger(prefix string) *PrefixedLogger {
return &PrefixedLogger{prefix: prefix + ": "}
}

func (pl *PrefixedLogger) V(level glog.Level) glog.Verbose {
return V(level)
}

func (pl *PrefixedLogger) Flush() {
Flush()
}

func (pl *PrefixedLogger) Info(args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Info(args...)
}

func (pl *PrefixedLogger) Infof(format string, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Infof("%s"+format, args...)
}

func (pl *PrefixedLogger) InfoDepth(depth int, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
InfoDepth(depth, args...)
}

func (pl *PrefixedLogger) Warning(args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Warning(args...)
}

func (pl *PrefixedLogger) Warningf(format string, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Warningf("%s"+format, args...)
}

func (pl *PrefixedLogger) WarningDepth(depth int, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
WarningDepth(depth, args...)
}

func (pl *PrefixedLogger) Error(args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Error(args...)
}

func (pl *PrefixedLogger) Errorf(format string, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Errorf("%s"+format, args...)
}

func (pl *PrefixedLogger) ErrorDepth(depth int, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
ErrorDepth(depth, args...)
}

func (pl *PrefixedLogger) Exit(args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Exit(args...)
}

func (pl *PrefixedLogger) Exitf(format string, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Exitf("%s"+format, args...)
}

func (pl *PrefixedLogger) ExitDepth(depth int, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
ExitDepth(depth, args...)
}

func (pl *PrefixedLogger) Fatal(args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Fatal(args...)
}

func (pl *PrefixedLogger) Fatalf(format string, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
Fatalf("%s"+format, args...)
}

func (pl *PrefixedLogger) FatalDepth(depth int, args ...any) {
args = append([]interface{}{pl.prefix}, args...)
FatalDepth(depth, args...)
}
3 changes: 2 additions & 1 deletion go/vt/vtorc/logic/disable_recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ package logic
// go to the database each time.

import (
"errors"
"fmt"

"vitess.io/vitess/go/vt/external/golib/sqlutils"
Expand All @@ -55,7 +56,7 @@ func IsRecoveryDisabled() (disabled bool, err error) {
if err != nil {
errMsg := fmt.Sprintf("recovery.IsRecoveryDisabled(): %v", err)
log.Errorf(errMsg)
err = fmt.Errorf(errMsg)
err = errors.New(errMsg)
}
return disabled, err
}
Expand Down
Loading

0 comments on commit b53e761

Please sign in to comment.