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

[Request] Log Callback API #60

Open
gudenau opened this issue Nov 6, 2023 · 0 comments
Open

[Request] Log Callback API #60

gudenau opened this issue Nov 6, 2023 · 0 comments

Comments

@gudenau
Copy link

gudenau commented Nov 6, 2023

Instead of dumping everything into the standard error/out streams or disabling logging all together via env vars (setenv("RUST_LOG", "off", true)).

I propose an API similar to the following:

// Adjust for actual usage in the backing code.
typedef enum {
    WOOTING_LOG_INFO,
    WOOTING_LOG_WARNING,
    WOOTING_LOG_ERROR,
    WOOTING_LOG_FATAL,
} WootingAnalogLogLevel;

typedef void (*WootingAnalogLogFunction)(WootingAnalogLogLevel level, const char* location, const char* message, void* user);

/// Sets the logging callback for the analog SDK. Passing `null` sets the logging backend to the default one.
/// Returns the previous log callback or `null` if none was present.
///
/// This can be called before wooting_analog_initialize,
WootingAnalogLogFunction wooting_analog_log_callback(WootingAnalogLogFunction callback, void* user);

Something similar to this should be fairly flexible but at the same time should not change the existing behavior of the library.

(This is related to #42 but I didn't consider it a duplicate)

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

1 participant