[5.4] Fix log format configurations #46422
Open
+5
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of Changes
In setting up the log format:
\tinstead of raw tab characters so they remain clearly visible when reading the code, regardless of the editor or configuration.$options['format'].Perhaps surprisingly, despite the changes, this PR has no effect on the resulting logging in any way.
Background
In PR 46273, spaces in the log format were replaced with tab characters. During testing, it was observed that
\twas used in some places, prompting a proposal to unify this convention — that is, to consistently use\tfor tabulators in log format strings. See #46273 (comment).During the development of this PR, it was discovered that the variable
$options['format']is not used. As a result, definitions such as'{DATE}\t{TIME}\t{LEVEL}\t{CODE}\t{MESSAGE}'are effectively ignored. This also explains why\tsequences in PHP single-quoted strings were never interpreted — the format was simply never applied.👉 To define a custom logging format, use
$options['text_entry_format']instead.There was an unused configuration of
{LEVEL}in the indexer. I tested it withtext_entry_format, but the logged result was only-. Therefore, it seems to be ineffective, and the currently used default format continues to be used.Discussion
I would recommend to use only one default log format overall and simplify further in 6.1. For example instead
"{DATE}\t{TIME}"use"{DATETIME}"everywhere. What are you thinking?Testing Instructions
The different changes could be tested (ensure 'Log Almost Everything' is enabled):
administrator/components/com_finder/src/Controller/IndexerController.phpadministrator/logs/indexer.phpwith the default formatadministrator/components/com_finder/src/Response/Response.phpadministrator/logs/indexer.phpwith the default formatadministrator/components/com_joomlaupdate/src/Model/UpdateModel.phpadministrator/logs/joomla_update.phpwith the default formatadministrator/components/com_scheduler/src/Scheduler/Scheduler.phpadministrator/components/com_scheduler/src/Scheduler/Scheduler.phpafter line 128Log::addLogger()administraor/log/joomla_scheduler.phpin the given non-default formatadministrator/components/com_scheduler/src/Task/Task.phpadministrator/logs/task_*.log.phpin the given non-default formatinstallation/includes/app.phpconfiguration.phpinstallation/includes/app.phpfile, before$app->execute();administrator/logs/error.login given default formatinstallation/includes/cli.phpinstallation/includes/cli.phpfile, before$app->execute();php installation/joomla.php installadministrator/logs/error.login given default formatlibraries/src/Log/Logger/FormattedtextLogger.phpadministrator/logs/everything.phpin default formatvilibraries/src/Log/Logger/W3cLogger.phpincludes/app.phpfile, before$app->execute();administrator/logs/w3c-test.phpin the default formatplugins/system/webauthn/src/Extension/Webauthn.phpadministrator/logs/webauthn_system.phpin the given non-default formatoptions.formatandfind . -name \*.php | xargs grep "{MESSAGE}"Actual result BEFORE applying this Pull Request
$options['format']exist in code, default log format is set again and raw tab characters are used in log format strings.Expected result AFTER applying this Pull Request
$options['format']exist in code, default log format is not set again and\tis used in log format strings.Link to documentations
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed