dave2wave commented on issue #339:
URL: 
https://github.com/apache/tooling-trusted-releases/issues/339#issuecomment-3568457257

   Also, nothing stops someone from mixing the two methods.
   
   ```python
   logger.info(f"Processing item {item_id}: %s", extra_detail)
   ```
   
   Now let's look at:
   
   ```python
   logger.info(f"Processing item {item_id}: %s", expensive_detail())
   ```
   
   In this case `expensive_detail()` will execute immediately, whether or not 
logging is enabled.
   
   So then you ought to do:
   
   ```python
   if logger.isEnabledFor(logging.INFO):
       logger.info(f"Processing item {item_id}: %s", expensive_detail())
   ```
   
   Or better:
   
   ```python
   if logger.isEnabledFor(logging.INFO):
       logger.info(f"Processing item {item_id}: {expensive_detail()}")
   ```
   
   We can show some examples easily about why we are constraining logging to 
more elemental versions and recommend use of `logger.isEnabled` if performance 
is an issue.
   
   A documentation PR would be welcome.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to