Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate logrus logger to aws and grpc packages #60

Merged
merged 2 commits into from
Jul 8, 2020

Conversation

Calebjh
Copy link
Contributor

@Calebjh Calebjh commented Jul 7, 2020

Uses the Options pattern to simplify the function signature when the default logger is fine.

@Calebjh Calebjh requested review from razamiDev and burov July 7, 2020 20:53
@codecov
Copy link

codecov bot commented Jul 7, 2020

Codecov Report

Merging #60 into master will decrease coverage by 1.15%.
The diff coverage is 63.38%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #60      +/-   ##
==========================================
- Coverage   69.82%   68.67%   -1.16%     
==========================================
  Files           6        6              
  Lines         759      779      +20     
==========================================
+ Hits          530      535       +5     
- Misses        210      222      +12     
- Partials       19       22       +3     
Impacted Files Coverage Δ
aws/aws.go 89.94% <42.85%> (ø)
aws/publisher.go 78.78% <53.33%> (-13.81%) ⬇️
aws/subscriber.go 78.77% <59.09%> (-2.27%) ⬇️
grpc/server.go 89.24% <77.77%> (-4.81%) ⬇️

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 e90d2a0...1554c4f. Read the comment docs.

Copy link

@burov burov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, just a couple things, can we log errors with Errorf instead of Infof and i see we use logrus package but in toolkit we have logger wich already setuped to use common format for atlas logs, what about using it ?

just one thing per what i see we use logrus package but we h

grpc/server.go Outdated Show resolved Hide resolved
@Calebjh Calebjh requested a review from burov July 7, 2020 22:01
func newPublisher(snsClient snsiface.SNSAPI, topic string, opts ...PublisherOption) (*publisher, error) {
p := publisher{
sns: snsClient,
logger: logrus.StandardLogger(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this logger will be overrided, but maybe it will be better to use toolkit logger with some default level (logrus.InfoLevel) as a default logger? It up to you, for me it seems more consistent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this. I decided that using the StandardLogger seemed to make more sense as the default. This also allows using the global Logrus functions to change the behavior of this internal logging without having to make further changes (https://github.com/sirupsen/logrus/blob/master/exported.go#L14-L37)

func newSubscriber(snsClient snsiface.SNSAPI, sqsClient sqsiface.SQSAPI, topic, subscriptionID string) (*awsSubscriber, error) {
subscriber := awsSubscriber{sns: snsClient, sqs: sqsClient, topic: topic, subscriptionID: subscriptionID}
func newSubscriber(snsClient snsiface.SNSAPI, sqsClient sqsiface.SQSAPI, topic, subscriptionID string, opts ...SubscriberOption) (*awsSubscriber, error) {
subscriber := awsSubscriber{sns: snsClient, sqs: sqsClient, topic: topic, subscriptionID: subscriptionID, logger: logrus.StandardLogger()}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this logger will be overrided, but maybe it will be better to use toolkit logger with some default level (logrus.InfoLevel) as a default logger? It up to you, for me it seems more consistent

@Calebjh Calebjh merged commit 2367226 into infobloxopen:master Jul 8, 2020
@Calebjh Calebjh deleted the log-refactor branch July 8, 2020 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants