fluent-bit-go
fluent-bit-go copied to clipboard
Access to logger
I implemented a redis output plugin: https://github.com/majst01/fluent-bit-go-redis-output and i want to log errors during configuration parsing or processing. Currently i do this with a simple fmt.Printf(). This is not perfect as this will come out on stdout instead of the configured log destination. It also does look different than other existing log entries and there is not destinction between info/debug/error etc.
I have already seen in flb_log.h there are already handy macros defined:
/* Logging macros */
#define flb_error(fmt, ...) \
if (flb_log_check(FLB_LOG_ERROR)) \
flb_log_print(FLB_LOG_ERROR, NULL, 0, fmt, ##__VA_ARGS__)
#define flb_warn(fmt, ...) \
if (flb_log_check(FLB_LOG_WARN)) \
flb_log_print(FLB_LOG_WARN, NULL, 0, fmt, ##__VA_ARGS__)
#define flb_info(fmt, ...) \
if (flb_log_check(FLB_LOG_INFO)) \
flb_log_print(FLB_LOG_INFO, NULL, 0, fmt, ##__VA_ARGS__)
but the current implementation of fluent-bit-go does not expose them to to golang interface. Can someone give hints howto start, im willing to implement this or help someone to do so.
Greetings and congrats to this simple but working api !
This sounds like a good idea. It would extend the ABI between fluent-bit and the plugin .so to share a pointer to this function. Perhaps this could be added to struct flb_api since that is already a container for function pointers that point back to functions implemented in fluent-bit:
https://github.com/fluent/fluent-bit-go/blob/51032bd05190bd178085a56c410706696fbd3177/output/flb_output.h#L25-L27
This is a bit of a stale issue but if you are still interested in working on this I would be willing to help. Just ping me on the fluent slack.
Hi,
still interested, gimmi some time to join
done
FYI: this is a must, feel free to send the PR
Cgo does not support calling variadic C functions, so we could only implement a wrapper for flb_error("%s", x);, etc.
https://golang.org/cmd/cgo/
Hi, I'd like to work on this, but being a total Go beginner, I'm having a hard time to start. Precisely, I can't understand how to edit a 3rd party package in general.
I forked this repo and then tried to import it by changing the import url, go mod tidy, go get <my_url>
But i keep getting
go: downloading github.com/brisa-robotics/fluent-bit-go v0.0.0-20221204101412-4d1575bac6fe
go: github.com/brisa-robotics/[email protected]: parsing go.mod:
module declares its path as: github.com/fluent/fluent-bit-go
but was required as: github.com/brisa-robotics/fluent-bit-go
Is there a way to a local directory otherwise? Thanks