2014-10-27 16:29:04 -06:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import logging
|
|
|
|
from logging.handlers import RotatingFileHandler
|
|
|
|
import paths
|
|
|
|
import sys
|
|
|
|
|
|
|
|
APP_LOG_FILE = 'debug.log'
|
|
|
|
ERROR_LOG_FILE = "error.log"
|
2015-03-16 19:24:27 -06:00
|
|
|
MESSAGE_FORMAT = "%(asctime)s %(name)s %(levelname)s: %(message)s"
|
|
|
|
DATE_FORMAT = u"%d/%m/%Y %H:%M:%S"
|
2014-10-27 16:29:04 -06:00
|
|
|
|
2015-03-16 19:24:27 -06:00
|
|
|
formatter = logging.Formatter(MESSAGE_FORMAT.decode("utf-8"), datefmt=DATE_FORMAT)
|
2014-10-27 16:29:04 -06:00
|
|
|
|
|
|
|
requests_log = logging.getLogger("requests")
|
|
|
|
requests_log.setLevel(logging.WARNING)
|
|
|
|
oauthlib_log = logging.getLogger("oauthlib")
|
|
|
|
oauthlib_log.setLevel(logging.WARNING)
|
2015-01-18 17:19:39 -06:00
|
|
|
requests_oauthlib_log = logging.getLogger("requests_oauthlib")
|
|
|
|
requests_oauthlib_log.setLevel(logging.WARNING)
|
2014-10-27 16:29:04 -06:00
|
|
|
suds_log = logging.getLogger("suds")
|
|
|
|
suds_log.setLevel(logging.WARNING)
|
|
|
|
server_log = logging.getLogger("BaseHTTPServer")
|
|
|
|
server_log.setLevel(logging.WARNING)
|
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger()
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
|
|
|
|
#handlers
|
|
|
|
|
2015-01-27 17:09:28 -06:00
|
|
|
app_handler = RotatingFileHandler(paths.logs_path(APP_LOG_FILE), mode="w")
|
2014-10-27 16:29:04 -06:00
|
|
|
app_handler.setFormatter(formatter)
|
|
|
|
app_handler.setLevel(logging.DEBUG)
|
|
|
|
logger.addHandler(app_handler)
|
|
|
|
|
2015-01-18 17:19:39 -06:00
|
|
|
error_handler = logging.FileHandler(paths.logs_path(ERROR_LOG_FILE), mode="w")
|
2014-10-27 16:29:04 -06:00
|
|
|
error_handler.setFormatter(formatter)
|
|
|
|
error_handler.setLevel(logging.ERROR)
|
|
|
|
logger.addHandler(error_handler)
|