1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """ Error and information logging for IDL """
10 # And IDLLog object provides a mechanism for capturing logging output
11 # and/or sending out via a file handle (usually stdout or stderr).
16 def __init__(self
, name
, out
):
18 self
.name
= '%s : ' % name
29 if self
.console
: self
.out
.write(line
)
33 def LogTag(self
, msg
):
34 line
= "%s%s\n" % (self
.name
, msg
)
35 if self
.console
: self
.out
.write(line
)
39 def LogLine(self
, filename
, lineno
, pos
, msg
):
40 line
= "%s(%d) : %s%s\n" % (filename
, lineno
, self
.name
, msg
)
41 if self
.console
: self
.out
.write(line
)
42 if self
.capture
: self
.log
.append(msg
)
44 def SetConsole(self
, enable
, out
= None):
46 if out
: self
.out
= out
48 def SetCapture(self
, enable
):
56 ErrOut
= IDLLog('Error', sys
.stderr
)
57 WarnOut
= IDLLog('Warning', sys
.stdout
)
58 InfoOut
= IDLLog('', sys
.stdout
)