errael opened a new issue, #8240:
URL: https://github.com/apache/netbeans/issues/8240

   ### Description
   
   This affects (the hints are under `Options > Editor > Hints > Java`)
   - `Insert Code` action/dialog, aka `Generate > Logger...`
   - `Surround with try-catch` hint, under `Error Fixes` hints
   - `Logging` hints
   
   There might be other items that should be added to the above list.
   
   A key question is how to specify which Logger, between `System` and 
`java.util`, to use. Could
   1. Add a new option somewhere; like a new tab under `Tools > Options`, 
examples
      - `Tools > Options > Java > Java Logging` 
      - `Tools > Options > Java > Java` for future looking
   2. Extend list at `Tools > Options > Editor > Hints > Java > Surround with 
try-catch`
      with `Use java.lang.System.Logger`
   
   Doing (2) above is the simplest. I'd be inclined to put it above `java.util` 
and have it check-marked by default. Consider that in most instances at 
run-time, there is little practical difference from the current behavior. These 
options could be used by `Generate > Logger...`, and in other cases as needed, 
to select which of the two loggers to use to initialize the logger. If this is 
acceptable, I volunteer.
   
   A few additional things that could be done
   
   A "use existing logger" option for `Surround with try-catch`.
   
   For reference, here the current and proposed code.
   
   - Current
     - `Generate>Logger...`
       `private static final Logger LOG = 
Logger.getLogger(Mavenproject5.class.getName());`
     - `Surround with try-catch`
       `Logger.getLogger(Mavenproject5.class.getName()).log(Level.SEVERE, null, 
ex);`
   
   - Proposed (when option is for System.Logger)
     - `Generate>Logger...`
       `private static final Logger LOG = 
System.getLogger(Mavenproject5.class.getName());`
   
     - `Surround with try-catch`
       - `System.getLogger(Mavenproject5.class.getName()).log(Level.ERROR, 
null, ex);`
       - `LOG.log(Level.ERROR, null, ex);`    // If "use existing logger" 
implemented
   
   Additional `Generate>Logger...` options for consideration
   - specify name of generated logger, e.g. "logger" instead of "LOG"
   - expression to use to init logger, e.g. "Utils.getLogger()" vs 
System.getLogger(...)
   
   With these options, a generated logger would look like
   ```
   private static final Logger logger = Utils.getLogger();
   ```
   
   
   ### Use case/motivation
   
   Provide access to newer, as of Java-9, capability
   
   ### Related issues
   
   _No response_
   
   ### Are you willing to submit a pull request?
   
   Yes


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@netbeans.apache.org
For additional commands, e-mail: notifications-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to