aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/bug.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@tremily.us>2013-01-24 02:31:52 -0500
committerW. Trevor King <wking@tremily.us>2013-01-24 02:36:22 -0500
commit932679f1e82a57feb4743e52d6c60f7331f057c2 (patch)
tree21c014cf36c8c159b7e5bf4627abf94b2e7a371b /libbe/bug.py
parent182a556397c2b0f4638991942c736c5daff17111 (diff)
downloadbugseverywhere-932679f1e82a57feb4743e52d6c60f7331f057c2.tar.gz
Transition to libbe.LOG for logging
This makes it easier to tweak log verbosity and redirect logs to other handlers. For example, the WSGI servers are unstable with stderr closed, and crash with an IOError if they try to print a warning to stderr.
Diffstat (limited to 'libbe/bug.py')
-rw-r--r--libbe/bug.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/libbe/bug.py b/libbe/bug.py
index 66510ba..bb7a37d 100644
--- a/libbe/bug.py
+++ b/libbe/bug.py
@@ -439,7 +439,7 @@ class Bug (settings_object.SavedSettingsObject):
sep = '\n' + istring
return istring + sep.join(lines).rstrip('\n')
- def from_xml(self, xml_string, preserve_uuids=False, verbose=True):
+ def from_xml(self, xml_string, preserve_uuids=False):
u"""
Note: If a bug uuid is given, set .alt_id to it's value.
>>> bugA = Bug(uuid="0123", summary="Need to test Bug.from_xml()")
@@ -451,7 +451,7 @@ class Bug (settings_object.SavedSettingsObject):
>>> commC = commA.new_reply(body='comment C')
>>> xml = bugA.xml(show_comments=True)
>>> bugB = Bug()
- >>> bugB.from_xml(xml, verbose=True)
+ >>> bugB.from_xml(xml)
>>> bugB.xml(show_comments=True) == xml
False
>>> bugB.uuid = bugB.alt_id
@@ -489,8 +489,7 @@ class Bug (settings_object.SavedSettingsObject):
pass
elif child.tag == 'comment':
comm = comment.Comment(bug=self)
- comm.from_xml(
- child, preserve_uuids=preserve_uuids, verbose=verbose)
+ comm.from_xml(child, preserve_uuids=preserve_uuids)
comments.append(comm)
continue
elif child.tag in tags:
@@ -515,9 +514,10 @@ class Bug (settings_object.SavedSettingsObject):
attr_name = child.tag.replace('-','_')
self.explicit_attrs.append(attr_name)
setattr(self, attr_name, text)
- elif verbose == True:
- print >> sys.stderr, 'Ignoring unknown tag %s in %s' \
- % (child.tag, comment.tag)
+ else:
+ libbe.LOG.warning(
+ 'ignoring unknown tag {0} in {1}'.format(
+ child.tag, comment.tag))
if uuid != self.uuid:
if not hasattr(self, 'alt_id') or self.alt_id == None:
self.alt_id = uuid
@@ -610,8 +610,9 @@ class Bug (settings_object.SavedSettingsObject):
parent = uuid_map[c.in_reply_to]
except KeyError:
if ignore_missing_references == True:
- print >> sys.stderr, \
- 'Ignoring missing reference to %s' % c.in_reply_to
+ libbe.LOG.warning(
+ 'ignoring missing reference to {0}'.format(
+ c.in_reply_to))
parent = default_parent
if parent.uuid != comment.INVALID_UUID:
c.in_reply_to = parent.uuid