[MERGE/RFC] Flush .bzr.log periodically
Vincent Ladeuil
v.ladeuil+lp at free.fr
Thu Jan 8 09:41:21 GMT 2009
>>>>> "jam" == John Arbash Meinel <john at arbash-meinel.com> writes:
<snip/>
jam> I'm not settled that we need it, but it did make
jam> following the log file on windows during a long running
jam> process nicer.
Flushing every 2 seconds (if only a few chars have been written
since otherwise the flush should already occurs "naturally")
sounds very useful to me (I have a lot of bzr commands that run
for hours or even days recently :-/).
jam> (I haven't broken it out into a mergable patch yet, but
jam> the change is pretty small).
jam> I know there is a comment that the tracefile is line
jam> buffered, but I can guarantee that isn't the case on
jam> Windows.
jam> John
jam> =:->
jam> === modified file 'bzrlib/trace.py'
jam> --- bzrlib/trace.py 2008-11-01 14:44:47 +0000
jam> +++ bzrlib/trace.py 2009-01-07 21:59:52 +0000
jam> @@ -129,9 +129,11 @@
jam> info = note
jam> log_error = _bzr_logger.error
jam> error = _bzr_logger.error
jam> +_last_mutter_flush_time = None
jam> def mutter(fmt, *args):
jam> + global _last_mutter_flush_time
jam> if _trace_file is None:
jam> return
jam> if (getattr(_trace_file, 'closed', None) is not None) and
jam> _trace_file.closed:
jam> @@ -152,11 +154,16 @@
jam> out = fmt % tuple(real_args)
jam> else:
jam> out = fmt
jam> - timestamp = '%0.3f ' % (time.time() - _bzr_log_start_time,)
jam> + now = time.time()
jam> + timestamp = '%0.3f ' % (now - _bzr_log_start_time,)
jam> out = timestamp + out + '\n'
jam> _trace_file.write(out)
jam> # no need to flush here, the trace file is now linebuffered when it's
jam> # opened.
jam> + if (_last_mutter_flush_time is None
jam> + or (now - _last_mutter_flush_time) > 2.0):
jam> + _trace_file.flush()
jam> + _last_mutter_flush_time = now
You should either delete the comment or not use flush() or some
people (including me in a couple of years and may be even you :)
will get confused.
BB:approve
Vincent
More information about the bazaar
mailing list