diff options
author | Johan Dahlin <johan@gnome.org> | 2010-09-02 12:09:52 -0300 |
---|---|---|
committer | Johan Dahlin <johan@gnome.org> | 2010-09-02 12:37:55 -0300 |
commit | ce3834d1ae059ebf149d282a8298375158f89141 (patch) | |
tree | 069ce0c5babf3e5f0156e1a66f60f4365bee3654 /giscanner/message.py | |
parent | ca0733f019a4a9c9364b376b37b268ce3a096faa (diff) | |
download | gobject-introspection-ce3834d1ae059ebf149d282a8298375158f89141.tar.gz |
[message] Add an output parameter
Diffstat (limited to 'giscanner/message.py')
-rw-r--r-- | giscanner/message.py | 17 |
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: |