[MERGE] ``BZR_LOG=disable`` suppresses writing messages to .bzr.log.
Alexander Belchenko
bialix at ukr.net
Mon Jan 28 14:24:50 GMT 2008
John Arbash Meinel пишет:
> Alexander Belchenko wrote:
>> This patch adds support for BZR_LOG env variables that allows to
>> suppress .bzr.log.
>>
>
> It seems to me that it should be done by the 'bzr' code, not inside the
> bzrlib code.
>
> Specifically, inside 'bzr' we have:
> if __name__ == '__main__':
> bzrlib.trace.enable_default_logging()
> exit_val = bzrlib.commands.main(sys.argv)
>
> If someone is asking 'bzrlib' to enable the log, then I think we should
> be doing so.
>
> So I would prefer something like:
>
> if __name__ == '__main__':
> if os.environ.get('BZR_LOG', '').lower() != 'disable':
> bzrlib.trace.enable_default_logging()
I disagree. enable_default_logging() is also setup note/warning functions
that goes to stderr. I don't think we want to suppress this messages
as well. As another solution we can provide optional argument
for enable_default_logging() to specify if we want to not open .bzr.log
tracefile. Something like this:
=== modified file 'bzrlib/trace.py'
--- bzrlib/trace.py 28.01.2008 10:40:24
+++ bzrlib/trace.py 28.01.2008 16:22:16
@@ -223,7 +223,7 @@
mutter(traceback.format_exc())
-def enable_default_logging():
+def enable_default_logging(enable_tracefile=True):
"""Configure default logging to stderr and .bzr.log"""
# FIXME: if this is run twice, things get confused
global _stderr_handler, _file_handler, _trace_file, _bzr_log_file
@@ -233,7 +233,7 @@
_stderr_handler = logging.StreamHandler(stderr)
logging.getLogger('').addHandler(_stderr_handler)
_stderr_handler.setLevel(logging.INFO)
- if not _file_handler:
+ if not _file_handler and enable_tracefile:
open_tracefile()
_trace_file = _bzr_log_file
if _file_handler:
Is it OK for you?
> As far as having it in a config file rather than in an environment
> variable... I understand the utility of it, but by the time we get to
> parsing config files, we've already started logging.
>
> So we *could* do that, but it would be difficult to make it not log
> anything.
>
> I'm also not a big fan of calling it "BZR_LOG=disable". I might prefer
> BZR_DISABLE_LOG=1
> or
> BZR_ENABLE_LOG=0
I'm not big fan of long names and numerical binary values, but I tend to agree
that BZR_LOG is better suited for controlling exact absolute path of .bzr.log.
More information about the bazaar
mailing list