2013-10-11 00:13:55 +00:00
|
|
|
from gevent import monkey
|
|
|
|
monkey.patch_all(dns=False)
|
|
|
|
from .orchestra import monkey
|
|
|
|
monkey.patch_all()
|
2013-10-11 22:10:57 +00:00
|
|
|
|
|
|
|
import logging
|
2014-05-07 16:02:52 +00:00
|
|
|
|
2014-08-04 19:11:26 +00:00
|
|
|
|
|
|
|
__version__ = '0.1.0'
|
|
|
|
|
2014-06-12 16:47:28 +00:00
|
|
|
# We don't need to see log entries for each connection opened
|
|
|
|
logging.getLogger('requests.packages.urllib3.connectionpool').setLevel(
|
|
|
|
logging.WARN)
|
|
|
|
|
2014-05-07 16:02:52 +00:00
|
|
|
logging.basicConfig(
|
|
|
|
level=logging.INFO,
|
|
|
|
format='%(asctime)s.%(msecs)03d %(levelname)s:%(name)s:%(message)s')
|
2013-10-11 22:10:57 +00:00
|
|
|
log = logging.getLogger(__name__)
|
2014-05-07 16:02:52 +00:00
|
|
|
|
|
|
|
|
2014-08-13 19:10:15 +00:00
|
|
|
def setup_log_file(log_path):
|
|
|
|
root_logger = logging.getLogger()
|
|
|
|
handlers = root_logger.handlers
|
|
|
|
for handler in handlers:
|
|
|
|
if isinstance(handler, logging.FileHandler) and \
|
|
|
|
handler.stream.name == log_path:
|
|
|
|
log.debug("Already logging to %s; not adding new handler",
|
|
|
|
log_path)
|
|
|
|
return
|
|
|
|
formatter = logging.Formatter(
|
2014-05-07 16:02:52 +00:00
|
|
|
fmt=u'%(asctime)s.%(msecs)03d %(levelname)s:%(name)s:%(message)s',
|
|
|
|
datefmt='%Y-%m-%dT%H:%M:%S')
|
2014-08-13 19:10:15 +00:00
|
|
|
handler = logging.FileHandler(filename=log_path)
|
|
|
|
handler.setFormatter(formatter)
|
|
|
|
root_logger.addHandler(handler)
|