瀏覽代碼

This is ugly, but it improves the current setup.

tags/v1.0^2
Ben Kurtovic 10 年之前
父節點
當前提交
9f935bbb74
共有 1 個檔案被更改,包括 7 行新增4 行删除
  1. +7
    -4
      bitshift/crawler/crawl.py

+ 7
- 4
bitshift/crawler/crawl.py 查看文件

@@ -33,10 +33,13 @@ def crawl():
thread.start()

def _configure_logging():
LOG_FILE_DIR = "log"
# This isn't ideal, since it means the bitshift python package must be kept
# inside the app, but it works for now:
root = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
log_dir = os.path.join(root, "logs")

if not os.path.exists(LOG_FILE_DIR):
os.mkdir(LOG_FILE_DIR)
if not os.path.exists(log_dir):
os.mkdir(log_dir)

logging.getLogger("requests").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)
@@ -46,7 +49,7 @@ def _configure_logging():
" %(message)s"), datefmt="%y-%m-%d %H:%M:%S")

handler = logging.handlers.TimedRotatingFileHandler(
"%s/%s" % (LOG_FILE_DIR, "app.log"), when="H", interval=1,
"%s/%s" % (log_dir, "app.log"), when="H", interval=1,
backupCount=20)
handler.setFormatter(formatter)



Loading…
取消
儲存