[svn] commit: r1946 - in /branches/trac176: ./ src/bin/xfrout/ src/lib/python/isc/ src/lib/python/isc/log/ src/lib/python/isc/log/tests/
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu May 27 12:03:32 UTC 2010
Author: chenzhengzhang
Date: Thu May 27 12:03:32 2010
New Revision: 1946
Log:
Add logging module and unittest in lib/python/isc/log,
also add log in xfrout module for testing.
Currently, logging module supports three channels:stderr
file and syslog.
Added:
branches/trac176/src/lib/python/isc/log/
branches/trac176/src/lib/python/isc/log/Makefile.am
branches/trac176/src/lib/python/isc/log/__init__.py
branches/trac176/src/lib/python/isc/log/log.py
branches/trac176/src/lib/python/isc/log/tests/
branches/trac176/src/lib/python/isc/log/tests/Makefile.am
branches/trac176/src/lib/python/isc/log/tests/log_test.py
Modified:
branches/trac176/configure.ac
branches/trac176/src/bin/xfrout/xfrout.py.in
branches/trac176/src/bin/xfrout/xfrout.spec.pre.in
branches/trac176/src/lib/python/isc/Makefile.am
branches/trac176/src/lib/python/isc/__init__.py
Modified: branches/trac176/configure.ac
==============================================================================
--- branches/trac176/configure.ac (original)
+++ branches/trac176/configure.ac Thu May 27 12:03:32 2010
@@ -396,6 +396,8 @@
src/lib/python/isc/cc/tests/Makefile
src/lib/python/isc/config/Makefile
src/lib/python/isc/config/tests/Makefile
+ src/lib/python/isc/log/Makefile
+ src/lib/python/isc/log/tests/Makefile
src/lib/config/Makefile
src/lib/config/tests/Makefile
src/lib/dns/Makefile
Modified: branches/trac176/src/bin/xfrout/xfrout.py.in
==============================================================================
--- branches/trac176/src/bin/xfrout/xfrout.py.in (original)
+++ branches/trac176/src/bin/xfrout/xfrout.py.in Thu May 27 12:03:32 2010
@@ -26,6 +26,7 @@
from socketserver import *
import os
from isc.config.ccsession import *
+from isc.log.log import *
from isc.cc import SessionError
import socket
from optparse import OptionParser, OptionValueError
@@ -276,7 +277,7 @@
class UnixSockServer(ThreadingUnixStreamServer):
'''The unix domain socket server which accept xfr query sent from auth server.'''
- def __init__(self, sock_file, handle_class, shutdown_event, config_data):
+ def __init__(self, sock_file, handle_class, shutdown_event, config_data, log):
try:
os.unlink(sock_file)
except:
@@ -287,23 +288,30 @@
self._lock = threading.Lock()
self._transfers_counter = 0
self._shutdown_event = shutdown_event
+ self._log = log
self.update_config_data(config_data)
def shutdown(self):
+ self._log.log_message('warning', 'Xfrout process will is shutting down')
ThreadingUnixStreamServer.shutdown(self)
try:
os.unlink(self._sock_file)
except:
- pass
+ #pass
+ self._log.log_message('error', 'OS unlink sock file exception while shutting down')
def update_config_data(self, new_config):
'''Apply the new config setting of xfrout module. '''
+ self._log.log_message('info', 'update config data start')
self._lock.acquire()
self._max_transfers_out = new_config.get('transfers_out')
+ self._log.log_message('debug', 'max transfer out : %d', self._max_transfers_out)
self._db_file = new_config.get('db_file')
+ self._log.log_message('debug', 'db file name : %s', self._db_file)
self._lock.release()
+ self._log.log_message('info', 'update config data complete')
def get_db_file(self):
self._lock.acquire()
@@ -339,11 +347,15 @@
class XfroutServer:
def __init__(self):
self._unix_socket_server = None
+ self._log = None
self._listen_sock_file = UNIX_SOCKET_FILE
self._shutdown_event = threading.Event()
self._cc = isc.config.ModuleCCSession(SPECFILE_LOCATION, self.config_handler, self.command_handler)
self._config_data = self._cc.get_full_config()
self._cc.start()
+ self._log = isc.log.ModuleLogger(self._config_data.get('log_name'), self._config_data.get('log_file'),
+ self._config_data.get('severity'), self._config_data.get('versions'),
+ self._config_data.get('max_bytes'), True)
self._start_xfr_query_listener()
@@ -351,7 +363,8 @@
'''Start a new thread to accept xfr query. '''
self._unix_socket_server = UnixSockServer(self._listen_sock_file, XfroutSession,
- self._shutdown_event, self._config_data);
+ self._shutdown_event, self._config_data,
+ self._log);
listener = threading.Thread(target = listen_on_xfr_query, args = (self._unix_socket_server,))
listener.start()
@@ -365,6 +378,10 @@
continue
self._config_data[key] = new_config[key]
+ if self._log:
+ self._log.update_config(self._config_data.get('log_file'), self._config_data.get('severity'),
+ self._config_data.get('max_bytes'), self._config_data.get('versions'))
+
if self._unix_socket_server:
self._unix_socket_server.update_config_data(self._config_data)
Modified: branches/trac176/src/bin/xfrout/xfrout.spec.pre.in
==============================================================================
--- branches/trac176/src/bin/xfrout/xfrout.spec.pre.in (original)
+++ branches/trac176/src/bin/xfrout/xfrout.spec.pre.in Thu May 27 12:03:32 2010
@@ -13,6 +13,36 @@
"item_type": "string",
"item_optional": False,
"item_default": '@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3'
+ },
+ {
+ "item_name": "log_name",
+ "item_type": "string",
+ "item_optional": False,
+ "item_default": "Xfrout"
+ },
+ {
+ "item_name": "log_file",
+ "item_type": "string",
+ "item_optional": False,
+ "item_default": "/var/log/xfrout.log"
+ },
+ {
+ "item_name": "severity",
+ "item_type": "string",
+ "item_optional": False,
+ "item_default": "debug"
+ },
+ {
+ "item_name": "versions",
+ "item_type": "integer",
+ "item_optional": False,
+ "item_default": 5
+ },
+ {
+ "item_name": "max_bytes",
+ "item_type": "integer",
+ "item_optional": False,
+ "item_default": 1048576
}
],
"commands": [
Modified: branches/trac176/src/lib/python/isc/Makefile.am
==============================================================================
--- branches/trac176/src/lib/python/isc/Makefile.am (original)
+++ branches/trac176/src/lib/python/isc/Makefile.am Thu May 27 12:03:32 2010
@@ -1,4 +1,4 @@
-SUBDIRS = datasrc cc config # Util
+SUBDIRS = datasrc cc config log # Util
python_PYTHON = __init__.py
Modified: branches/trac176/src/lib/python/isc/__init__.py
==============================================================================
--- branches/trac176/src/lib/python/isc/__init__.py (original)
+++ branches/trac176/src/lib/python/isc/__init__.py Thu May 27 12:03:32 2010
@@ -1,3 +1,4 @@
import isc.datasrc
import isc.cc
import isc.config
+import isc.log
More information about the bind10-changes
mailing list