Return a sentence describing when this exception was already seen.
"""
exc_log=run_sql("SELECT last_notified,last_seen,total FROM hstEXCEPTION WHERE name=%s AND filename=%s AND line=%s",(name,filename,line))
ifexc_log:
last_notified,last_seen,total=exc_log[0]
return"This exception has already been seen %s times\n last time it was seen: %s\n last time it was notified: %s\n"%(total,last_seen.strftime("%Y-%m-%d %H:%M:%S"),last_notified.strftime("%Y-%m-%d %H:%M:%S"))
else:
return"It is the first time this exception has been seen.\n"
defregister_exception(stream='error',
req=None,
prefix='',
suffix='',
alert_admin=False,
subject=''):
"""
Log error exception to invenio.err and warning exception to invenio.log.
Errors will be logged together with client information (if req is
given).
Note: For sanity reasons, dynamic params such as PREFIX, SUFFIX and
local stack variables are checked for length, and only first 500
chars of their values are printed.
@param stream: 'error' or 'warning'
@param req: mod_python request
@param prefix: a message to be printed before the exception in
the log
@param suffix: a message to be printed before the exception in
the log
@param alert_admin: wethever to send the exception to the administrator via
email. Note this parameter is bypassed when
CFG_SITE_ADMIN_EMAIL_EXCEPTIONS is set to a value different than 1
@param subject: overrides the email subject
@return: 1 if successfully wrote to stream, 0 if not