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