feat: log plugin runtime errors
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once PLUGIN_ROOT . '/exec/lib/PluginLogger.php';
|
||||
|
||||
test('plugin logger writes exceptions to plugin log file', function (): void {
|
||||
$path = TEST_TMP . '/plugin.log';
|
||||
|
||||
PluginLogger::init($path);
|
||||
PluginLogger::exception(new RuntimeException('DirectAdmin API command failed'), 'CREATE');
|
||||
|
||||
$log = file_get_contents($path) ?: '';
|
||||
assert_contains('CREATE RuntimeException: DirectAdmin API command failed', $log);
|
||||
assert_contains('plugin_logger_test.php', $log);
|
||||
assert_same('0600', substr(sprintf('%o', fileperms($path)), -4));
|
||||
});
|
||||
Reference in New Issue
Block a user