Is there a way to dynamically set which log level I want a statement logged as?
I have this code:
logging.info("Data Set Size => {0}".format(len(data)))
logging.info("Training Set Size => {0}".format(len(train)))
logging.info("Test Set Size => {0}".format(len(test)))
logging.info("Entire data set allocated => {0}".format(len(data) == len(train) + len(test)))
It very nicely outputs something similar to this, depending on the format I've set:
root : INFO Data Set Size => 10000
root : INFO Training Set Size => 7500
root : INFO Test Set Size => 2500
root : INFO Entire data set allocated => True
Now, the question I have, if the logic check in that last line is False, can I set that level to a .warning?
I could do something like this:
if len(data) == len(train) + len(test):
logging.info("Entire data set allocated => {0}".format(True)
else:
logging.warning("Entire data set allocated => {0}".format(False)
But, is there a way to do it in fewer lines?