Skip to content
Snippets Groups Projects
Commit f8638504 authored by Randal Vanheede's avatar Randal Vanheede
Browse files

Drupal 11 compatibiity

parent cb8389df
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@
"source": "https://git.drupalcode.org/project/fileslog"
},
"require": {
"drupal/core": "^9.4 || ^10",
"drupal/core": "^10 || ^11",
"php": ">=8.1"
}
}
name: Private Files Logging
type: module
package: Logging
core_version_requirement: ^9.4 || ^10
core_version_requirement: ^10 || ^11
description: 'Logs and records system events to the private filesystem.'
configure: system.logging_settings
......@@ -5,6 +5,8 @@
* The install/update hooks for the fileslog module.
*/
use Drupal\Core\Site\Settings;
/**
* Implements hook_requirements().
*/
......@@ -28,6 +30,14 @@ function fileslog_requirements($phase) {
'severity' => REQUIREMENT_ERROR,
];
}
if (!Settings::get('file_private_path')) {
$requirements['fileslog_dblog'] = [
'title' => t('Fileslog module'),
'description' => t('The Fileslog module requires the private filesystem to be set up.'),
'severity' => REQUIREMENT_ERROR,
];
}
}
return $requirements;
......
......@@ -27,13 +27,9 @@ function fileslog_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_cron().
*/
function fileslog_cron() {
/**
* @var \Drupal\Core\File\FileSystemInterface $filesystem
*/
/** @var \Drupal\Core\File\FileSystemInterface $filesystem */
$filesystem = \Drupal::service('file_system');
/**
* @var \Drupal\fileslog\FilesLogManagerInterface $files_log_manager
*/
/** @var \Drupal\fileslog\FilesLogManagerInterface $files_log_manager */
$files_log_manager = \Drupal::service('fileslog.manager');
$dir = FilesLogInterface::DIRECTORY;
$max_items = (int) \Drupal::config('fileslog.settings')->get('max_items') ?: 1000;
......
......@@ -123,7 +123,7 @@ class FilesLogController extends ControllerBase {
<tr><th><strong>{{ "Date"|t }}</strong></th><td>{{ date }}</td></tr>
<tr><th><strong>{{ "User"|t }}</strong></th><td>{{ user|raw }}</td></tr>
<tr><th><strong>{{ "Location"|t }}</strong></th><td>{{ uri }}</td></tr>
<tr><th><strong>{{ "Referer"|t }}</strong></th><td>{{ referer }}</td></tr>
<tr><th><strong>{{ "Referrer"|t }}</strong></th><td>{{ referer }}</td></tr>
<tr><th><strong>{{ "Severity"|t }}</strong></th><td>{{ severity }}</td></tr>
<tr><td colspan="2"><strong>{{ "Message"|t }}:</strong><pre>{{ message }}</pre></td></tr>
</table>',
......
......@@ -11,20 +11,20 @@ interface FilesLogInterface extends LoggerInterface {
*
* @var int
*/
const ITEMS_PER_PAGE = 25;
public const ITEMS_PER_PAGE = 25;
/**
* The directory to put logs in.
*
* @var string
*/
const DIRECTORY = 'private://logs';
public const DIRECTORY = 'private://logs';
/**
* The maximum message length to show in the overview.
*
* @var int
*/
const MAX_MESSAGE_LENGTH = 64;
public const MAX_MESSAGE_LENGTH = 64;
}
......@@ -40,18 +40,21 @@ class FilesLog implements FilesLogInterface {
$message = empty($message_placeholders) ? $message : strtr($message, $message_placeholders);
$channel = $context['channel'];
$entry = json_encode([
'base_url' => $base_url,
'timestamp' => $context['timestamp'],
'type' => $channel,
'ip' => $context['ip'],
'request_uri' => $context['request_uri'],
'referer' => $context['referer'],
'severity' => $level,
'uid' => $context['uid'],
'link' => strip_tags($context['link']),
'message' => strip_tags($message),
], JSON_PRETTY_PRINT);
try {
$entry = json_encode([
'base_url' => $base_url,
'timestamp' => $context['timestamp'],
'type' => $channel,
'ip' => $context['ip'],
'request_uri' => $context['request_uri'],
'referer' => $context['referer'],
'severity' => $level,
'uid' => $context['uid'],
'link' => strip_tags($context['link']),
'message' => strip_tags($message),
], JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);
}
catch (\Exception $e) {}
/**
* @var \Drupal\fileslog\FilesLogManagerInterface $files_log_manager
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment