Commit 583de555 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[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.
parent 57f3e532
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
......
# 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')
# 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.
......@@ -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)
......
......@@ -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__
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment