From: Jelte Jansen Date: Fri, 23 Mar 2012 15:31:38 +0000 (+0100) Subject: [963] do --verbose through log (re)init X-Git-Tag: trac2351_base~226^2~116^2~95^2~2^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5e70d900e46fb148acfebf8c2aa068159e58d91b;p=thirdparty%2Fkea.git [963] do --verbose through log (re)init --- diff --git a/src/bin/dbutil/Makefile.am b/src/bin/dbutil/Makefile.am index 001332064d..f328cb0fef 100644 --- a/src/bin/dbutil/Makefile.am +++ b/src/bin/dbutil/Makefile.am @@ -6,7 +6,7 @@ man_MANS = b10-dbutil.8 nodist_pylogmessage_PYTHON = $(PYTHON_LOGMSGPKG_DIR)/work/dbutil_messages.py pylogmessagedir = $(pyexecdir)/isc/log_messages/ -EXTRA_DIST = $(man_MANS) b10-dbutil.xml +EXTRA_DIST = $(man_MANS) b10-dbutil.xml dbutil_messages.mes noinst_SCRIPTS = run_dbutil.sh diff --git a/src/bin/dbutil/dbutil.py.in b/src/bin/dbutil/dbutil.py.in index 3f97df9145..de5c4bdc39 100755 --- a/src/bin/dbutil/dbutil.py.in +++ b/src/bin/dbutil/dbutil.py.in @@ -45,6 +45,8 @@ isc.log.init("b10-dbutil") logger = isc.log.Logger("dbutil") isc.util.process.rename() +TRACE_BASIC = logger.DBGLVL_TRACE_BASIC + # @brief Version String # This is the version displayed to the user. It comprises the module name, # the module version number, and the overall BIND 10 version number (set in @@ -200,19 +202,16 @@ class Database: Encapsulates the SQL database, both the connection and the cursor. The methods will cause a program exit on any error. """ - def __init__(self, db_file, verbose = False): + def __init__(self, db_file): """ @brief Constructor @param db_file Name of the database file - @param verbose If True, print all SQL statements to stdout before - executing them. """ self.connection = None self.cursor = None self.db_file = db_file self.backup_file = None - self.verbose = verbose def open(self): """ @@ -244,14 +243,11 @@ class Database: """ @brief Execute Statement - Executes the given statement, exiting the program on error. If - verbose mode is set, the statement is printed to stdout before - execution. + Executes the given statement, exiting the program on error. @param statement SQL statement to execute """ - if self.verbose: - logger.debug(40, DBUTIL_EXECUTE, statement) + logger.debug(TRACE_BASIC, DBUTIL_EXECUTE, statement) try: self.cursor.execute(statement) @@ -543,7 +539,12 @@ def parse_command(): if __name__ == "__main__": (options, args) = parse_command() - db = Database(args[0], options.verbose) + + if options.verbose: + isc.log.init("b10-dbutil", "DEBUG", 99) + logger = isc.log.Logger("dbutil") + + db = Database(args[0]) exit_code = EXIT_SUCCESS logger.info(DBUTIL_FILE, args[0])