title: Suppress multiple messages with same content in Python logging module AKA log compression
body: <p>By design, my application sometimes produces repeating errors which fill up the log file and make it annoying to read. It looks like that:</p>
  
  <pre><code>WARNING:__main__:CRON10: clock unset or no wind update received in 60 sec -&gt; supressed rrd update
  WARNING:__main__:CRON10: clock unset or no wind update received in 60 sec -&gt; supressed rrd update
  WARNING:__main__:CRON10: clock unset or no wind update received in 60 sec -&gt; supressed rrd update
  WARNING:__main__:CRON10: clock unset or no wind update received in 60 sec -&gt; supressed rrd update
  </code></pre>
  
  <p>How can I use the Python logging module to suppress repeating messages and output something more rsyslog style (<a href="http://www.rsyslog.com/doc/rsconf1_repeatedmsgreduction.html" rel="noreferrer">http://www.rsyslog.com/doc/rsconf1_repeatedmsgreduction.html</a>):</p>
  
  <pre><code>WARNING:__main__:CRON10: clock unset or no wind update received in 60 sec -&gt; supressed rrd update
  --- The last message repeated 3 times
  </code></pre>
  
  <p>Is there a way to extend logging or do I have to write a completly own logger?</p>
  
  <p>The code I use for logging is:</p>
  
  <pre><code>logging.basicConfig(format='%(asctime)s %(message)s')
  logging.basicConfig(level=logging.info)
  logger = logging.getLogger(__name__)
  hdlr = logging.FileHandler(LOGFILE)
  hdlr.setFormatter(formatter)
  logger.addHandler(hdlr) 
  </code></pre>
  
  <p>Any ideas on that?</p>