Remove extra line from unit_tests.isolate
[chromium-blink-merge.git] / ppapi / generators / idl_log.py
blob679c7d87f42755fed51a71ec03059e9dad5c0e40
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 """
8 # IDL Log
10 # And IDLLog object provides a mechanism for capturing logging output
11 # and/or sending out via a file handle (usually stdout or stderr).
13 import sys
15 class IDLLog(object):
16 def __init__(self, name, out):
17 if name:
18 self.name = '%s : ' % name
19 else:
20 self.name = ''
22 self.out = out
23 self.capture = False
24 self.console = True
25 self.log = []
27 def Log(self, msg):
28 line = "%s\n" % (msg)
29 if self.console: self.out.write(line)
30 if self.capture:
31 self.log.append(msg)
33 def LogTag(self, msg):
34 line = "%s%s\n" % (self.name, msg)
35 if self.console: self.out.write(line)
36 if self.capture:
37 self.log.append(msg)
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):
45 self.console = enable
46 if out: self.out = out
48 def SetCapture(self, enable):
49 self.capture = enable
51 def DrainLog(self):
52 out = self.log
53 self.log = []
54 return out
56 ErrOut = IDLLog('Error', sys.stderr)
57 WarnOut = IDLLog('Warning', sys.stdout)
58 InfoOut = IDLLog('', sys.stdout)