(self, d, emsg)
Log database and query details from exception.
Log database and query details from exception.
Log database and query details from exception .
def exception_hook(self, d, emsg):
        """Log database and query details from exception."""
        curs = getattr(d, 'cursor', None)
        conn = getattr(curs, 'connection', None)
        cname = getattr(conn, 'my_name', None)
        if cname:
            # Properly named connection
            cname = d.cursor.connection.my_name
            sql = getattr(curs, 'query', None) or '?'
            if len(sql) > 200: # avoid logging londiste huge batched queries
                sql = sql[:60] + " ..."
            lm = "Job %s got error on connection '%s': %s.   Query: %s" % (
                self.job_name, cname, emsg, sql)
            if self._is_quiet_exception(d):
                self.log.warning(lm)
            else:
                self.log.exception(lm)
        else:
            BaseScript.exception_hook(self, d, emsg)
def exception_hook ( self , d , emsg ) : curs = getattr ( d , 'cursor' , None ) conn = getattr ( curs , 'connection' , None ) cname = getattr ( conn , 'my_name' , None ) if cname : # Properly named connection cname = d . cursor . connection . my_name sql = getattr ( curs , 'query' , None ) or '?' if len ( sql ) > 200 : # avoid logging londiste huge batched queries sql = sql [ : 60 ] + " ..." lm = "Job %s got error on connection '%s': %s.   Query: %s" % ( self . job_name , cname , emsg , sql ) if self . _is_quiet_exception ( d ) : self . log . warning ( lm ) else : self . log . exception ( lm ) else : BaseScript . exception_hook ( self , d , emsg )