title: How to turn off logging buffer to get logs in real time with python command line tool?
body: <p>I have a command line tool which produces plenty of logs. I want these logs to be sent to <code>stdout</code> as soon as they're made. Right now, the program finishes everything (which can take several minutes), and then sends everything to <code>stdout</code> all at once. This means that currently, the user is not aware of whats going on internally, and I want to change that.</p>
  
  <p>So far I've tried passing the <code>-u</code> flag as a command line argument, but that doesn't change anything. I have a feeling I need to use <code>logging.handlers.BufferingHandler</code> with <code>flush()</code> in some capacity, but I haven't been able to figure it out through tinkering.</p>
  
  <pre class="lang-py prettyprint-override"><code>def some_func(flag: bool):
      if flag:
          logging.info('flag is truthy')
          return
      logging.warning('flag is falsy')
  </code></pre>
  
  <p>I'd like the above function to show the user one of those logs as soon as the log is created. 
  Note: currently I set the logging level with <code>logging.root.setLevel(logging.INFO)</code>.</p>
  
  <p>Thanks!</p>