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

use jul logger by default #66

Merged
merged 5 commits into from
Apr 8, 2023
Merged

use jul logger by default #66

merged 5 commits into from
Apr 8, 2023

Conversation

ortex
Copy link
Member

@ortex ortex commented Apr 2, 2023

fix #3

@ortex ortex requested a review from gavv April 2, 2023 13:35
@gavv
Copy link
Member

gavv commented Apr 3, 2023

Three questions:

  1. We call setCallback during initialization, so by default we use jul logger. But, if the user will set some logger calbback manually, and then will revert it to default by calling setCallback(null), we will use native default logger instead of jul logger, right? I think it should be fixed.

  2. mapLogLevel can throw exception. Is native code that invokes callback ready for exceptions? Maybe better fallback to some specific log level instead of throwing?

    • BTW, if native code is not ready for exceptions, I think we should modify setCallback to suppress exceptions for user-provided callback? E.g. by wrapping in on java side.
  3. In the issue we have this part: We should make sure than on android, default logger will send logs to android log (which can be received with adb logcat). Is it true now with using jul?

@ortex
Copy link
Member Author

ortex commented Apr 3, 2023

@gavv

  1. Agreed
  2. Yeah, we can fallback to some level. Which one? Error?
  3. Yeah, that should be true

BTW, if native code is not ready for exceptions, I think we should modify setCallback to suppress exceptions for user-provided callback? E.g. by wrapping in on java side.

or we can add supporting on JNI leve, e.g:

    env->CallVoidMethod(handler_args.callback, handler_args.methID, levelObj, jmodule, jmess);
    if (env->ExceptionCheck()) {
        env->ExceptionDescribe(); // print exception to stderr
        env->ExceptionClear();
    }

@gavv
Copy link
Member

gavv commented Apr 3, 2023

  1. Yep, I think log error is good fallback.

  2. Support at jni level is even better, agree.

@gavv
Copy link
Member

gavv commented Apr 3, 2023

Probably printing exception to stderr is not great - user may want to disable stderr, or maybe user doesn't have stderr, e.g. on android.

Maybe better print exception to jul?

@ortex ortex force-pushed the improve-logging branch from bf7aff0 to ea0e444 Compare April 5, 2023 11:13
@codecov
Copy link

codecov bot commented Apr 5, 2023

Codecov Report

Merging #66 (731e8ef) into main (c389c3e) will increase coverage by 1.05%.
The diff coverage is 88.00%.

@@             Coverage Diff              @@
##               main      #66      +/-   ##
============================================
+ Coverage     69.84%   70.89%   +1.05%     
- Complexity       74       83       +9     
============================================
  Files            23       23              
  Lines           378      402      +24     
  Branches          2        3       +1     
============================================
+ Hits            264      285      +21     
- Misses          108      110       +2     
- Partials          6        7       +1     
Impacted Files Coverage Δ
.../main/java/org/rocstreaming/roctoolkit/Logger.java 88.46% <88.00%> (-11.54%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@ortex ortex force-pushed the improve-logging branch 3 times, most recently from e79901c to 3f0388c Compare April 7, 2023 13:03
@gavv
Copy link
Member

gavv commented Apr 8, 2023

Maybe rename setCallback0 to setCallbackImp or setCallbackImpl or setCallbackNative?

@gavv
Copy link
Member

gavv commented Apr 8, 2023

Consider reworking TestValidLoggerSetLevel to be synchronous (wait for actual logs).

Same for TestInvalidLoggerNotThrows

@ortex ortex force-pushed the improve-logging branch from 3f0388c to 6d387d9 Compare April 8, 2023 12:41
@ortex ortex added the ready for review Pull request can be reviewed label Apr 8, 2023
@gavv gavv merged commit 98135b9 into main Apr 8, 2023
@gavv gavv deleted the improve-logging branch April 8, 2023 14:06
@gavv gavv removed the ready for review Pull request can be reviewed label Apr 8, 2023
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

Successfully merging this pull request may close these issues.

Use standard Java logger by default
2 participants