-
Notifications
You must be signed in to change notification settings - Fork 2
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
input: output: Bind log api from fluent-bit #20
Conversation
Signed-off-by: Hiroshi Hatake <[email protected]>
@nicolasparada Could you add logging interface in top of this PR? |
Signed-off-by: Hiroshi Hatake <[email protected]>
Signed-off-by: Hiroshi Hatake <[email protected]>
Signed-off-by: Hiroshi Hatake <[email protected]>
Signed-off-by: Hiroshi Hatake <[email protected]>
I tried to implement Logger interface for Golang plugin. |
Is the log level always required? We can have something like: logger.Log(msg, args...)
level.Error(logger).Log(msg, args...) If we can skip the log level. |
Oh, good point. In fluent-bit's logging system, log level is always required. But, in Golang world, we can implement a builder for constructing logger. |
That's ok, if it always required in fluent-bit, we can follow that with Go too. |
cshared.go
Outdated
@@ -325,3 +376,7 @@ func makeMetrics(cmp *cmetrics.Context) Metrics { | |||
}, | |||
} | |||
} | |||
|
|||
func GetLogger() Logger { | |||
return logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't make this a package level thing.
Maybe Init()
method on the plugin could receive it in its args.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Init()
is already receiving too many args.
ctx context.Context
conf plugin.ConfigLoader
metrics plugin.Metrics
And adding plugin.Logger
to those... Maybe we can pass a struct with all of those in there.
type Fluentbit struct {
Conf plugin.ConfigLoader
Metrics plugin.Metrics
Logger plugin.Logger
}
Init()
can now looks like this:
func (myPlugin) Init(ctx context.Context, fbit plugin.Fluentbit) error {
fbit.Config.String("some_param")
fbit.Metrics.NewCounter("my_counter", "desc")
fbit.Logger.Info("calling init")
return nil
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I implemented your suggestion. ¡Genial!
… in the same struct Signed-off-by: Hiroshi Hatake <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cosmo0920 2 things I would like to add 👍🏻
- Please expand the README.md with an example that uses logger.
- Please add a test to validate that logger works in the dummy plugin
Thanks!
Signed-off-by: Hiroshi Hatake <[email protected]>
f02213b
to
d6c6972
Compare
I added the commit to reflect the argument changes on Init |
I think that we should do in test plugins that is implemented in testdata. |
9d29fd3
to
c10404c
Compare
Oh, CI is failed. I'll take a look later. |
Signed-off-by: Hiroshi Hatake <[email protected]>
c10404c
to
c01ccbf
Compare
Signed-off-by: Hiroshi Hatake <[email protected]>
Signed-off-by: Hiroshi Hatake <[email protected]>
CI got green! 💚 |
Related to #19.
I binded the fundamental APIs to use fluent-bit's logging mechanism.
With this patch, we can call
flb_log_print
andflb_log_check
via flb_api interface.Signed-off-by: Hiroshi Hatake [email protected]