mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-12-30 15:05:39 +00:00
Merge pull request #652 from ngoduykhanh/fix_import
Fix logging in models
This commit is contained in:
commit
faeb8d1f94
@ -1,3 +1,5 @@
|
|||||||
|
from flask import current_app
|
||||||
|
|
||||||
from .base import db
|
from .base import db
|
||||||
from .user import User
|
from .user import User
|
||||||
from .account_user import AccountUser
|
from .account_user import AccountUser
|
||||||
@ -99,7 +101,7 @@ class Account(db.Model):
|
|||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
logging.error(
|
current_app.logger.error(
|
||||||
'Cannot delete account {0} from DB. DETAIL: {1}'.format(
|
'Cannot delete account {0} from DB. DETAIL: {1}'.format(
|
||||||
self.username, e))
|
self.username, e))
|
||||||
return False
|
return False
|
||||||
@ -140,7 +142,7 @@ class Account(db.Model):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
logging.error(
|
current_app.logger.error(
|
||||||
'Cannot revoke user privileges on account {0}. DETAIL: {1}'.
|
'Cannot revoke user privileges on account {0}. DETAIL: {1}'.
|
||||||
format(self.name, e))
|
format(self.name, e))
|
||||||
|
|
||||||
@ -151,7 +153,7 @@ class Account(db.Model):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
logging.error(
|
current_app.logger.error(
|
||||||
'Cannot grant user privileges to account {0}. DETAIL: {1}'.
|
'Cannot grant user privileges to account {0}. DETAIL: {1}'.
|
||||||
format(self.name, e))
|
format(self.name, e))
|
||||||
|
|
||||||
@ -177,7 +179,7 @@ class Account(db.Model):
|
|||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
logging.error(
|
current_app.logger.error(
|
||||||
'Cannot add user privileges on account {0}. DETAIL: {1}'.
|
'Cannot add user privileges on account {0}. DETAIL: {1}'.
|
||||||
format(self.name, e))
|
format(self.name, e))
|
||||||
return False
|
return False
|
||||||
@ -194,7 +196,7 @@ class Account(db.Model):
|
|||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
logging.error(
|
current_app.logger.error(
|
||||||
'Cannot revoke user privileges on account {0}. DETAIL: {1}'.
|
'Cannot revoke user privileges on account {0}. DETAIL: {1}'.
|
||||||
format(self.name, e))
|
format(self.name, e))
|
||||||
return False
|
return False
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from flask import current_app
|
||||||
|
|
||||||
from .base import db
|
from .base import db
|
||||||
|
|
||||||
|
|
||||||
@ -26,8 +28,8 @@ class DomainSetting(db.Model):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(
|
current_app.logger.error(
|
||||||
'Unable to set DomainSetting value. DETAIL: {0}'.format(e))
|
'Unable to set DomainSetting value. DETAIL: {0}'.format(e))
|
||||||
logging.debug(traceback.format_exc())
|
current_app.logger.debug(traceback.format_exc())
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
return False
|
return False
|
@ -1,3 +1,5 @@
|
|||||||
|
from flask import current_app
|
||||||
|
|
||||||
from .base import db
|
from .base import db
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +38,7 @@ class DomainTemplateRecord(db.Model):
|
|||||||
try:
|
try:
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(
|
current_app.logger.error(
|
||||||
'Can not update domain template table. Error: {0}'.format(e))
|
'Can not update domain template table. Error: {0}'.format(e))
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
return {
|
return {
|
||||||
|
@ -2,6 +2,7 @@ import sys
|
|||||||
import pytimeparse
|
import pytimeparse
|
||||||
from ast import literal_eval
|
from ast import literal_eval
|
||||||
from distutils.util import strtobool
|
from distutils.util import strtobool
|
||||||
|
from flask import current_app
|
||||||
|
|
||||||
from .base import db
|
from .base import db
|
||||||
|
|
||||||
@ -193,9 +194,9 @@ class Setting(db.Model):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error('Cannot set maintenance to {0}. DETAIL: {1}'.format(
|
current_app.logger.error('Cannot set maintenance to {0}. DETAIL: {1}'.format(
|
||||||
mode, e))
|
mode, e))
|
||||||
logging.debug(traceback.format_exec())
|
current_app.logger.debug(traceback.format_exec())
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -215,9 +216,9 @@ class Setting(db.Model):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error('Cannot toggle setting {0}. DETAIL: {1}'.format(
|
current_app.logger.error('Cannot toggle setting {0}. DETAIL: {1}'.format(
|
||||||
setting, e))
|
setting, e))
|
||||||
logging.debug(traceback.format_exec())
|
current_app.logger.debug(traceback.format_exec())
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -235,9 +236,9 @@ class Setting(db.Model):
|
|||||||
db.session.commit()
|
db.session.commit()
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error('Cannot edit setting {0}. DETAIL: {1}'.format(
|
current_app.logger.error('Cannot edit setting {0}. DETAIL: {1}'.format(
|
||||||
setting, e))
|
setting, e))
|
||||||
logging.debug(traceback.format_exec())
|
current_app.logger.debug(traceback.format_exec())
|
||||||
db.session.rollback()
|
db.session.rollback()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -251,7 +252,7 @@ class Setting(db.Model):
|
|||||||
else:
|
else:
|
||||||
return self.defaults[setting]
|
return self.defaults[setting]
|
||||||
else:
|
else:
|
||||||
logging.error('Unknown setting queried: {0}'.format(setting))
|
current_app.logger.error('Unknown setting queried: {0}'.format(setting))
|
||||||
|
|
||||||
def get_records_allow_to_edit(self):
|
def get_records_allow_to_edit(self):
|
||||||
return list(
|
return list(
|
||||||
|
Loading…
Reference in New Issue
Block a user