commit d3b49a85d0c68f777562c00adff3350fc99c45d1
parent be425f08c4e5c242cac8ad30c148b04b6d581739
Author: Jan Dankert <develop@jandankert.de>
Date: Thu, 19 Nov 2020 17:59:57 +0100
New: Control log level with environment variables.
Diffstat:
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/Dockerfile b/Dockerfile
@@ -15,10 +15,14 @@ ENV DB_TYPE="mysql" \
DB_PASS="" \
CMS_MOTD="Welcome to dockerized CMS" \
CMS_NAME="OpenRat CMS (Docker)" \
- CMS_OPERATOR="Docker-Host" \
+ CMS_OPERATOR="" \
+ CMS_LOG_LEVEL="info" \
+ CMS_PRODUCTION="true" \
DOCROOT="/var/www/localhost/htdocs"
# Configuring apache webserver
+# - disable access log
+# - enable HTTP/2
RUN sed -i '/CustomLog/s/^/#/g' /etc/apache2/httpd.conf && \
sed -i '/LoadModule http2_module/s/^#//g' /etc/apache2/httpd.conf && \
sed -i 's/^Listen 80/Listen 8080/g' /etc/apache2/httpd.conf && \
@@ -58,23 +62,17 @@ database:\n\
dsn : "${env:DB_TYPE}:host=${env:DB_HOST}; dbname=${env:DB_NAME}"\n\
description: "PDO"\n\
name : "PRO"\n\
- type : pdo\n\
user : ${env:DB_USER}\n\
password : ${env:DB_PASS}\n\
base64 : true # store binary as BASE64 (should be true for postgresql)\n\
prefix : cms_\n\
suffix : _or\n\
- persistent : yes # use persistent connections (faster)\n\
- charset : UTF-8\n\
- cmd : ""\n\
- prepare : true\n\
- transaction: true\n\
\n\
log:\n\
file : "log/cms.log"\n\
- level : "info"\n\
+ level : "${env:CMS_LOG_LEVEL}"\n\
\n\
-production: true\n\
+production: ${env:CMS_PRODUCTION}\n\
\n\
publish:\n\
filesystem:\n\
diff --git a/modules/logger/Logger.class.php b/modules/logger/Logger.class.php
@@ -188,12 +188,13 @@ class Logger
error_log('logfile ' . Logger::$filename . ' is not writable');
error_log($text . "\n");
} else {
- // Schreiben in Logdatei
- error_log($text . "\n", 3, Logger::$filename);
+ // Writing to the logfile
+ // It's not a good idea to user error_log here because it failed on symlinked files.
+ file_put_contents( Logger::$filename,$text . "\n", FILE_APPEND );
}
}
- // ERROR- und WARN-Meldungen immer zusätzlich in das Error-Log schreiben.
+ // Errors and warnings are written to the common error log.
if (Logger::$level <= self::LEVEL_WARN)
error_log($text . "\n");
}