summaryrefslogtreecommitdiff
path: root/giscanner/message.py
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2010-09-02 12:09:52 -0300
committerJohan Dahlin <johan@gnome.org>2010-09-02 12:37:55 -0300
commitce3834d1ae059ebf149d282a8298375158f89141 (patch)
tree069ce0c5babf3e5f0156e1a66f60f4365bee3654 /giscanner/message.py
parentca0733f019a4a9c9364b376b37b268ce3a096faa (diff)
downloadgobject-introspection-ce3834d1ae059ebf149d282a8298375158f89141.tar.gz
[message] Add an output parameter
Diffstat (limited to 'giscanner/message.py')
-rw-r--r--giscanner/message.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/giscanner/message.py b/giscanner/message.py
index 43555142..10a32a6a 100644
--- a/giscanner/message.py
+++ b/giscanner/message.py
@@ -32,8 +32,11 @@ from . import ast
class MessageLogger(object):
_instance = None
- def __init__(self, namespace):
+ def __init__(self, namespace, output=None):
+ if output is None:
+ output = sys.stderr
self._cwd = os.getcwd() + os.sep
+ self._output = output
self._namespace = namespace
self._enable_warnings = False
self._warned = False
@@ -76,7 +79,7 @@ If the warning is related to a ast.Node type, see log_node_warning()."""
position_strings.append(position)
for position in position_strings[:-1]:
- print >>sys.stderr, "%s:" % (position, )
+ self._output.write("%s:\n" % (position, ))
last_position = position_strings[-1]
if log_type == WARNING:
@@ -86,12 +89,12 @@ If the warning is related to a ast.Node type, see log_node_warning()."""
elif log_type == FATAL:
error_type = "Fatal"
if prefix:
- print >>sys.stderr, \
-'''%s: %s: %s: %s: %s''' % (last_position, error_type, self._namespace.name,
- prefix, text)
+ self._output.write(
+'''%s: %s: %s: %s: %s\n''' % (last_position, error_type, self._namespace.name,
+ prefix, text))
else:
- print >>sys.stderr, \
-'''%s: %s: %s: %s''' % (last_position, error_type, self._namespace.name, text)
+ self._output.write(
+'''%s: %s: %s: %s\n''' % (last_position, error_type, self._namespace.name, text))
if log_type == FATAL: