Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(222)

Unified Diff: third_party/chrome/ppapi/generators/idl_log.py

Issue 12300042: Update idlsync.py to pull in dependencies required for chrome api generation. (Closed) Base URL: git://github.com/dart-lang/bleeding_edge.git@master
Patch Set: From another checkout Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/chrome/ppapi/generators/idl_log.py
diff --git a/third_party/chrome/ppapi/generators/idl_log.py b/third_party/chrome/ppapi/generators/idl_log.py
new file mode 100644
index 0000000000000000000000000000000000000000..b7f2151a4d9489a14df9f18598279bb761dd2ff9
--- /dev/null
+++ b/third_party/chrome/ppapi/generators/idl_log.py
@@ -0,0 +1,59 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+""" Error and information logging for IDL """
+
+#
+# IDL Log
+#
+# And IDLLog object provides a mechanism for capturing logging output
+# and/or sending out via a file handle (usually stdout or stderr).
+#
+import sys
+
+
+class IDLLog(object):
+ def __init__(self, name, out):
+ if name:
+ self.name = '%s : ' % name
+ else:
+ self.name = ''
+
+ self.out = out
+ self.capture = False
+ self.console = True
+ self.log = []
+
+ def Log(self, msg):
+ line = "%s\n" % (msg)
+ if self.console: self.out.write(line)
+ if self.capture:
+ self.log.append(msg)
+
+ def LogTag(self, msg):
+ line = "%s%s\n" % (self.name, msg)
+ if self.console: self.out.write(line)
+ if self.capture:
+ self.log.append(msg)
+
+ def LogLine(self, filename, lineno, pos, msg):
+ line = "%s(%d) : %s%s\n" % (filename, lineno, self.name, msg)
+ if self.console: self.out.write(line)
+ if self.capture: self.log.append(msg)
+
+ def SetConsole(self, enable, out = None):
+ self.console = enable
+ if out: self.out = out
+
+ def SetCapture(self, enable):
+ self.capture = enable
+
+ def DrainLog(self):
+ out = self.log
+ self.log = []
+ return out
+
+ErrOut = IDLLog('Error', sys.stderr)
+WarnOut = IDLLog('Warning', sys.stdout)
+InfoOut = IDLLog('', sys.stdout)
« no previous file with comments | « third_party/chrome/ppapi/generators/idl_lint.py ('k') | third_party/chrome/ppapi/generators/idl_namespace.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698