Skip to content

Commit

Permalink
Use prefix in all vtorc check and recover logs (#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 authored Jan 23, 2025
1 parent 1d57f39 commit 91dd79d
Show file tree
Hide file tree
Showing 3 changed files with 184 additions and 55 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...)
}
Loading

0 comments on commit 91dd79d

Please sign in to comment.