def METHOD_NAME(msg, tracefile=None, mode='w', tstamp=False):
    """Write a trace message.
    Write messages when debugging which do not interfere with stdout.
    Useful in tests, which monitor stdout and would break with
    unexpected output. Trace messages can go to the console (which is
    opened as a file), or to a disk file; the tracefile argument persists
    across calls unless overridden.
    Args:
        tracefile: file to write trace message to. If omitted,
          write to the previous trace file (default: console).
        mode: file open mode (default: 'w')
        tstamp: write relative timestamps with trace. Outputs time since
          scons was started, and time since last trace (default: False)
    """
    global TraceDefault
    global TimeStampDefault
    global PreviousTime
    def trace_cleanup(traceFP):
        traceFP.close()
    if tracefile is None:
        tracefile = TraceDefault
    else:
        TraceDefault = tracefile
    if not tstamp:
        tstamp = TimeStampDefault
    else:
        TimeStampDefault = tstamp
    try:
        fp = TraceFP[tracefile]
    except KeyError:
        try:
            fp = TraceFP[tracefile] = open(tracefile, mode)
            atexit.register(trace_cleanup, fp)
        except TypeError:
            # Assume we were passed an open file pointer.
            fp = tracefile
    if tstamp:
        now = time.time()
        fp.write('%8.4f %8.4f:  ' % (now - StartTime, now - PreviousTime))
        PreviousTime = now
    fp.write(msg)
    fp.flush()