I agree with the other answer -- logging
is for logging and warning
is for warning -- but I'd like to add more detail.
Here is a tutorial-style HOWTO taking you through the steps in using the logging
module.
https://docs.python.org/3/howto/logging.html
It directly answers your question:
warnings.warn() in library code if the issue is avoidable and the
client application should be modified to eliminate the warning
logging.warning() if there is nothing the client application can do
about the situation, but the event should still be noted
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…