Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
2d845953
Commit
2d845953
authored
Oct 17, 2011
by
Stephen Morris
Browse files
[1074] Set defined debug levels for the Python code
parent
621c92d9
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/bin/bind10/bind10_src.py.in
View file @
2d845953
...
...
@@ -74,8 +74,8 @@ logger = isc.log.Logger("boss")
# Pending system-wide debug level definitions, the ones we
# use here are hardcoded for now
DBG_PROCESS =
10
DBG_COMMANDS =
30
DBG_PROCESS =
logger.DBGLVL_TRACE_BASIC
DBG_COMMANDS =
logger.DBGLVL_TRACE_DETAIL
# Assign this process some longer name
isc.util.process.rename(sys.argv[0])
...
...
src/bin/cmdctl/cmdctl.py.in
View file @
2d845953
...
...
@@ -49,17 +49,12 @@ from hashlib import sha1
from isc.util import socketserver_mixin
from isc.log_messages.cmdctl_messages import *
# TODO: these debug-levels are hard-coded here; we are planning on
# creating a general set of debug levels, see ticket #1074. When done,
# we should remove these values and use the general ones in the
# logger.debug calls
# Debug level for communication with BIND10
DBG_CMDCTL_MESSAGING = 30
isc.log.init("b10-cmdctl")
logger = isc.log.Logger("cmdctl")
# Debug level for communication with BIND10
DBG_CMDCTL_MESSAGING = logger.DBGLVL_COMMAND
try:
import threading
except ImportError:
...
...
src/bin/stats/stats.py.in
View file @
2d845953
...
...
@@ -32,9 +32,8 @@ from isc.log_messages.stats_messages import *
isc.log.init("b10-stats")
logger = isc.log.Logger("stats")
# Some constants for debug levels, these should be removed when we
# have #1074
DBG_STATS_MESSAGING = 30
# Some constants for debug levels.
DBG_STATS_MESSAGING = logger.DBGLVL_COMMAND
# This is for boot_time of Stats
_BASETIME = gmtime()
...
...
src/bin/stats/stats_httpd.py.in
View file @
2d845953
...
...
@@ -40,10 +40,9 @@ from isc.log_messages.stats_httpd_messages import *
isc.log.init("b10-stats-httpd")
logger = isc.log.Logger("stats-httpd")
# Some constants for debug levels, these should be removed when we
# have #1074
DBG_STATHTTPD_INIT = 10
DBG_STATHTTPD_MESSAGING = 30
# Some constants for debug levels.
DBG_STATHTTPD_INIT = logger.DBGLVL_START_SHUT
DBG_STATHTTPD_MESSAGING = logger.DBGLVL_COMMAND
# If B10_FROM_SOURCE is set in the environment, we use data files
# from a directory relative to that, otherwise we use the ones
...
...
src/bin/xfrin/xfrin.py.in
View file @
2d845953
...
...
@@ -64,8 +64,8 @@ ZONE_MANAGER_MODULE_NAME = 'Zonemgr'
REFRESH_FROM_ZONEMGR = 'refresh_from_zonemgr'
ZONE_XFRIN_FAILED = 'zone_xfrin_failed'
# Constants for debug levels
, to be removed when we have #1074
.
DBG_XFRIN_TRACE =
3
# Constants for debug levels.
DBG_XFRIN_TRACE =
logger.DBGLVL_TRACE_BASIC
# These two default are currently hard-coded. For config this isn't
# necessary, but we need these defaults for optional command arguments
...
...
src/bin/zonemgr/zonemgr.py.in
View file @
2d845953
...
...
@@ -43,10 +43,10 @@ from isc.log_messages.zonemgr_messages import *
isc.log.init("b10-zonemgr")
logger = isc.log.Logger("zonemgr")
# Constants for debug levels
, to be removed when we have #1074
.
DBG_START_SHUT =
0
DBG_ZONEMGR_COMMAND =
10
DBG_ZONEMGR_BASIC =
40
# Constants for debug levels.
DBG_START_SHUT =
logger.DBGLVL_START_SHUT
DBG_ZONEMGR_COMMAND =
logger.DBGLVL_COMMAND
DBG_ZONEMGR_BASIC =
logger.DBGLVL_TRACE_BASIC
isc.util.process.rename()
...
...
src/lib/log/log_dbglevels.h
View file @
2d845953
...
...
@@ -45,6 +45,11 @@
/// In this way users can have some expection of what will be output when
/// enabling debugging. Symbols are prefixed DBGLVL so as not to clash with
/// DBG_ symbols in the various modules.
///
/// N.B. If the names of debug constants are changed, or if ones are added or
/// removed, edit the file src/lib/python/isc/log/log.cc to update the log
/// level definitions available to Python. The change does not need to be
/// made if only the numeric values of constants are updated.
namespace
{
...
...
@@ -68,7 +73,7 @@ const int DBGLVL_COMMAND = 10;
const
int
DBGLVL_COMMAND_DATA
=
20
;
// The following constants are suggested values for common operations.
// Depending on the exact nature of the code, modules may or may not use
d
these
// Depending on the exact nature of the code, modules may or may not use these
// levels.
/// Trace basic operations.
...
...
src/lib/python/isc/log/log.cc
View file @
2d845953
...
...
@@ -28,7 +28,11 @@
#include <string>
#include <boost/bind.hpp>
#include <util/python/pycppwrapper_util.h>
#include <log/log_dbglevels.h>
using
namespace
isc
::
log
;
using
namespace
isc
::
util
::
python
;
using
std
::
string
;
using
boost
::
bind
;
...
...
@@ -723,7 +727,38 @@ PyInit_log(void) {
&
logger_type
)))
<
0
)
{
return
(
NULL
);
}
Py_INCREF
(
&
logger_type
);
// Add in the definitions of the standard debug levels. These can then
// be referred to in Python through the constants log.DBGLVL_XXX.
// N.B. These should be kept in sync with the constants defined in
// log_dbglevels.h.
try
{
installClassVariable
(
logger_type
,
"DBGLVL_START_SHUT"
,
Py_BuildValue
(
"I"
,
DBGLVL_START_SHUT
));
installClassVariable
(
logger_type
,
"DBGLVL_COMMAND"
,
Py_BuildValue
(
"I"
,
DBGLVL_COMMAND
));
installClassVariable
(
logger_type
,
"DBGLVL_COMMAND_DATA"
,
Py_BuildValue
(
"I"
,
DBGLVL_COMMAND_DATA
));
installClassVariable
(
logger_type
,
"DBGLVL_TRACE_BASIC"
,
Py_BuildValue
(
"I"
,
DBGLVL_TRACE_BASIC
));
installClassVariable
(
logger_type
,
"DBGLVL_TRACE_BASIC_DATA"
,
Py_BuildValue
(
"I"
,
DBGLVL_TRACE_BASIC_DATA
));
installClassVariable
(
logger_type
,
"DBGLVL_TRACE_DETAIL"
,
Py_BuildValue
(
"I"
,
DBGLVL_TRACE_DETAIL
));
installClassVariable
(
logger_type
,
"DBGLVL_TRACE_DETAIL_DATA"
,
Py_BuildValue
(
"I"
,
DBGLVL_TRACE_DETAIL_DATA
));
}
catch
(
const
std
::
exception
&
ex
)
{
const
std
::
string
ex_what
=
"Unexpected failure in Log initialization: "
+
std
::
string
(
ex
.
what
());
PyErr_SetString
(
PyExc_SystemError
,
ex_what
.
c_str
());
return
(
NULL
);
}
catch
(...)
{
PyErr_SetString
(
PyExc_SystemError
,
"Unexpected failure in Log initialization"
);
return
(
NULL
);
}
Py_INCREF
(
&
logger_type
);
return
(
mod
);
}
src/lib/python/isc/log/tests/log_test.py
View file @
2d845953
...
...
@@ -159,5 +159,15 @@ class Logger(unittest.TestCase):
# Bad type
self
.
assertRaises
(
TypeError
,
logger
.
debug
,
"42"
,
"hello"
)
def
test_dbglevel_constants
(
self
):
"""
Just check a constant to make sure it is defined and is the
correct value. (The constant chosen has a non-zero value to
ensure that the code has both define the constant and set its
value correctly.)
"""
logger
=
isc
.
log
.
Logger
(
"child"
)
self
.
assertEqual
(
logger
.
DBGLVL_COMMAND
,
10
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment