From: Sarah Hoffmann Date: Mon, 25 Oct 2021 08:13:11 +0000 (+0200) Subject: allow relative paths for log files X-Git-Tag: v4.0.0~12 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/13e7398566909044348e57163cbd87a2095e8e80?ds=inline;hp=--cc allow relative paths for log files --- 13e7398566909044348e57163cbd87a2095e8e80 diff --git a/docs/customize/Settings.md b/docs/customize/Settings.md index b056a78b..428ef11c 100644 --- a/docs/customize/Settings.md +++ b/docs/customize/Settings.md @@ -634,7 +634,11 @@ Can be used as the same time as NOMINATIM_LOG_FILE. | **After Changes:** | run `nominatim refresh --website` | Enable logging of requests into a file with this setting by setting the log -file where to log to. The entries in the log file have the following format: +file where to log to. A relative file name is assumed to be relative to +the project directory. + + +The entries in the log file have the following format: "" diff --git a/nominatim/tools/refresh.py b/nominatim/tools/refresh.py index a6fe3d19..0a72b02b 100644 --- a/nominatim/tools/refresh.py +++ b/nominatim/tools/refresh.py @@ -3,6 +3,7 @@ Functions for bringing auxiliary data in the database up-to-date. """ import logging from textwrap import dedent +from pathlib import Path from psycopg2 import sql as pysql @@ -94,7 +95,7 @@ PHP_CONST_DEFS = ( ('Database_DSN', 'DATABASE_DSN', str), ('Default_Language', 'DEFAULT_LANGUAGE', str), ('Log_DB', 'LOG_DB', bool), - ('Log_File', 'LOG_FILE', str), + ('Log_File', 'LOG_FILE', Path), ('NoAccessControl', 'CORS_NOACCESSCONTROL', bool), ('Places_Max_ID_count', 'LOOKUP_MAX_COUNT', int), ('PolygonOutput_MaximumTypes', 'POLYGON_OUTPUT_MAX_TYPES', int), @@ -162,7 +163,12 @@ def _quote_php_variable(var_type, config, conf_name): if not getattr(config, conf_name): return 'false' - quoted = getattr(config, conf_name).replace("'", "\\'") + if var_type == Path: + value = str(config.get_path(conf_name)) + else: + value = getattr(config, conf_name) + + quoted = value.replace("'", "\\'") return f"'{quoted}'"