Works like logdebug, but only prints first and
    and every xth message.

def log_every_x_times(logger, counter, x, msg, *args, **kwargs):
    '''
    Works like logdebug, but only prints first and
    and every xth message.
    '''
    if counter==1 or counter % x == 0:
        #msg = msg + (' (counter %i)' % counter)
        logdebug(logger, msg, *args, **kwargs)