diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2009-01-27 22:01:27 +0100 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2009-01-27 22:01:27 +0100 |
commit | 29297f7e706d8635d582c257aba63d7c3230efdb (patch) | |
tree | 97f0510981a39b0947ad4321c45b94011098adbd /portato/log.py | |
parent | 6224da7a5810ef8a9309bc0fd919759e832edcf6 (diff) | |
parent | 581f7e6b508c43250c4191ad740dd1b31a4ca9af (diff) | |
download | portato-29297f7e706d8635d582c257aba63d7c3230efdb.tar.gz portato-29297f7e706d8635d582c257aba63d7c3230efdb.tar.bz2 portato-29297f7e706d8635d582c257aba63d7c3230efdb.zip |
Merged enhanced session handling
Diffstat (limited to 'portato/log.py')
-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: |