title: How to right align level field in Python logging.Formatter
body: <p>I'm currently trying to right align the logging level field in my Python logger so that output such as:</p>
  
  <pre><code>[2011-10-14 13:47:51] [DEBUG] --- starting... (smtphandlers.py:96)
  [2011-10-14 13:47:51] [INFO] --- first things first... (smtphandlers.py:97)
  [2011-10-14 13:47:51] [WARNING] --- about to end... (smtphandlers.py:98)
  [2011-10-14 13:47:51] [DEBUG] --- ending (smtphandlers.py:99)
  </code></pre>
  
  <p>instead looks like:</p>
  
  <pre><code>[2011-10-14 13:47:51] [   DEBUG] --- starting... (smtphandlers.py:96)
  [2011-10-14 13:47:51] [    INFO] --- first things first... (smtphandlers.py:97)
  [2011-10-14 13:47:51] [ WARNING] --- about to end... (smtphandlers.py:98)
  [2011-10-14 13:47:51] [   DEBUG] --- ending (smtphandlers.py:99)
  </code></pre>
  
  <p>The format line for the first block is:</p>
  
  <pre><code>logging.Formatter("[%(asctime)s] [%(levelname)s] --- %(message)s (%(filename)s:%(lineno)s)", "%Y-%m-%d %H:%M:%S")
  </code></pre>
  
  <p>If I know the max level length is 8 (eg: CRITICAL), then I'll right align to 8 spaces.
  I'm trying to figure out how to achieve this.  The following fails because "%(levelname)s" is more than 8 characters (the substitution doesn't happen until later).  If I use something like "{0:>20}".format"%(levelname)s", then it works, but that is more padding than I need or want.</p>
  
  <pre><code>logging.Formatter("[%(asctime)s] [" + "{0:&gt;8}".format"%(levelname)s" + "] --- %(message)s (%(filename)s:%(lineno)s)", "%Y-%m-%d %H:%M:%S")
  </code></pre>
  
  <p>Short of subclassing Formatter, anyone have a way to achieve this?</p>