Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jun 14, 2023. It is now read-only.

Conversation

@rainbend
Copy link
Member

@rainbend rainbend commented Jan 6, 2022

Background

Now GRPCReporter can only use log.Logger to output logs, but there are many good log libraries, such as zap, logrus, I think we should design a logging interface and let the user decide which one to use.

Design

type Log interface {
	// Info logs to the INFO log.
	Info(args ...interface{})
	// Infof logs to the INFO log.
	Infof(format string, args ...interface{})
	// Warning logs to the WARNING and INFO logs.
	Warn(args ...interface{})
	// Warningf logs to the WARNING and INFO logs.
	Warnf(format string, args ...interface{})
	// Error logs to the ERROR, WARNING, and INFO logs.
	Error(args ...interface{})
	// Errorf logs to the ERROR, WARNING, and INFO logs.
	Errorf(format string, args ...interface{})
}

Use Case

  • golang/log (default)
	logger := log.New(os.Stderr, "go2sky", log.LstdFlags)

	reporter, _ := NewGRPCReporter("127.0.0.1:11800", WithLogger(logger))
  • zap
	logger, _ := zap.NewProduction()
	defer logger.Sync() // flushes buffer, if any
	sugar := logger.Sugar()

	reporter, _ := NewGRPCReporter("127.0.0.1:11800", WithLog(sugar))
  • logrus
	logger := logrus.New()
	
	reporter, _ := NewGRPCReporter("127.0.0.1:11800", WithLog(logger))

@rainbend rainbend added the enhancement New feature or request label Jan 6, 2022
@rainbend rainbend added this to the 1.4.0 milestone Jan 6, 2022
@rainbend rainbend requested review from kagaya85 and wu-sheng January 6, 2022 06:47
@rainbend rainbend linked an issue Jan 6, 2022 that may be closed by this pull request
@codecov-commenter
Copy link

codecov-commenter commented Jan 6, 2022

Codecov Report

Merging #147 (3848d35) into master (a12c5be) will increase coverage by 0.09%.
The diff coverage is 35.71%.

❗ Current head 3848d35 differs from pull request most recent head 40f8f27. Consider uploading reports for the commit 40f8f27 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #147      +/-   ##
==========================================
+ Coverage   70.64%   70.73%   +0.09%     
==========================================
  Files          18       18              
  Lines         930      933       +3     
==========================================
+ Hits          657      660       +3     
  Misses        225      225              
  Partials       48       48              
Impacted Files Coverage Δ
reporter/grpc.go 56.14% <35.71%> (+0.58%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a12c5be...40f8f27. Read the comment docs.

@wu-sheng
Copy link
Member

wu-sheng commented Jan 6, 2022

Could you introduce what is this? I can't see the update in readme doc.

@rainbend
Copy link
Member Author

rainbend commented Jan 6, 2022

Could you introduce what is this? I can't see the update in readme doc.

Description has been added for this PR

@wu-sheng wu-sheng merged commit 4fe3cf3 into master Jan 6, 2022
@wu-sheng wu-sheng deleted the log branch January 6, 2022 12:39
@rainbend rainbend restored the log branch January 6, 2022 13:27
@rainbend rainbend deleted the log branch January 6, 2022 13:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grpc Reporter's logger cannot use custom logger.

4 participants