allow relative paths for log files

This commit is contained in:
Sarah Hoffmann
2021-10-25 10:13:11 +02:00
parent 8b90ee4364
commit 13e7398566
2 changed files with 13 additions and 3 deletions

View File

@@ -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:
<request time> <execution time in s> <number of results> <type> "<query string>"

View File

@@ -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}'"