Skip to content

Commit e2523da

Browse files
committed
make logging unobtrusive
1 parent e4066c1 commit e2523da

3 files changed

Lines changed: 14 additions & 24 deletions

File tree

identify/main/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
from identify.main.identify_sync_client import SyncIdentifyClient
2-
from identify.util import logger
32

43

54
def get_client(config):
65
'''
76
Entry point for the Identify API client
87
'''
98
_async = config.get('async', False)
10-
if _async: raise Exception('Async client not yet implemented')
11-
12-
if 'log_level' in config:
13-
logger.set_level(config['log_level'])
9+
if _async:
10+
raise Exception('Async client not yet implemented')
1411

1512
return SyncIdentifyClient(config)

identify/util/logger.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
from __future__ import absolute_import, division, print_function, \
22
unicode_literals
33
import logging
4-
import colorlog
4+
5+
try:
6+
from logging import NullHandler
7+
except ImportError: # Python 2.7+
8+
class NullHandler(logging.Handler):
9+
def emit(self, record):
10+
pass
11+
12+
13+
logging.getLogger(__name__).addHandler(NullHandler())
514

615
_LOGLEVELS = {
716
'CRITICAL': logging.CRITICAL,
@@ -13,20 +22,5 @@
1322
}
1423

1524

16-
handler = colorlog.StreamHandler()
17-
handler.setFormatter(colorlog.ColoredFormatter(
18-
'%(log_color)s%(levelname)s:%(name)s: %(message)s'
19-
))
20-
21-
LOGGER = colorlog.getLogger('IDENTIFY')
22-
LOGGER.addHandler(handler)
23-
LOGGER.setLevel(logging.CRITICAL)
24-
25-
26-
def set_level(strlevel):
27-
'''
28-
'''
29-
lvl = _LOGLEVELS.get(strlevel.upper())
30-
if not lvl:
31-
raise Exception('Invalid Log Level %s' % strlevel)
32-
LOGGER.setLevel(lvl)
25+
LOGGER = logging.getLogger('IDENTIFY')
26+
LOGGER.addHandler(NullHandler())

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def run(self):
8181
# Project requirements
8282
install_requires = [
8383
'argparse>=1.1',
84-
'colorlog>=2.10.0',
8584
'requests>=2.14.2',
8685
'six>=1.10.0',
8786
]

0 commit comments

Comments
 (0)