Skip to content

Commit 363f984

Browse files
author
Richard Jones
committed
complete transition from HYPERDBDEBUG to new logging
1 parent 379436a commit 363f984

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

doc/developers.txt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Developing Roundup
33
==================
44

5-
:Version: $Revision: 1.11 $
5+
:Version: $Revision: 1.12 $
66

77
.. note::
88
The intended audience of this document is the developers of the core
@@ -107,6 +107,24 @@ The administrators of the project reserve the right to boot developers who
107107
consistently check in code which is either broken or takes the codebase in
108108
directions that have not been agreed to.
109109

110+
111+
Debugging Aids
112+
--------------
113+
114+
Try turning on logging of DEBUG level messages. This may be done a number
115+
of ways, depending on what it is you're testing:
116+
117+
1. If you're testing the database unit tests, then set the environment
118+
variable ``LOGGING_LEVEL=DEBUG``. This may be done like so:
119+
120+
LOGGING_LEVEL=DEBUG python run_tests.py
121+
122+
This variable replaces the older HYPERDBDEBUG environment var.
123+
124+
2. If you're testing a particular tracker, then set the logging level in
125+
your tracker's ``config.py``.
126+
127+
110128
Internationalization Notes
111129
--------------------------
112130

roundup/rlog.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class BasicLogger:
8080
def __init__(self, file, level):
8181
self.file = file
8282
self.level = level
83+
self.format = '%(time)s %(level)s %(message)s'
8384

8485
def setFile(self, file):
8586
'''Set the file to log to. "file" is either an open file object or
@@ -97,10 +98,17 @@ def setLevel(self, level):
9798
if name == level:
9899
level = num
99100
self.level = level
101+
def setFormat(self, format):
102+
self.format = format
100103
def write(self, level, message):
101-
message = '%s %s %s\n'%(time.strftime('%Y-%m-%d %H:%M:%D'),
102-
BasicLogging.NAMES[level], message)
104+
info = {
105+
'time': time.strftime('%Y-%m-%d %H:%M:%D'),
106+
'level': BasicLogging.NAMES[level],
107+
'message': message
108+
}
109+
message = self.format%info
103110
self._write(message)
111+
self._write('\n')
104112
def _write(self, text):
105113
file = self.file or sys.stderr
106114
file.write(text)

test/db_test_base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: db_test_base.py,v 1.42 2004-07-20 23:24:27 richard Exp $
18+
# $Id: db_test_base.py,v 1.43 2004-07-21 00:50:50 richard Exp $
1919

2020
import unittest, os, shutil, errno, imp, sys, time, pprint
2121

@@ -80,6 +80,12 @@ class config:
8080

8181
logging = MockNull()
8282

83+
if os.environ.has_key('LOGGING_LEVEL'):
84+
from roundup import rlog
85+
config.logging = rlog.BasicLogging()
86+
config.logging.setLevel(os.environ['LOGGING_LEVEL'])
87+
config.logging.getLogger('hyperdb').setFormat('%(message)s')
88+
8389
class DBTest(MyTestCase):
8490
def setUp(self):
8591
# remove previous test, ignore errors

0 commit comments

Comments
 (0)