From 6ed11f176c03eda3d50baac4fac3caf483ad2064 Mon Sep 17 00:00:00 2001 From: Kobi Meirson Date: Wed, 19 Oct 2022 22:46:38 +0300 Subject: [PATCH] feat: more granular controls for logging --- src/nginxconfig/generators/conf/nginx.conf.js | 2 +- .../generators/conf/website.conf.js | 10 ++- .../de/templates/domain_sections/logging.js | 2 + .../de/templates/global_sections/logging.js | 2 + .../en/templates/domain_sections/logging.js | 2 + .../en/templates/global_sections/logging.js | 2 + .../es/templates/domain_sections/logging.js | 2 + .../es/templates/global_sections/logging.js | 2 + .../fr/templates/domain_sections/logging.js | 2 + .../fr/templates/global_sections/logging.js | 2 + .../ja/templates/domain_sections/logging.js | 2 + .../ja/templates/global_sections/logging.js | 2 + .../pl/templates/domain_sections/logging.js | 2 + .../pl/templates/global_sections/logging.js | 2 + .../templates/domain_sections/logging.js | 2 + .../templates/global_sections/logging.js | 2 + .../ru/templates/domain_sections/logging.js | 2 + .../ru/templates/global_sections/logging.js | 2 + .../templates/domain_sections/logging.js | 2 + .../templates/global_sections/logging.js | 2 + .../templates/domain_sections/logging.js | 2 + .../templates/global_sections/logging.js | 2 + .../templates/domain_sections/logging.vue | 89 +++++++++++++++++++ .../templates/global_sections/logging.vue | 44 +++++++-- .../util/{get_log_paths.js => logging.js} | 11 +-- 25 files changed, 176 insertions(+), 20 deletions(-) rename src/nginxconfig/util/{get_log_paths.js => logging.js} (75%) diff --git a/src/nginxconfig/generators/conf/nginx.conf.js b/src/nginxconfig/generators/conf/nginx.conf.js index 544e6ff..8142680 100644 --- a/src/nginxconfig/generators/conf/nginx.conf.js +++ b/src/nginxconfig/generators/conf/nginx.conf.js @@ -110,7 +110,7 @@ export default (domains, global) => { if (global.logging.accessLog.computed) { config.http.push(['access_log', global.logging.accessLogPath.computed.trim() + (global.logging.cloudflare.computed ? ' cloudflare' : '') + - (global.logging.accessLogArguments.computed ? ` ${global.logging.accessLogArguments.computed.trim()}` : ''), + (global.logging.accessLogParameters.computed ? ` ${global.logging.accessLogParameters.computed.trim()}` : ''), ]); } else { config.http.push(['access_log', 'off']); diff --git a/src/nginxconfig/generators/conf/website.conf.js b/src/nginxconfig/generators/conf/website.conf.js index a33938b..e6f99bf 100644 --- a/src/nginxconfig/generators/conf/website.conf.js +++ b/src/nginxconfig/generators/conf/website.conf.js @@ -25,7 +25,6 @@ THE SOFTWARE. */ import { getSslCertificate, getSslCertificateKey } from '../../util/get_ssl_certificate'; -import { getAccessLogDomainPath, getErrorLogDomainPath } from '../../util/get_log_paths'; import { extensions, gzipTypes } from '../../util/types_extensions'; import commonHsts from '../../util/common_hsts'; import securityConf from './security.conf'; @@ -226,13 +225,16 @@ export default (domain, domains, global, ipPortPairs) => { if (domain.logging.accessLog.computed) serverConfig.push(['access_log', - getAccessLogDomainPath(domain, global) + + domain.logging.accessLogPath.computed.trim() + (global.logging.cloudflare.computed ? ' cloudflare' : '') + - (global.logging.accessLogArguments.computed ? ` ${global.logging.accessLogArguments.computed.trim()}`: ''), + (domain.logging.accessLogParameters.computed ? ` ${domain.logging.accessLogParameters.computed.trim()}`: ''), ]); if (domain.logging.errorLog.computed) - serverConfig.push(['error_log', getErrorLogDomainPath(domain, global)]); + serverConfig.push(['error_log', + domain.logging.errorLogPath.computed.trim() + + ` ${domain.logging.errorLogLevel.computed}`, + ]); } // index.php diff --git a/src/nginxconfig/i18n/de/templates/domain_sections/logging.js b/src/nginxconfig/i18n/de/templates/domain_sections/logging.js index bbe0b08..eaaacda 100644 --- a/src/nginxconfig/i18n/de/templates/domain_sections/logging.js +++ b/src/nginxconfig/i18n/de/templates/domain_sections/logging.js @@ -27,4 +27,6 @@ THE SOFTWARE. export default { byDomain: 'der Domain', enableForThisDomain: 'Für diese Domain aktivieren', + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate }; diff --git a/src/nginxconfig/i18n/de/templates/global_sections/logging.js b/src/nginxconfig/i18n/de/templates/global_sections/logging.js index 148c2d0..bc3f45d 100644 --- a/src/nginxconfig/i18n/de/templates/global_sections/logging.js +++ b/src/nginxconfig/i18n/de/templates/global_sections/logging.js @@ -29,6 +29,8 @@ import common from '../../common'; export default { enableFileNotFoundErrorLogging: `${common.enable} "Seite nicht gefunden" Error Logging in`, logformat: 'log_format', + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate enableCloudflare: 'Füge Cloudflare Anfrage-Header dem Standard Log-Format hinzu', cfRay: 'CF-Ray', cfConnectingIp: 'CF-Connecting-IP', diff --git a/src/nginxconfig/i18n/en/templates/domain_sections/logging.js b/src/nginxconfig/i18n/en/templates/domain_sections/logging.js index 16f42e7..31e972c 100644 --- a/src/nginxconfig/i18n/en/templates/domain_sections/logging.js +++ b/src/nginxconfig/i18n/en/templates/domain_sections/logging.js @@ -29,4 +29,6 @@ import common from '../../common'; export default { byDomain: 'by domain', enableForThisDomain: `${common.enable} for this domain`, + arguments: 'arguments', + level: 'logging level', }; diff --git a/src/nginxconfig/i18n/en/templates/global_sections/logging.js b/src/nginxconfig/i18n/en/templates/global_sections/logging.js index 26e6db9..48caccb 100644 --- a/src/nginxconfig/i18n/en/templates/global_sections/logging.js +++ b/src/nginxconfig/i18n/en/templates/global_sections/logging.js @@ -29,6 +29,8 @@ import common from '../../common'; export default { enableFileNotFoundErrorLogging: `${common.enable} file not found error logging in`, logformat: 'log_format', + arguments: 'arguments', + level: 'logging level', enableCloudflare: 'add Cloudflare request headers to the default log format', cfRay: 'CF-Ray', cfConnectingIp: 'CF-Connecting-IP', diff --git a/src/nginxconfig/i18n/es/templates/domain_sections/logging.js b/src/nginxconfig/i18n/es/templates/domain_sections/logging.js index 3a04692..16c35b2 100644 --- a/src/nginxconfig/i18n/es/templates/domain_sections/logging.js +++ b/src/nginxconfig/i18n/es/templates/domain_sections/logging.js @@ -29,4 +29,6 @@ import common from '../../common'; export default { byDomain: 'por dominio', enableForThisDomain: `${common.enable} para este dominio`, + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate }; diff --git a/src/nginxconfig/i18n/es/templates/global_sections/logging.js b/src/nginxconfig/i18n/es/templates/global_sections/logging.js index c8985be..062e429 100644 --- a/src/nginxconfig/i18n/es/templates/global_sections/logging.js +++ b/src/nginxconfig/i18n/es/templates/global_sections/logging.js @@ -29,6 +29,8 @@ import common from '../../common'; export default { enableFileNotFoundErrorLogging: `${common.enable} el registro de error de archivo no encontrado`, logformat: 'log_format', + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate enableCloudflare: 'agregar cabecera de petición de Cloudflare en el formato por defecto del registro', cfRay: 'CF-Ray', cfConnectingIp: 'CF-Connecting-IP', diff --git a/src/nginxconfig/i18n/fr/templates/domain_sections/logging.js b/src/nginxconfig/i18n/fr/templates/domain_sections/logging.js index 51d9cfb..3265cde 100644 --- a/src/nginxconfig/i18n/fr/templates/domain_sections/logging.js +++ b/src/nginxconfig/i18n/fr/templates/domain_sections/logging.js @@ -29,4 +29,6 @@ import common from '../../common'; export default { byDomain: 'par domaine', enableForThisDomain: `${common.enable} pour ce domaine`, + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate }; diff --git a/src/nginxconfig/i18n/fr/templates/global_sections/logging.js b/src/nginxconfig/i18n/fr/templates/global_sections/logging.js index ccce5bf..eee0c57 100644 --- a/src/nginxconfig/i18n/fr/templates/global_sections/logging.js +++ b/src/nginxconfig/i18n/fr/templates/global_sections/logging.js @@ -29,6 +29,8 @@ import common from '../../common'; export default { enableFileNotFoundErrorLogging: `${common.enable} les erreurs de fichiers introuvables lors de la journalisation`, logformat: 'log_format', + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate enableCloudflare: 'ajouter les en-têtes de requête CloudFlare au format de journal par défaut', cfRay: 'CF-Ray', cfConnectingIp: 'CF-Connecting-IP', diff --git a/src/nginxconfig/i18n/ja/templates/domain_sections/logging.js b/src/nginxconfig/i18n/ja/templates/domain_sections/logging.js index b1ff230..f53efae 100644 --- a/src/nginxconfig/i18n/ja/templates/domain_sections/logging.js +++ b/src/nginxconfig/i18n/ja/templates/domain_sections/logging.js @@ -29,4 +29,6 @@ import common from '../../common'; export default { byDomain: '(ドメインごと)', enableForThisDomain: `このドメインで${common.enable}`, + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate }; diff --git a/src/nginxconfig/i18n/ja/templates/global_sections/logging.js b/src/nginxconfig/i18n/ja/templates/global_sections/logging.js index 0a85911..39c0781 100644 --- a/src/nginxconfig/i18n/ja/templates/global_sections/logging.js +++ b/src/nginxconfig/i18n/ja/templates/global_sections/logging.js @@ -29,6 +29,8 @@ import common from '../../common'; export default { enableFileNotFoundErrorLogging: `FILE NOT FOUND エラーのロギングを${common.enable}`, logformat: 'log_format', + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate enableCloudflare: 'デフォルトのログフォーマットに Cloudflare のリクエストヘッダを追加する', cfRay: 'CF-Ray', cfConnectingIp: 'CF-Connecting-IP', diff --git a/src/nginxconfig/i18n/pl/templates/domain_sections/logging.js b/src/nginxconfig/i18n/pl/templates/domain_sections/logging.js index 5e02483..325f93d 100644 --- a/src/nginxconfig/i18n/pl/templates/domain_sections/logging.js +++ b/src/nginxconfig/i18n/pl/templates/domain_sections/logging.js @@ -29,4 +29,6 @@ import common from '../../common'; export default { byDomain: 'wg. domen', enableForThisDomain: `${common.enable} dla tej domeny`, + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate }; diff --git a/src/nginxconfig/i18n/pl/templates/global_sections/logging.js b/src/nginxconfig/i18n/pl/templates/global_sections/logging.js index 06937f6..9b3939b 100644 --- a/src/nginxconfig/i18n/pl/templates/global_sections/logging.js +++ b/src/nginxconfig/i18n/pl/templates/global_sections/logging.js @@ -29,6 +29,8 @@ import common from '../../common'; export default { enableFileNotFoundErrorLogging: `${common.enable} logowanie błędów o nieznalezionych plikach`, logformat: 'log_format', + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate enableCloudflare: 'dodaj nagłówki żądań Cloudflare do domyślnego formatu dziennika ', cfRay: 'CF-Ray', cfConnectingIp: 'CF-Connecting-IP', diff --git a/src/nginxconfig/i18n/pt-br/templates/domain_sections/logging.js b/src/nginxconfig/i18n/pt-br/templates/domain_sections/logging.js index b483d88..b7d894e 100644 --- a/src/nginxconfig/i18n/pt-br/templates/domain_sections/logging.js +++ b/src/nginxconfig/i18n/pt-br/templates/domain_sections/logging.js @@ -29,4 +29,6 @@ import common from '../../common'; export default { byDomain: 'por domínio', enableForThisDomain: `${common.enable} para este domínio`, + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate }; diff --git a/src/nginxconfig/i18n/pt-br/templates/global_sections/logging.js b/src/nginxconfig/i18n/pt-br/templates/global_sections/logging.js index 864b3da..c2a811a 100644 --- a/src/nginxconfig/i18n/pt-br/templates/global_sections/logging.js +++ b/src/nginxconfig/i18n/pt-br/templates/global_sections/logging.js @@ -29,6 +29,8 @@ import common from '../../common'; export default { enableFileNotFoundErrorLogging: `${common.enable} erro de arquivo não encontrado ao fazer login`, logformat: 'log_format', + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate enableCloudflare: 'adicionar cabeçalhos de solicitação Cloudflare ao formato de log padrão', cfRay: 'CF-Ray', cfConnectingIp: 'CF-Connecting-IP', diff --git a/src/nginxconfig/i18n/ru/templates/domain_sections/logging.js b/src/nginxconfig/i18n/ru/templates/domain_sections/logging.js index 1ad7d67..0c7900d 100644 --- a/src/nginxconfig/i18n/ru/templates/domain_sections/logging.js +++ b/src/nginxconfig/i18n/ru/templates/domain_sections/logging.js @@ -29,4 +29,6 @@ import common from '../../common'; export default { byDomain: 'по домену', enableForThisDomain: `${common.enable} для этого домена`, + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate }; diff --git a/src/nginxconfig/i18n/ru/templates/global_sections/logging.js b/src/nginxconfig/i18n/ru/templates/global_sections/logging.js index 19cfd71..b065731 100644 --- a/src/nginxconfig/i18n/ru/templates/global_sections/logging.js +++ b/src/nginxconfig/i18n/ru/templates/global_sections/logging.js @@ -29,6 +29,8 @@ import common from '../../common'; export default { enableFileNotFoundErrorLogging: `${common.enable} логирование ошибок для файлов, которые не были найдены при запросе`, logformat: 'log_format', + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate enableCloudflare: 'добавить Cloudflare хедеры запроса в дефолтный формат логов', cfRay: 'CF-Ray', cfConnectingIp: 'CF-Connecting-IP', diff --git a/src/nginxconfig/i18n/zh-cn/templates/domain_sections/logging.js b/src/nginxconfig/i18n/zh-cn/templates/domain_sections/logging.js index 48323b6..d024cf4 100644 --- a/src/nginxconfig/i18n/zh-cn/templates/domain_sections/logging.js +++ b/src/nginxconfig/i18n/zh-cn/templates/domain_sections/logging.js @@ -29,4 +29,6 @@ import common from '../../common'; export default { byDomain: '在此站点', enableForThisDomain: `为此站点${common.enable}`, + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate }; diff --git a/src/nginxconfig/i18n/zh-cn/templates/global_sections/logging.js b/src/nginxconfig/i18n/zh-cn/templates/global_sections/logging.js index f3f8b60..064c390 100644 --- a/src/nginxconfig/i18n/zh-cn/templates/global_sections/logging.js +++ b/src/nginxconfig/i18n/zh-cn/templates/global_sections/logging.js @@ -29,6 +29,8 @@ import common from '../../common'; export default { enableFileNotFoundErrorLogging: `${common.enable}“文件未找到”错误日志:`, logformat: 'log_format', + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate enableCloudflare: '将Cloudflare请求头部添加到默认日志格式', cfRay: 'CF-Ray', cfConnectingIp: 'CF-Connecting-IP', diff --git a/src/nginxconfig/i18n/zh-tw/templates/domain_sections/logging.js b/src/nginxconfig/i18n/zh-tw/templates/domain_sections/logging.js index 20c9c93..49ccb8d 100644 --- a/src/nginxconfig/i18n/zh-tw/templates/domain_sections/logging.js +++ b/src/nginxconfig/i18n/zh-tw/templates/domain_sections/logging.js @@ -29,4 +29,6 @@ import common from '../../common'; export default { byDomain: '在此網域', enableForThisDomain: `為此網域${common.enable}`, + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate }; diff --git a/src/nginxconfig/i18n/zh-tw/templates/global_sections/logging.js b/src/nginxconfig/i18n/zh-tw/templates/global_sections/logging.js index a05d022..0b85b01 100644 --- a/src/nginxconfig/i18n/zh-tw/templates/global_sections/logging.js +++ b/src/nginxconfig/i18n/zh-tw/templates/global_sections/logging.js @@ -29,6 +29,8 @@ import common from '../../common'; export default { enableFileNotFoundErrorLogging: `${common.enable}「找不到檔案」錯誤日誌:`, logformat: 'log_format', + arguments: 'arguments', // TODO: translate + level: 'logging level', // TODO: translate enableCloudflare: '將 Cloudflare 請求標頭加入預設日誌格式', cfRay: 'CF-Ray', cfConnectingIp: 'CF-Connecting-IP', diff --git a/src/nginxconfig/templates/domain_sections/logging.vue b/src/nginxconfig/templates/domain_sections/logging.vue index 39969ef..c0a4abd 100644 --- a/src/nginxconfig/templates/domain_sections/logging.vue +++ b/src/nginxconfig/templates/domain_sections/logging.vue @@ -39,6 +39,32 @@ THE SOFTWARE. +
+ +
+ + + + +
+
+ +
+
+
+
+ +
@@ -55,6 +81,34 @@ THE SOFTWARE. {{ $t('templates.domainSections.logging.enableForThisDomain') }} +
+ +
+ + + + + +
+
+ +
+
+
+
+
+ + {{ value }} + +
@@ -65,17 +119,38 @@ THE SOFTWARE. diff --git a/src/nginxconfig/templates/global_sections/logging.vue b/src/nginxconfig/templates/global_sections/logging.vue index eb99757..6279703 100644 --- a/src/nginxconfig/templates/global_sections/logging.vue +++ b/src/nginxconfig/templates/global_sections/logging.vue @@ -51,18 +51,18 @@ THE SOFTWARE.
-
+
- +
-
+
@@ -94,6 +94,26 @@ THE SOFTWARE.
+
+
+ +
+
+
+
+
+ + {{ value }} + +
+
+
+
+
+
@@ -189,7 +209,9 @@ THE SOFTWARE.