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

51.20. error(): Write a message to stderr

This function writes a message to the standard error stream. It takes a list of strings as arguments, concatenates them, and sends them to sys.stderr decorated with a characteristic prefix so we can rapidly find error messages in log files. It also appends a newline, so none of the callers have to remember to do that. The message is also written to file ERROR_LOG with append access so there is a cumulative log of all errors.

pageget.py
# - - -   e r r o r   - - -

ERROR_LOG  =  "/u/www/docs/tcc/webstats/error-log"

def error ( *L ):
    """Send a message to the standard error stream.

      [ L is a list of strings ->
          sys.stderr  +:=  (error message prefix) +
              (elements of L, concatenated) + "\n" ]
    """
    text  =  "*** %s\n" % "".join(L)
    message ( text )