use sys.stderr.isatty() to decide if we use colors in log output or not.
fix var name. Fixes #7668