Hi Adam,
Thanks for the reply! Yeah, the code I posted was just a POC—I would hope to never ship it :)
Working this into setLogger seems a little tricky—how would (native) setLogger know that the logger handle it was given corresponded to a user-defined logger (to invoke over the JNI), or a singleton (that configures the native logger)? Just from the jlong it is given, I don't see a simple way to do this.
An option that makes more sense to me is to have a method setNativeLogger, which takes an enum that specifies an existing, native logger implementation to use. It seems that logger configuration is anyway done through the passed Options class (as described
here), so an enum might be all that needs to be passed to setNativeLogger.
With respect to Ownership: I suppose if the user had a custom logger, set it via setLogger, and then set their logger to a native logger, the custom logger would be leaked. Is that the scenario you're referring to? If so, is that something we need to actively protect against, or do we assume that they will close their resources before doing away with them?
Best,
Neil