Fixes log plugin

main
Yasen Pramatarov 2025-04-27 15:43:45 +03:00
parent fa3e75f722
commit f84a337607
2 changed files with 17 additions and 2 deletions

View File

@ -16,4 +16,12 @@ class NullLogger
* @return void
*/
public function insertLog($userId, string $message, ?string $type = null): void {}
/**
* PSR-3 log stub.
* @param string $level
* @param string $message
* @param array $context
*/
public function log(string $level, string $message, array $context = []): void {}
}

View File

@ -119,4 +119,11 @@ class Log {
return $query->fetchAll(PDO::FETCH_ASSOC);
}
// PSR-3 style log method
public function log(string $level, string $message, array $context = []): void {
$userId = $context['user_id'] ?? null;
$scope = $context['scope'] ?? 'system';
$this->insertLog($userId, "[$level] " . $message, $scope);
}
}