From: JINMEI Tatuya Date: Wed, 30 Jan 2013 21:29:20 +0000 (-0800) Subject: [2617] extend python cc module so it logs some events, and log local lname X-Git-Tag: bind10-1.0.0-rc-release~37^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=583de5551d162a5feb89bf5759e573b32d80f142;p=thirdparty%2Fkea.git [2617] extend python cc module so it logs some events, and log local lname this is for debugging the issue of this task, but will be useful in general. --- diff --git a/src/lib/python/isc/cc/Makefile.am b/src/lib/python/isc/cc/Makefile.am index b0ba3b2851..ba6fe507db 100644 --- a/src/lib/python/isc/cc/Makefile.am +++ b/src/lib/python/isc/cc/Makefile.am @@ -1,6 +1,19 @@ SUBDIRS = . tests -python_PYTHON = __init__.py data.py session.py message.py +python_PYTHON = __init__.py data.py session.py message.py logger.py +BUILT_SOURCES = $(PYTHON_LOGMSGPKG_DIR)/work/pycc_messages.py +nodist_pylogmessage_PYTHON = $(PYTHON_LOGMSGPKG_DIR)/work/pycc_messages.py +pylogmessagedir = $(pyexecdir)/isc/log_messages/ + +CLEANFILES = $(PYTHON_LOGMSGPKG_DIR)/work/pycc_messages.py +CLEANFILES += $(PYTHON_LOGMSGPKG_DIR)/work/pycc_messages.pyc + +EXTRA_DIST = pycc_messages.mes + +# Define rule to build logging source files from message file +$(PYTHON_LOGMSGPKG_DIR)/work/pycc_messages.py: pycc_messages.mes + $(top_builddir)/src/lib/log/compiler/message \ + -d $(PYTHON_LOGMSGPKG_DIR)/work -p $(srcdir)/pycc_messages.mes pythondir = $(pyexecdir)/isc/cc diff --git a/src/lib/python/isc/cc/logger.py b/src/lib/python/isc/cc/logger.py new file mode 100644 index 0000000000..5fd440f786 --- /dev/null +++ b/src/lib/python/isc/cc/logger.py @@ -0,0 +1,26 @@ +# Copyright (C) 2013 Internet Systems Consortium. +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM +# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL +# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING +# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +""" This is a logging utility module for other modules of the cc library +package. + +""" + +import isc.log + +# C++ version of the CC module uses 'cc'; using the same name does not +# necessarily cause disruption, but we use a different name to minimize +# possible confusion. +logger = isc.log.Logger('pycc') diff --git a/src/lib/python/isc/cc/pycc_messages.mes b/src/lib/python/isc/cc/pycc_messages.mes new file mode 100644 index 0000000000..997b89916e --- /dev/null +++ b/src/lib/python/isc/cc/pycc_messages.mes @@ -0,0 +1,20 @@ +# Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC") +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +# PERFORMANCE OF THIS SOFTWARE. + +# No namespace declaration - these constants go in the global namespace +# of the libddns_messages python module. + +% PYCC_LNAME_RECEIVED received local name: %1 +Debug message: the local module received its unique identifier (name) +from msgq on completion of establishing the session with msgq. diff --git a/src/lib/python/isc/cc/session.py b/src/lib/python/isc/cc/session.py index 33a47bdfcb..caac553124 100644 --- a/src/lib/python/isc/cc/session.py +++ b/src/lib/python/isc/cc/session.py @@ -22,6 +22,9 @@ import threading import bind10_config import isc.cc.message +import isc.log +from isc.cc.logger import logger +from isc.log_messages.pycc_messages import * class ProtocolError(Exception): pass class NetworkError(Exception): pass @@ -60,6 +63,8 @@ class Session: self._lname = msg["lname"] if not self._lname: raise ProtocolError("Could not get local name") + logger.debug(logger.DBGLVL_TRACE_BASIC, PYCC_LNAME_RECEIVED, + self._lname) except socket.error as se: raise SessionError(se) diff --git a/src/lib/python/isc/log_messages/Makefile.am b/src/lib/python/isc/log_messages/Makefile.am index 97ff6e6766..02523cdab3 100644 --- a/src/lib/python/isc/log_messages/Makefile.am +++ b/src/lib/python/isc/log_messages/Makefile.am @@ -18,6 +18,7 @@ EXTRA_DIST += loadzone_messages.py EXTRA_DIST += server_common_messages.py EXTRA_DIST += dbutil_messages.py EXTRA_DIST += msgq_messages.py +EXTRA_DIST += pycc_messages.py CLEANFILES = __init__.pyc CLEANFILES += bind10_messages.pyc @@ -37,6 +38,7 @@ CLEANFILES += loadzone_messages.pyc CLEANFILES += server_common_messages.pyc CLEANFILES += dbutil_messages.pyc CLEANFILES += msgq_messages.pyc +CLEANFILES += pycc_messages.pyc CLEANDIRS = __pycache__ diff --git a/src/lib/python/isc/log_messages/pycc_messages.py b/src/lib/python/isc/log_messages/pycc_messages.py new file mode 100644 index 0000000000..77b38040b6 --- /dev/null +++ b/src/lib/python/isc/log_messages/pycc_messages.py @@ -0,0 +1 @@ +from work.pycc_messages import *