| Index: third_party/logilab/common/logging_ext.py
 | 
| ===================================================================
 | 
| --- third_party/logilab/common/logging_ext.py	(revision 292986)
 | 
| +++ third_party/logilab/common/logging_ext.py	(working copy)
 | 
| @@ -24,6 +24,8 @@
 | 
|  import sys
 | 
|  import logging
 | 
|  
 | 
| +from six import string_types
 | 
| +
 | 
|  from logilab.common.textutils import colorize_ansi
 | 
|  
 | 
|  
 | 
| @@ -112,7 +114,11 @@
 | 
|      else:
 | 
|          try:
 | 
|              if rotation_parameters is None:
 | 
| -                handler = logging.FileHandler(logfile)
 | 
| +                if os.name == 'posix' and sys.version_info >= (2, 6):
 | 
| +                    from logging.handlers import WatchedFileHandler
 | 
| +                    handler = WatchedFileHandler(logfile)
 | 
| +                else:
 | 
| +                    handler = logging.FileHandler(logfile)
 | 
|              else:
 | 
|                  from logging.handlers import TimedRotatingFileHandler
 | 
|                  handler = TimedRotatingFileHandler(
 | 
| @@ -127,14 +133,25 @@
 | 
|              logthreshold = logging.DEBUG
 | 
|          else:
 | 
|              logthreshold = logging.ERROR
 | 
| -    elif isinstance(logthreshold, basestring):
 | 
| +    elif isinstance(logthreshold, string_types):
 | 
|          logthreshold = getattr(logging, THRESHOLD_MAP.get(logthreshold,
 | 
|                                                            logthreshold))
 | 
|      return logthreshold
 | 
|  
 | 
| +def _colorable_terminal():
 | 
| +    isatty = hasattr(sys.__stdout__, 'isatty') and sys.__stdout__.isatty()
 | 
| +    if not isatty:
 | 
| +        return False
 | 
| +    if os.name == 'nt':
 | 
| +        try:
 | 
| +            from colorama import init as init_win32_colors
 | 
| +        except ImportError:
 | 
| +            return False
 | 
| +        init_win32_colors()
 | 
| +    return True
 | 
| +
 | 
|  def get_formatter(logformat=LOG_FORMAT, logdateformat=LOG_DATE_FORMAT):
 | 
| -    isatty = hasattr(sys.__stdout__, 'isatty') and sys.__stdout__.isatty()
 | 
| -    if isatty and sys.platform != 'win32':
 | 
| +    if _colorable_terminal():
 | 
|          fmt = ColorFormatter(logformat, logdateformat)
 | 
|          def col_fact(record):
 | 
|              if 'XXX' in record.message:
 | 
| 
 |