123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package grpclog
- import (
- "fmt"
- )
- type PrefixLogger struct {
- logger DepthLoggerV2
- prefix string
- }
- func (pl *PrefixLogger) Infof(format string, args ...interface{}) {
- if pl != nil {
-
- format = pl.prefix + format
- pl.logger.InfoDepth(1, fmt.Sprintf(format, args...))
- return
- }
- InfoDepth(1, fmt.Sprintf(format, args...))
- }
- func (pl *PrefixLogger) Warningf(format string, args ...interface{}) {
- if pl != nil {
- format = pl.prefix + format
- pl.logger.WarningDepth(1, fmt.Sprintf(format, args...))
- return
- }
- WarningDepth(1, fmt.Sprintf(format, args...))
- }
- func (pl *PrefixLogger) Errorf(format string, args ...interface{}) {
- if pl != nil {
- format = pl.prefix + format
- pl.logger.ErrorDepth(1, fmt.Sprintf(format, args...))
- return
- }
- ErrorDepth(1, fmt.Sprintf(format, args...))
- }
- func (pl *PrefixLogger) Debugf(format string, args ...interface{}) {
- if !Logger.V(2) {
- return
- }
- if pl != nil {
-
- format = pl.prefix + format
- pl.logger.InfoDepth(1, fmt.Sprintf(format, args...))
- return
- }
- InfoDepth(1, fmt.Sprintf(format, args...))
- }
- func NewPrefixLogger(logger DepthLoggerV2, prefix string) *PrefixLogger {
- return &PrefixLogger{logger: logger, prefix: prefix}
- }
|