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

Access to logger #8

Open
majst01 opened this issue Nov 28, 2017 · 7 comments
Open

Access to logger #8

majst01 opened this issue Nov 28, 2017 · 7 comments
Assignees

Comments

@majst01
Copy link

majst01 commented Nov 28, 2017

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 !

@jasonkeene
Copy link

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:

struct flb_api {
char *(*output_get_property) (char *, void *);
};

@jasonkeene
Copy link

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.

@majst01
Copy link
Author

majst01 commented Apr 17, 2019

Hi,

still interested, gimmi some time to join

@majst01
Copy link
Author

majst01 commented Apr 20, 2019

done

@edsiper
Copy link
Member

edsiper commented Apr 21, 2019

FYI: this is a must, feel free to send the PR

@l2dy
Copy link
Contributor

l2dy commented Oct 28, 2019

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/

@Minipada
Copy link

Minipada commented Dec 4, 2022

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

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

6 participants