Next / Previous / Contents / TCC Help System / NM Tech homepage

51.21. message(): Send a message to standard error and log file

This function sends a string to the standard error stream, and also appends it to a cumulative log file.

pageget.py
# - - -   m e s s a g e   - - -

def message ( text ):
    """Send a message to stderr and ERROR_LOG.

      [ text is a string ->
          sys.stderr  +:=  text
          file ERROR_LOG  +:=  text ]
    """
    sys.stderr.write ( text )
    logFile  =  open ( ERROR_LOG, "a" )
    logFile.write ( text )
    logFile.close()