Commit 4e4a8033 authored by Yuanle Song's avatar Yuanle Song
Browse files

v0.19.1 do not try to run sudo in configlogger.py

This may require user interactive and is very bad behavior on import/app
runs.

also update default log level for non-prod env to DEBUG.
parent 10d30f21
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
(defproject python/lein-template "0.19.0"
(defproject python/lein-template "0.19.1"
  :description "lein template for a python project"
  :repositories [["snapshots"
                  {:url "http://devserv.game.yy.com/nexus/content/repositories/snapshots"
+3 −16
Original line number Diff line number Diff line
@@ -28,26 +28,13 @@ def load_logger_config():
        fileConfig(resource_filename("{{name}}", "logger.conf"))
        return

    try:
        os.makedirs(logdir)
        fileConfig(resource_filename("{{name}}", "logger.conf"))
        return
    except OSError as _:
        pass

    import subprocess
    exit_code = subprocess.call(["sudo", "mkdir", "-p", logdir])
    if exit_code == 0:
        fileConfig(resource_filename("{{name}}", "logger.conf"))
        return

    TESTING = os.getenv("PYTEST") == "1"
    level = logging.DEBUG if TESTING else logging.INFO
    ENV = os.getenv("ENV", "test")
    level = logging.INFO if ENV == "prod" else logging.DEBUG
    logging.basicConfig(
        format='%(asctime)s [%(module)s] %(levelname)-8s %(message)s',
        level=level)
    logging.info("Create log dir %s failed. Using basic config, level=%s",
                 logdir, "DEBUG" if TESTING else "INFO")
                 logdir, level)


logging.captureWarnings(True)