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

expose logger #19

Closed
nicolasparada opened this issue Jun 29, 2022 · 4 comments
Closed

expose logger #19

nicolasparada opened this issue Jun 29, 2022 · 4 comments
Assignees
Milestone

Comments

@nicolasparada
Copy link
Contributor

Expose the logger from fluent-bit so we can write logs using the same format and respect the same level configured in fluent-bit.

@cosmo0920 can you tell me all the levels that fluent-bit has in its logger and whether it is an structured logger or not, so we can come with a nice golang interface.

@cosmo0920
Copy link
Contributor

cosmo0920 commented Jul 1, 2022

I tested to expose fluent-bit's logger interface into Golang world.
But, there is a few issues to handle in Golang side:

  1. We wouldn't handle variable-argument lists at flb_log_print function in Golang caller:
    ref: https://github.com/fluent/fluent-bit/blob/master/src/flb_log.c#L326
    ref: cmd/cgo: cannot call functions with variable-argument lists. golang/go#975

    a. Or, variable-argument lists operation should be proceeded in Golang side with fmt.Sprintf or something equivalent and then passing processed string into exposed log interface?

  2. Only retrieving fluent-bit's log level and a path of log file is better?

I'm not sure which is the better choice for our use case.

@cosmo0920
Copy link
Contributor

I'm considering the following:

  1. We can bind fluent-bit's logging interface with novar (no variable-argument) version.
  2. We can proceed variable-argument with fmt.sprintf or its equivalents before passing binded fluent-bit's logger

@cosmo0920
Copy link
Contributor

I created a PR to handle the first one:

We can bind fluent-bit's logging interface with novar (no variable-argument) version.

@nicolasparada
Copy link
Contributor Author

Off course, the Golang function can use variadic arguments, and build the final string using fmt.Sprint and pass it to fluentbit.

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

No branches or pull requests

3 participants