Commits

Alexander Hesse committed f96e644

Added new log drivers and log.step

  • Participants
  • Parent commits 656335a
  • Branches quiet-rpython

Comments (0)

Files changed (6)

rpython/jit/codewriter/codewriter.py

             self.print_ssa_repr(ssarepr, portal_jd, verbose)
 
     def make_jitcodes(self, verbose=False):
-        log.info("making JitCodes...")
+        log.info("Producing JitCodes")
         self.callcontrol.grab_initial_jitcodes()
         count = 0
         for graph, jitcode in self.callcontrol.enum_pending_graphs():
             self.transform_graph_to_jitcode(graph, jitcode, verbose)
             count += 1
-            if not count % 500:
-                log.info("Produced %d jitcodes" % count)
+            if not count % 10:
+                log.dot()
         self.assembler.finished(self.callcontrol.callinfocollection)
         heaptracker.finish_registering(self.cpu)
         log.info("there are %d JitCode instances." % count)

rpython/rtyper/rtyper.py

         if self.typererrors: 
             self.dump_typererrors(to_log=True) 
             raise TyperError("there were %d error" % len(self.typererrors))
-        self.log.event('-=- specialized %d%s blocks -=-' % (
-            blockcount, newtext))
+        self.log.dot()
         annmixlevel = self.annmixlevel
         del self.annmixlevel
         if annmixlevel is not None:

rpython/tool/ansi_mandelbrot.py

     def reset(self, cnt=0):
         """ Resets to the beginning of the line and drops cnt lines internally. """
         self.mandelbrot.reset(cnt)
+        print >>sys.stderr
 
     def catchup(self):
         """ Fills the current line. """

rpython/tool/ansi_print.py

         self.state += 1
         self.state %= len(self.states)
 
+class DotDriver(object):
+    def dot(self):
+        sys.stderr.write('.')
+    def reset(self):
+        pass
+
 class AnsiLog:
     wrote_dot = False # XXX sharing state with all instances
 
         'Error': ((1, 31), False),
         'info': ((35,), False),
         'stub': ((34,), False),
-        'init': ((1, 34), False),
+        'step': ((1, 34), False),
     }
     
     log_on_quiet = [
         "ERROR",
         "Error",
-        "init",
+        "step",
     ]
 
     def __init__(self, kw_to_color={}, file=None):
             self.quiet = quiet
         
         self.driver = None
-        if self.isatty and self.fancy:
-            self.driver = MandelbrotDriver()
-        if self.isatty and self.quiet:
-            self.driver = SpinningDriver()
+        if self.isatty:
+            self.driver = DotDriver()
+            if self.fancy:
+                self.driver = MandelbrotDriver()
+            if self.quiet:
+                self.driver = SpinningDriver()
+
+    def dot(self):
+        if self.driver is None:
+            return
+        self.driver.dot()
+        AnsiLog.wrote_dot = True
 
     def __call__(self, msg):
         tty = self.isatty()
                 print >> sys.stderr
                 return
         elif 'dot' in keywords:
-            if tty:
-                if self.driver is not None:
-                    if not AnsiLog.wrote_dot:
-                        self.driver.reset()
-                    self.driver.dot()
-                else:
-                    ansi_print(".", tuple(esc), file=self.file, newline=False, flush=flush)
-                AnsiLog.wrote_dot = True
-                return
-        if AnsiLog.wrote_dot:
-            AnsiLog.wrote_dot = False
-            sys.stderr.write("\n")
+            self.dot()
+            return
         esc = tuple(esc)
         if not self.quiet or any([kw in self.log_on_quiet for kw in keywords]):
+            if AnsiLog.wrote_dot and self.driver is not None:
+                self.driver.reset()
+            AnsiLog.wrote_dot = False
             for line in msg.content().splitlines():
                 ansi_print("[%s] %s" %(":".join(keywords), line), esc, 
                             file=self.file, newline=newline, flush=flush)
+        else:
+            self.dot()
 
 ansi_log = AnsiLog()

rpython/translator/driver.py

     def _do(self, goal, func, *args, **kwds):
         title = func.task_title
         if goal in self.done:
-            self.log.init("already done: %s" % title)
+            self.log.step("already done: %s" % title)
             return
         else:
-            self.log.init("%s" % title)
-        debug_start('translation-task')
-        debug_print('starting', goal)
+            self.log.step("%s" % title)
         self.timer.start_event(goal)
         try:
             instrument = False
                 assert False, 'we should not get here'
         finally:
             try:
-                debug_stop('translation-task')
                 self.timer.end_event(goal)
             except (KeyboardInterrupt, SystemExit):
                 raise
                                     str(newsoname.new(ext='lib')))
             self.c_entryp = newexename
         self.log.info('usession directory: %s' % (udir,))
-        self.log.info("created: %s" % (self.c_entryp,))
+        self.log.step("created: %s" % (self.c_entryp,))
 
     @taskdef(['source_c'], "Compiling c source")
     def task_compile_c(self):

rpython/translator/goal/translate.py

 py.log.setconsumer("translation", ansi_log)
 
 def load_target(targetspec):
-    log.init("Translating target %s" % targetspec)
+    log.step("Translating target %s" % targetspec)
     if not targetspec.endswith('.py'):
         targetspec += '.py'
     thismod = sys.modules[__name__]