Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: third_party/logilab/common/logging_ext.py

Issue 739393004: Revert "Revert "pylint: upgrade to 1.3.1"" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/logilab/common/hg.py ('k') | third_party/logilab/common/modutils.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/logilab/common/logging_ext.py
===================================================================
--- third_party/logilab/common/logging_ext.py (revision 293047)
+++ 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:
« no previous file with comments | « third_party/logilab/common/hg.py ('k') | third_party/logilab/common/modutils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698