Author: Alexander Hesse <[email protected]>
Branch: quiet-rpython
Changeset: r60657:f96e644c7df3
Date: 2013-01-29 08:42 +0100
http://bitbucket.org/pypy/pypy/changeset/f96e644c7df3/
Log: Added new log drivers and log.step
diff --git a/rpython/jit/codewriter/codewriter.py
b/rpython/jit/codewriter/codewriter.py
--- a/rpython/jit/codewriter/codewriter.py
+++ b/rpython/jit/codewriter/codewriter.py
@@ -65,14 +65,14 @@
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)
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -271,8 +271,7 @@
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:
diff --git a/rpython/tool/ansi_mandelbrot.py b/rpython/tool/ansi_mandelbrot.py
--- a/rpython/tool/ansi_mandelbrot.py
+++ b/rpython/tool/ansi_mandelbrot.py
@@ -118,6 +118,7 @@
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. """
diff --git a/rpython/tool/ansi_print.py b/rpython/tool/ansi_print.py
--- a/rpython/tool/ansi_print.py
+++ b/rpython/tool/ansi_print.py
@@ -17,6 +17,12 @@
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
@@ -30,13 +36,13 @@
'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):
@@ -54,10 +60,18 @@
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()
@@ -81,22 +95,17 @@
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()
diff --git a/rpython/translator/driver.py b/rpython/translator/driver.py
--- a/rpython/translator/driver.py
+++ b/rpython/translator/driver.py
@@ -268,12 +268,10 @@
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
@@ -291,7 +289,6 @@
assert False, 'we should not get here'
finally:
try:
- debug_stop('translation-task')
self.timer.end_event(goal)
except (KeyboardInterrupt, SystemExit):
raise
@@ -514,7 +511,7 @@
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):
diff --git a/rpython/translator/goal/translate.py
b/rpython/translator/goal/translate.py
--- a/rpython/translator/goal/translate.py
+++ b/rpython/translator/goal/translate.py
@@ -92,7 +92,7 @@
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__]
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit