@with_session
def log_once(message, logger=logging.getLogger(u'log_once'), once_level=logging.INFO, suppressed_level=f_logger.VERBOSE, session=None):
 from flexget.manager import manager
 if (not manager):
  log.warning(u'DB not initialized. log_once will not work properly.')
  logger.log(once_level, message)
  return
 digest = hashlib.md5()
 digest.update(message.encode(u'latin1', u'replace'))
 md5sum = digest.hexdigest()
 if session.query(LogMessage).filter_by(md5sum=md5sum).first():
  logger.log(suppressed_level, message)
  return False
 row = LogMessage(md5sum)
 session.add(row)
 logger.log(once_level, message)
 return True

@ with_session def log_once ( message , logger = logging . getLogger ( u'log_once' ) , once_level = logging . INFO , suppressed_level = f_logger . VERBOSE , session = None ) : from flexget . manager import manager if ( not manager ) : log . warning ( u'DB not initialized. log_once will not work properly.' ) logger . log ( once_level , message ) return digest = hashlib . md5 ( ) digest . update ( message . encode ( u'latin1' , u'replace' ) ) md5sum = digest . hexdigest ( ) if session . query ( LogMessage ) . filter_by ( md5sum = md5sum ) . first ( ) : logger . log ( suppressed_level , message ) return False row = LogMessage ( md5sum ) session . add ( row ) logger . log ( once_level , message ) return True
log message only once using given logger .