addLogEntry
The addLogEntry
hook is triggered when a new log entry is added. It passes
the message, the function and the action as arguments and does not expect
a return value.
Note
Using the addLogEntry
hook has been deprecated and will no longer work in Contao 5.0.
Parameters
string
$message
The log message.
string
$func
The PHP source method. Be aware that this is not necessarily a real function, the function accepts any string!
string
$action
The log action. Usually one of the following constants, but can be any string.
TL_ERROR
TL_ACCESS
TL_GENERAL
TL_FILES
TL_CRON
TL_FORMS
TL_CONFIGURATION
TL_NEWSLETTER
TL_REPOSITORY
Example
// src/EventListener/AddLogEntryListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('addLogEntry')]
class AddLogEntryListener
{
public function __invoke(string $message, string $func, string $action): void
{
// Do something …
}
}