diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2009-01-27 20:54:22 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2009-01-27 20:54:22 +0100 |
commit | 76e1bf4dcb68341249417f291c74f72dc84c18e1 (patch) | |
tree | ca12939053f418060d932bf11241b3a2f918ebb1 | |
parent | fb06f577bae6bf02a6c585cd78c31d065e0e98dc (diff) | |
download | portato-76e1bf4dcb68341249417f291c74f72dc84c18e1.tar.gz portato-76e1bf4dcb68341249417f291c74f72dc84c18e1.tar.bz2 portato-76e1bf4dcb68341249417f291c74f72dc84c18e1.zip |
Fix logging in bpython
Diffstat (limited to '')
-rw-r--r-- | portato/log.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/portato/log.py b/portato/log.py index 9c5ebd2..97b1493 100644 --- a/portato/log.py +++ b/portato/log.py @@ -39,11 +39,16 @@ class OutputFormatter (logging.Formatter): for key, value in self.colors.iteritems(): self.colors[key] = "\x1b[01;%02dm*\x1b[39;49;00m" % value + if hasattr(sys.stderr, "fileno"): + self.istty = os.isatty(sys.stderr.fileno()) + else: + self.istty = False # no fileno -> save default + def format (self, record): string = logging.Formatter.format(self, record) color = None - if os.isatty(sys.stderr.fileno()): + if self.istty: if record.levelno <= logging.DEBUG: color = self.colors["blue"] elif record.levelno <= logging.INFO: |