log exceptions only in debug mode
This commit is contained in:
parent
8b605aeaa8
commit
d9b22fd513
|
@ -259,7 +259,10 @@ def delete_book(book_id, book_format, jsonResponse):
|
|||
filter(db.Data.format == book_format).delete()
|
||||
calibre_db.session.commit()
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
if config.config_log_level == logger.logging.DEBUG:
|
||||
log.exception(e)
|
||||
else:
|
||||
log.error(e)
|
||||
calibre_db.session.rollback()
|
||||
else:
|
||||
# book not found
|
||||
|
|
|
@ -156,5 +156,8 @@ def on_received_watch_confirmation():
|
|||
move(os.path.join(tmp_dir, "tmp_metadata.db"), dbpath)
|
||||
calibre_db.reconnect_db(config, ub.app_DB_path)
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
if config.config_log_level == logger.logging.DEBUG:
|
||||
log.exception(e)
|
||||
else:
|
||||
log.error(e)
|
||||
return ''
|
||||
|
|
|
@ -199,7 +199,10 @@ def getDrive(drive=None, gauth=None):
|
|||
except RefreshError as e:
|
||||
log.error("Google Drive error: %s", e)
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
if config.config_log_level == logger.logging.DEBUG:
|
||||
log.exception(e)
|
||||
else:
|
||||
log.error(e)
|
||||
else:
|
||||
# Initialize the saved creds
|
||||
gauth.Authorize()
|
||||
|
|
|
@ -562,8 +562,10 @@ def get_book_cover_internal(book, use_generic_cover_on_failure):
|
|||
log.error('%s/cover.jpg not found on Google Drive', book.path)
|
||||
return get_cover_on_failure(use_generic_cover_on_failure)
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
# traceback.print_exc()
|
||||
if config.config_log_level == logger.logging.DEBUG:
|
||||
log.exception(e)
|
||||
else:
|
||||
log.error(e)
|
||||
return get_cover_on_failure(use_generic_cover_on_failure)
|
||||
else:
|
||||
cover_file_path = os.path.join(config.config_calibre_dir, book.path)
|
||||
|
|
|
@ -88,7 +88,10 @@ def register_user_with_oauth(user=None):
|
|||
try:
|
||||
ub.session.commit()
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
if config.config_log_level == logger.logging.DEBUG:
|
||||
log.exception(e)
|
||||
else:
|
||||
log.error(e)
|
||||
ub.session.rollback()
|
||||
|
||||
|
||||
|
@ -207,7 +210,10 @@ if ub.oauth_support:
|
|||
ub.session.add(oauth_entry)
|
||||
ub.session.commit()
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
if config.config_log_level == logger.logging.DEBUG:
|
||||
log.exception(e)
|
||||
else:
|
||||
log.error(e)
|
||||
ub.session.rollback()
|
||||
|
||||
# Disable Flask-Dance's default behavior for saving the OAuth token
|
||||
|
@ -239,7 +245,10 @@ if ub.oauth_support:
|
|||
flash(_(u"Link to %(oauth)s Succeeded", oauth=provider_name), category="success")
|
||||
return redirect(url_for('web.profile'))
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
if config.config_log_level == logger.logging.DEBUG:
|
||||
log.exception(e)
|
||||
else:
|
||||
log.error(e)
|
||||
ub.session.rollback()
|
||||
else:
|
||||
flash(_(u"Login failed, No User Linked With OAuth Account"), category="error")
|
||||
|
@ -286,7 +295,10 @@ if ub.oauth_support:
|
|||
logout_oauth_user()
|
||||
flash(_(u"Unlink to %(oauth)s Succeeded", oauth=oauth_check[provider]), category="success")
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
if config.config_log_level == logger.logging.DEBUG:
|
||||
log.exception(e)
|
||||
else:
|
||||
log.error(e)
|
||||
ub.session.rollback()
|
||||
flash(_(u"Unlink to %(oauth)s Failed", oauth=oauth_check[provider]), category="error")
|
||||
except NoResultFound:
|
||||
|
|
|
@ -210,7 +210,10 @@ class CalibreTask:
|
|||
self._progress = x
|
||||
|
||||
def _handleError(self, error_message):
|
||||
log.exception(error_message)
|
||||
if logger.is_debug_enabled():
|
||||
log.exception(error_message)
|
||||
else:
|
||||
log.error(error_message)
|
||||
self.stat = STAT_FAIL
|
||||
self.progress = 1
|
||||
self.error = error_message
|
||||
|
|
10
cps/web.py
10
cps/web.py
|
@ -316,7 +316,10 @@ def import_ldap_users():
|
|||
try:
|
||||
new_users = services.ldap.get_group_members(config.config_ldap_group_name)
|
||||
except (services.ldap.LDAPException, TypeError, AttributeError, KeyError) as e:
|
||||
log.exception(e)
|
||||
if config.config_log_level == logger.logging.DEBUG:
|
||||
log.exception(e)
|
||||
else:
|
||||
log.error(e)
|
||||
showtext['text'] = _(u'Error: %(ldaperror)s', ldaperror=e)
|
||||
return json.dumps(showtext)
|
||||
if not new_users:
|
||||
|
@ -344,7 +347,10 @@ def import_ldap_users():
|
|||
try:
|
||||
user_data = services.ldap.get_object_details(user=user_identifier, query_filter=query_filter)
|
||||
except AttributeError as e:
|
||||
log.exception(e)
|
||||
if config.config_log_level == logger.logging.DEBUG:
|
||||
log.exception(e)
|
||||
else:
|
||||
log.error(e)
|
||||
continue
|
||||
if user_data:
|
||||
user_login_field = extract_dynamic_field_from_filter(user, config.config_ldap_user_object)
|
||||
|
|
Loading…
Reference in New Issue
Block a user