-
Notifications
You must be signed in to change notification settings - Fork 21
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
Custom glib.LogSetWriter #99
Comments
This likely needs improvements, but |
I think that makes sense, as |
Right, it should work. However, there are other ways to initialize GTK without calling Go's |
Maybe using an internal variable that checks if the logger has been added before and then adding it in all of those if it hasnt already been added? |
That could work, but var _ = glib.DontInjectLogger() |
I was more thinking of var logWriterAdded = false And then inside the body of LogSetWriter if logWriterAdded {
return
}
logWriterAdded = true
// Rest of the body
} And then putting the function that sets the default logger at the starz of every method that allows starting the gtk application, but that would also work |
This is hard if not impossible to figure out. You can try and guess it, but other C libraries (e.g. libadwaita) may call the C function on its own and bypass the Go call anyway. Another method could just be introducing our own callback that the user can swap out manually in their |
Both of those should be good, the first one would probably be the simplest to handle ig |
I'm trying to use a custom log writer that uses zerolog, but I'm getting
Error: GLib: g_log_set_writer_func() called multiple times
because of this code in pkg/glib/v2/gmessages.go:
I agree with the note in gir/cmd/gir-generate/gendata/gendata.go that this is referring to
but having that set in an ìnit` function with no way to disable it permanently from inside the application (even putting an init function in main.go that sets the variable doesn't work)
isn't the best approach, as this effectively makes it impossible to use a custom logger afaik. Is there a way around this currently that I'm not seeing or does this need improvement?
The text was updated successfully, but these errors were encountered: