You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/zrpc/internal/rpclogger.go

82 lines
1.8 KiB
Go

4 years ago
package internal
4 years ago
import (
"github.com/zeromicro/go-zero/core/logx"
4 years ago
"google.golang.org/grpc/grpclog"
)
// because grpclog.errorLog is not exported, we need to define our own.
const errorLevel = 2
// A Logger is a rpc logger.
4 years ago
type Logger struct{}
func init() {
grpclog.SetLoggerV2(new(Logger))
4 years ago
}
// Error logs the given args into error log.
func (l *Logger) Error(args ...any) {
4 years ago
logx.Error(args...)
}
// Errorf logs the given args with format into error log.
func (l *Logger) Errorf(format string, args ...any) {
4 years ago
logx.Errorf(format, args...)
}
// Errorln logs the given args into error log with newline.
func (l *Logger) Errorln(args ...any) {
4 years ago
logx.Error(args...)
}
// Fatal logs the given args into error log.
func (l *Logger) Fatal(args ...any) {
4 years ago
logx.Error(args...)
}
// Fatalf logs the given args with format into error log.
func (l *Logger) Fatalf(format string, args ...any) {
4 years ago
logx.Errorf(format, args...)
}
// Fatalln logs args into error log with newline.
func (l *Logger) Fatalln(args ...any) {
4 years ago
logx.Error(args...)
}
// Info ignores the grpc info logs.
func (l *Logger) Info(args ...any) {
4 years ago
// ignore builtin grpc info
}
// Infoln ignores the grpc info logs.
func (l *Logger) Infoln(args ...any) {
4 years ago
// ignore builtin grpc info
}
// Infof ignores the grpc info logs.
func (l *Logger) Infof(format string, args ...any) {
4 years ago
// ignore builtin grpc info
}
// V checks if meet required log level.
4 years ago
func (l *Logger) V(v int) bool {
return v >= errorLevel
}
// Warning ignores the grpc warning logs.
func (l *Logger) Warning(args ...any) {
4 years ago
// ignore builtin grpc warning
}
// Warningf ignores the grpc warning logs.
func (l *Logger) Warningf(format string, args ...any) {
4 years ago
// ignore builtin grpc warning
}
// Warningln ignores the grpc warning logs.
func (l *Logger) Warningln(args ...any) {
4 years ago
// ignore builtin grpc warning
}