diff --git a/powerdnsadmin/models/account.py b/powerdnsadmin/models/account.py index 0fb3c3c..523ac1d 100644 --- a/powerdnsadmin/models/account.py +++ b/powerdnsadmin/models/account.py @@ -1,3 +1,5 @@ +from flask import current_app + from .base import db from .user import User from .account_user import AccountUser @@ -99,7 +101,7 @@ class Account(db.Model): return True except Exception as e: db.session.rollback() - logging.error( + current_app.logger.error( 'Cannot delete account {0} from DB. DETAIL: {1}'.format( self.username, e)) return False @@ -140,7 +142,7 @@ class Account(db.Model): db.session.commit() except Exception as e: db.session.rollback() - logging.error( + current_app.logger.error( 'Cannot revoke user privileges on account {0}. DETAIL: {1}'. format(self.name, e)) @@ -151,7 +153,7 @@ class Account(db.Model): db.session.commit() except Exception as e: db.session.rollback() - logging.error( + current_app.logger.error( 'Cannot grant user privileges to account {0}. DETAIL: {1}'. format(self.name, e)) @@ -177,7 +179,7 @@ class Account(db.Model): return True except Exception as e: db.session.rollback() - logging.error( + current_app.logger.error( 'Cannot add user privileges on account {0}. DETAIL: {1}'. format(self.name, e)) return False @@ -194,7 +196,7 @@ class Account(db.Model): return True except Exception as e: db.session.rollback() - logging.error( + current_app.logger.error( 'Cannot revoke user privileges on account {0}. DETAIL: {1}'. format(self.name, e)) return False diff --git a/powerdnsadmin/models/domain_setting.py b/powerdnsadmin/models/domain_setting.py index 56dd6f1..849239c 100644 --- a/powerdnsadmin/models/domain_setting.py +++ b/powerdnsadmin/models/domain_setting.py @@ -1,3 +1,5 @@ +from flask import current_app + from .base import db @@ -26,8 +28,8 @@ class DomainSetting(db.Model): db.session.commit() return True except Exception as e: - logging.error( + current_app.logger.error( 'Unable to set DomainSetting value. DETAIL: {0}'.format(e)) - logging.debug(traceback.format_exc()) + current_app.logger.debug(traceback.format_exc()) db.session.rollback() return False \ No newline at end of file diff --git a/powerdnsadmin/models/domain_template_record.py b/powerdnsadmin/models/domain_template_record.py index 9290a51..bd86c6e 100644 --- a/powerdnsadmin/models/domain_template_record.py +++ b/powerdnsadmin/models/domain_template_record.py @@ -1,3 +1,5 @@ +from flask import current_app + from .base import db @@ -36,7 +38,7 @@ class DomainTemplateRecord(db.Model): try: db.session.commit() except Exception as e: - logging.error( + current_app.logger.error( 'Can not update domain template table. Error: {0}'.format(e)) db.session.rollback() return { diff --git a/powerdnsadmin/models/setting.py b/powerdnsadmin/models/setting.py index 8d469da..3446487 100644 --- a/powerdnsadmin/models/setting.py +++ b/powerdnsadmin/models/setting.py @@ -2,6 +2,7 @@ import sys import pytimeparse from ast import literal_eval from distutils.util import strtobool +from flask import current_app from .base import db @@ -193,9 +194,9 @@ class Setting(db.Model): db.session.commit() return True 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)) - logging.debug(traceback.format_exec()) + current_app.logger.debug(traceback.format_exec()) db.session.rollback() return False @@ -215,9 +216,9 @@ class Setting(db.Model): db.session.commit() return True 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)) - logging.debug(traceback.format_exec()) + current_app.logger.debug(traceback.format_exec()) db.session.rollback() return False @@ -235,9 +236,9 @@ class Setting(db.Model): db.session.commit() return True 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)) - logging.debug(traceback.format_exec()) + current_app.logger.debug(traceback.format_exec()) db.session.rollback() return False @@ -251,7 +252,7 @@ class Setting(db.Model): else: return self.defaults[setting] 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): return list(