mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
add "log_level" to settings
This commit is contained in:
parent
9f395dc57d
commit
450b84c9d0
4 changed files with 19 additions and 8 deletions
|
@ -13,13 +13,6 @@ import searx.settings_loader
|
||||||
from searx.settings_defaults import settings_set_defaults
|
from searx.settings_defaults import settings_set_defaults
|
||||||
|
|
||||||
|
|
||||||
# Debug
|
|
||||||
LOG_FORMAT_DEBUG = '%(levelname)-7s %(name)-30.30s: %(message)s'
|
|
||||||
|
|
||||||
# Production
|
|
||||||
LOG_FORMAT_PROD = '%(asctime)-15s %(levelname)s:%(name)s: %(message)s'
|
|
||||||
LOG_LEVEL_PROD = logging.WARNING
|
|
||||||
|
|
||||||
searx_dir = abspath(dirname(__file__))
|
searx_dir = abspath(dirname(__file__))
|
||||||
searx_parent_dir = abspath(dirname(dirname(__file__)))
|
searx_parent_dir = abspath(dirname(dirname(__file__)))
|
||||||
settings, settings_load_message = searx.settings_loader.load_settings()
|
settings, settings_load_message = searx.settings_loader.load_settings()
|
||||||
|
@ -27,6 +20,14 @@ settings, settings_load_message = searx.settings_loader.load_settings()
|
||||||
if settings is not None:
|
if settings is not None:
|
||||||
settings = settings_set_defaults(settings)
|
settings = settings_set_defaults(settings)
|
||||||
|
|
||||||
|
# Debug
|
||||||
|
LOG_FORMAT_DEBUG = '%(levelname)-7s %(name)-30.30s: %(message)s'
|
||||||
|
|
||||||
|
# Production
|
||||||
|
LOG_FORMAT_PROD = '%(asctime)-15s %(levelname)s:%(name)s: %(message)s'
|
||||||
|
LOG_LEVEL_PROD = (settings['general']).get("log_level", "info").upper()
|
||||||
|
LOG_LEVEL_PROD = logging.getLevelName(LOG_LEVEL_PROD)
|
||||||
|
|
||||||
_unset = object()
|
_unset = object()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
general:
|
general:
|
||||||
debug: false # Debug mode, only for development
|
log_level: info # notset/debug/info/warning/error/critical
|
||||||
instance_name: "SearXNG" # displayed name
|
instance_name: "SearXNG" # displayed name
|
||||||
contact_url: false # mailto:contact@example.com
|
contact_url: false # mailto:contact@example.com
|
||||||
enable_metrics: true # record stats
|
enable_metrics: true # record stats
|
||||||
|
|
|
@ -47,6 +47,7 @@ SEARX_ENVIRON_VARIABLES = {
|
||||||
'SEARX_DISABLE_ETC_SETTINGS': 'SEARXNG_DISABLE_ETC_SETTINGS',
|
'SEARX_DISABLE_ETC_SETTINGS': 'SEARXNG_DISABLE_ETC_SETTINGS',
|
||||||
'SEARX_SETTINGS_PATH': 'SEARXNG_SETTINGS_PATH',
|
'SEARX_SETTINGS_PATH': 'SEARXNG_SETTINGS_PATH',
|
||||||
'SEARX_DEBUG': 'SEARXNG_DEBUG',
|
'SEARX_DEBUG': 'SEARXNG_DEBUG',
|
||||||
|
'SEARX_LOGLEVEL': 'SEARXNG_LOGLEVEL',
|
||||||
'SEARX_PORT': 'SEARXNG_PORT',
|
'SEARX_PORT': 'SEARXNG_PORT',
|
||||||
'SEARX_BIND_ADDRESS': 'SEARXNG_BIND_ADDRESS',
|
'SEARX_BIND_ADDRESS': 'SEARXNG_BIND_ADDRESS',
|
||||||
'SEARX_SECRET': 'SEARXNG_SECRET',
|
'SEARX_SECRET': 'SEARXNG_SECRET',
|
||||||
|
@ -140,6 +141,7 @@ def apply_schema(settings, schema, path_list):
|
||||||
SCHEMA = {
|
SCHEMA = {
|
||||||
'general': {
|
'general': {
|
||||||
'debug': SettingsValue(bool, False, 'SEARXNG_DEBUG'),
|
'debug': SettingsValue(bool, False, 'SEARXNG_DEBUG'),
|
||||||
|
'log_level': SettingsValue(str, 'info', 'SEARXNG_LOGLEVEL'),
|
||||||
'instance_name': SettingsValue(str, 'SearXNG'),
|
'instance_name': SettingsValue(str, 'SearXNG'),
|
||||||
'contact_url': SettingsValue((None, False, str), None),
|
'contact_url': SettingsValue((None, False, str), None),
|
||||||
'enable_metrics': SettingsValue(bool, True),
|
'enable_metrics': SettingsValue(bool, True),
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
import pprint
|
||||||
|
|
||||||
from os import environ
|
from os import environ
|
||||||
from os.path import dirname, join, abspath, isfile
|
from os.path import dirname, join, abspath, isfile
|
||||||
|
@ -140,5 +141,12 @@ def load_settings(load_user_setttings=True):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Consider to deprecate general.debug in the future.
|
||||||
|
# To make everything work correctly, set general.debug = general.log_level=="debug"
|
||||||
|
if "log_level" not in user_settings['general']: user_settings['general']['log_level'] = 'info'
|
||||||
|
user_settings['general']['debug'] = (user_settings['general']['log_level']=="debug")
|
||||||
|
|
||||||
|
pprint.pprint(user_settings['general'], indent=4, sort_dicts=True)
|
||||||
|
|
||||||
# the user settings, fully replace the default configuration
|
# the user settings, fully replace the default configuration
|
||||||
return (user_settings, 'load the user settings from {}'.format(user_settings_path))
|
return (user_settings, 'load the user settings from {}'.format(user_settings_path))
|
||||||
|
|
Loading…
Add table
Reference in a new issue