fix(php8): RemoteCP-Log-Rauschen reduzieren und errors.log rotieren
Unter PHP 8 sind viele fruehere Notices (Undefined array key, Attempt to read property ...) Warnings. Der RemoteCP-Errorhandler ignoriert diese ohne Debug-Modus wie bisher unter PHP 7; im Test wuchs errors.log sonst um rund 500 KB in 15 Minuten. Zusaetzlich rotiere ich remotecp/cache/*.log per logrotate (10 MB, 5 Dateien).
This commit is contained in:
1 parent
1ecb6c93b3
commit
9f8f0f00d6
2 files changed
+22
-5
No files matched your search
@@ -271,13 +271,17 @@ if [ -d "$RCP_INC" ]; then
|
||||
-e "s/^ini_set\('display_errors', 1\);/ini_set('display_errors', getenv('PHP_DISPLAY_ERRORS') === 'true' ? 1 : 0);/" \
|
||||
-e "s/^ini_set\('display_startup_errors', 1\);/ini_set('display_startup_errors', getenv('PHP_DISPLAY_ERRORS') === 'true' ? 1 : 0);/" \
|
||||
"$RCP_INC/core.functions.php"
|
||||
# PHP-Warnings ohne Debug-Modus nur loggen, nicht im Browser anzeigen
|
||||
if ! grep -q 'tmserver-docker: PHP_DISPLAY_ERRORS' "$RCP_INC/core.functions.php"; then
|
||||
# PHP-Warnings ohne Debug-Modus nur loggen, nicht im Browser anzeigen.
|
||||
# v2: Unter PHP 8 sind viele fruehere Notices (Undefined array key, ...)
|
||||
# Warnings; die werden wie unter PHP 7 ignoriert, sonst waechst das Log
|
||||
# um mehrere MB pro Tag. Alte v1-Variante wird ersetzt.
|
||||
if ! grep -q 'tmserver-docker: PHP_DISPLAY_ERRORS v2' "$RCP_INC/core.functions.php"; then
|
||||
sed -i '/tmserver-docker: PHP_DISPLAY_ERRORS - /,/^\t}$/d' "$RCP_INC/core.functions.php"
|
||||
sed -i "/if(error_reporting() == 0) return;/a\\
|
||||
\\
|
||||
\\t//tmserver-docker: PHP_DISPLAY_ERRORS - PHP-Warnings ohne Debug-Modus nur loggen\\
|
||||
\\t//tmserver-docker: PHP_DISPLAY_ERRORS v2 - PHP-Warnings ohne Debug-Modus nur loggen\\
|
||||
\\tif(\$errno == E_WARNING \&\& !ini_get('display_errors')) {\\
|
||||
\\t\\twriteLog('errors', \"[\".date('c').\"] [PHP Warning] \$errstr on line \$errline in file \$errfile\");\\
|
||||
\\t\\tif(preg_match('/^(Undefined (array key|variable|property|offset)|Attempt to read property|Trying to access array offset|Constant .* already defined|Array to string conversion)/', \$errstr)) return true;\\
|
||||
\\t\\twriteLog('errors', \"[PHP Warning] \$errstr on line \$errline in file \$errfile\");\\
|
||||
\\t\\treturn true;\\
|
||||
\\t}" "$RCP_INC/core.functions.php"
|
||||
fi
|
||||
|
||||
@@ -42,6 +42,19 @@
|
||||
copytruncate
|
||||
}
|
||||
|
||||
# RemoteCP-Logs (liegen im persistenten Volume)
|
||||
/var/www/html/remotecp/cache/*.log
|
||||
{
|
||||
su www-data www-data
|
||||
size 10M
|
||||
rotate 5
|
||||
missingok
|
||||
notifempty
|
||||
compress
|
||||
delaycompress
|
||||
copytruncate
|
||||
}
|
||||
|
||||
# AdminServ-Logs (liegen im persistenten Volume)
|
||||
/var/www/html/logs/*.log
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user