~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

(jam) Give a clear error when we fail to open ~/.bzr.log,
        instead of 'no handlers for "bzr"' (#503886).

Show diffs side-by-side

added added

removed removed

Lines of Context:
237
237
            bzr_log_file.write("bug reports to https://bugs.launchpad.net/bzr/+filebug\n\n")
238
238
        return bzr_log_file
239
239
    except IOError, e:
240
 
        warning("failed to open trace file: %s" % (e))
 
240
        # If we are failing to open the log, then most likely logging has not
 
241
        # been set up yet. So we just write to stderr rather than using
 
242
        # 'warning()'. If we using warning(), users get the unhelpful 'no
 
243
        # handlers registered for "bzr"' when something goes wrong on the
 
244
        # server. (bug #503886)
 
245
        sys.stderr.write("failed to open trace file: %s\n" % (e,))
241
246
    # TODO: What should happen if we fail to open the trace file?  Maybe the
242
247
    # objects should be pointed at /dev/null or the equivalent?  Currently
243
248
    # returns None which will cause failures later.