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

use interface instead *logrus.Logger in plugin klogrus #619

Merged
merged 1 commit into from
Dec 28, 2023

Conversation

peczenyj
Copy link
Contributor

Hello

We use some wrappers around *logrus.Logger and we don't want to write a wrapper each time we need to set the kafka logger

Instead, since most of the time we use logrus.FieldLogger with some extra methods, I decided to send this small contribution where we can use this minimal interface

// FieldLogger interface.
type FieldLogger interface {
	logrus.FieldLogger
	GetLevel() logrus.Level
}

The result is still compatible with logrus, but on steroids.

I was thinking in use the pure logrus.FieldLogger and store the log level (using two constructors, for instance) but I think we need to react to possible changes in the log level in runtime. This solution is cleaner

Also I add one test based on kslog plugin.

Enjoy

@twmb
Copy link
Owner

twmb commented Nov 27, 2023

Technically this is a "major" change since the input type changed. What do you think about making this a minor change by adding a new API, NewFieldLogger?

@peczenyj
Copy link
Contributor Author

Sure, will work on it

@peczenyj
Copy link
Contributor Author

done @twmb

twmb
twmb previously approved these changes Dec 3, 2023
Copy link
Owner

@twmb twmb left a comment

Choose a reason for hiding this comment

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

Nice, thanks

plugin/klogrus/klogrus.go Outdated Show resolved Hide resolved
plugin/klogrus/klogrus.go Outdated Show resolved Hide resolved
plugin/klogrus/klogrus.go Outdated Show resolved Hide resolved
@twmb
Copy link
Owner

twmb commented Dec 3, 2023

Can you squash all of these changes into one commit? Also still need the period dropped on that doc line I commented on

@peczenyj
Copy link
Contributor Author

peczenyj commented Dec 4, 2023

squash done

twmb
twmb previously approved these changes Dec 4, 2023
Copy link
Owner

@twmb twmb left a comment

Choose a reason for hiding this comment

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

nice thanks, I'll release this likely today

@peczenyj peczenyj reopened this Dec 21, 2023
@twmb
Copy link
Owner

twmb commented Dec 21, 2023

I haven't forgotten, just got behind. Why changes today?

@peczenyj
Copy link
Contributor Author

I had some free time :)

@twmb
Copy link
Owner

twmb commented Dec 28, 2023

Apologies on the delay, lgtm, I'll tag imminently.

@twmb twmb merged commit 98f95bc into twmb:master Dec 28, 2023
3 checks passed
@twmb
Copy link
Owner

twmb commented Dec 28, 2023

Released as plugin/klogrus/v1.1.0. I think v1.10.0 was tagged incorrectly with an @ rather than a /, so at least v1.1.0 is correct.

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