-
Notifications
You must be signed in to change notification settings - Fork 120
Convert RulesLog to a logging service, first version. Issue #2404089 #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| rules_log_errors: warning | ||
| rules_debug_log: false | ||
| rules_debug: false | ||
| rules_log_level: info |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Implements hook_theme(). | ||
| */ | ||
| function rules_theme() { | ||
| return array( | ||
| 'rules_debug_element' => [ | ||
| 'template' => 'rules_debug_element', | ||
| 'variables' => [ | ||
| 'head' => NULL, | ||
| 'link' => NULL, | ||
| 'log' => NULL, | ||
| ] | ||
| ], | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <?php | ||
|
|
||
| namespace Drupal\rules\Engine; | ||
|
|
||
| use Psr\Log\LogLevel; | ||
|
|
||
| /** | ||
| * Interface RulesLogInterface | ||
| */ | ||
| interface RulesLogInterface { | ||
|
|
||
| /** | ||
| * Logs a log message. | ||
| * | ||
| * @param $msg | ||
| * @param array $args | ||
| * @param string $logLevel | ||
| * @param null $scope | ||
| * @param null $path | ||
| * | ||
| * @see rules_log() | ||
| */ | ||
| public function log($msg, $args = [], $logLevel = LogLevel::INFO, $scope = NULL, $path = NULL); | ||
|
|
||
| /** | ||
| * Checks the log and throws an exception if there were any problems. | ||
| * | ||
| * @param string $logLevel | ||
| * | ||
| * @throws \Exception | ||
| */ | ||
| public function checkLog($logLevel = LogLevel::WARNING); | ||
|
|
||
| /** | ||
| * Checks the log for (error) messages with a log level equal | ||
| * or higher than the given one. | ||
| * | ||
| * @param string $logLevel | ||
| * | ||
| * @return bool | ||
| * Whether the an error has been logged. | ||
| */ | ||
| public function hasErrors($logLevel = LogLevel::WARNING); | ||
|
|
||
| /** | ||
| * Gets an array of logged messages. | ||
| */ | ||
| public function get(); | ||
|
|
||
| /** | ||
| * Renders the whole log. | ||
| */ | ||
| public function render(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should remove the render() part. The rules logger should simply extend AbstractLogger. Rendering should not be part of it but rather be outsourced into a separate service which can then be invoked from a specific controller which shows all log entries on a distinct page and can also be used to render the current rule log for the active request somewhere on the page. |
||
|
|
||
| /** | ||
| * Clears the logged messages. | ||
| */ | ||
| public function clear(); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RulesLog should extend AbstractLogger, no?