Minimal compatibility for logging feature and Python 2.6

This commit is contained in:
Nicolas Hennion 2014-07-09 14:58:32 +02:00
parent e4a91eb462
commit aeee86d6c9
2 changed files with 8 additions and 2 deletions

View File

@ -10,7 +10,6 @@ install:
- pip install coveralls
script:
- python setup.py install
- python unitest.py
- coverage run --source=glances unitest.py
after_success:
- coveralls

View File

@ -72,5 +72,12 @@ LOGGING_CFG = {
def glancesLogger():
_logger = logging.getLogger()
logging.config.dictConfig(LOGGING_CFG)
try:
logging.config.dictConfig(LOGGING_CFG)
except AttributeError:
# dictConfig is only available for Python 2.7 or higher
# Minimal configuration for Python 2.6
logging.basicConfig(filename=os.path.join(tempfile.gettempdir(), 'glances.log'),
level=logging.DEBUG,
format='%(asctime)s -- %(levelname)s -- %(message)s')
return _logger