Split proxy access and errors logs

This commit is contained in:
Igor Chubin 2022-10-26 08:41:20 +02:00
parent 34684cb264
commit 8f433de15a
2 changed files with 11 additions and 7 deletions

View file

@ -37,12 +37,13 @@ MYDIR = os.path.abspath(
sys.path.append("%s/lib/" % MYDIR)
import proxy_log
from globals import PROXY_CACHEDIR, PROXY_HOST, PROXY_PORT, USE_METNO, USER_AGENT, MISSING_TRANSLATION_LOG, PROXY_LOG_FILE
import globals
from globals import PROXY_CACHEDIR, PROXY_HOST, PROXY_PORT, USE_METNO, USER_AGENT, MISSING_TRANSLATION_LOG
from metno import create_standard_json_from_metno, metno_request
from translations import PROXY_LANGS
# pylint: enable=wrong-import-position
proxy_logger = proxy_log.LoggerWWO(PROXY_LOG_FILE)
proxy_logger = proxy_log.LoggerWWO(globals.PROXY_LOG_ACCESS, globals.PROXY_LOG_ERRORS)
def is_testmode():
"""Server is running in the wttr.in test mode"""
@ -250,6 +251,7 @@ def _fetch_content_and_headers(path, query_string, **kwargs):
try:
data = json.loads(response.content)
error = data.get("data", {}).get("error", "")
if error:
try:
error = error[0]["msg"]
except (ValueError, IndexError):

View file

@ -35,7 +35,9 @@ PNG_CACHE = os.path.join(_DATADIR, "cache/png")
LRU_CACHE = os.path.join(_DATADIR, "cache/lru")
LOG_FILE = os.path.join(_LOGDIR, 'main.log')
PROXY_LOG_FILE = os.path.join(_LOGDIR, 'proxy.log')
PROXY_LOG_ACCESS = os.path.join(_LOGDIR, 'proxy-access.log')
PROXY_LOG_ERRORS = os.path.join(_LOGDIR, 'proxy-errors.log')
MISSING_TRANSLATION_LOG = os.path.join(_LOGDIR, 'missing-translation/%s.log')