Skip to content

Commit

Permalink
Add watchdog() function (#91)
Browse files Browse the repository at this point in the history
Co-authored-by: Matt Glaman <[email protected]>
  • Loading branch information
darrenoh and mglaman authored Nov 8, 2023
1 parent aacc3a5 commit 2930956
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/constants/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

declare(strict_types=1);

use Drupal\Core\Logger\RfcLogLevel;

const CHECK_PLAIN = 0;

const PASS_THROUGH = -1;

const WATCHDOG_EMERGENCY = RfcLogLevel::EMERGENCY;

const WATCHDOG_ALERT = RfcLogLevel::ALERT;

const WATCHDOG_CRITICAL = RfcLogLevel::CRITICAL;

const WATCHDOG_ERROR = RfcLogLevel::ERROR;

const WATCHDOG_WARNING = RfcLogLevel::WARNING;

const WATCHDOG_NOTICE = RfcLogLevel::NOTICE;

const WATCHDOG_INFO = RfcLogLevel::INFO;

const WATCHDOG_DEBUG = RfcLogLevel::DEBUG;
14 changes: 14 additions & 0 deletions src/functions/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,17 @@ function drupal_get_title(): array|string|\Stringable|null

return $titleResolver->getTitle(\Drupal::request(), $route);
}

/**
* @param mixed[] $variables
*/
function watchdog(
string $type,
string|\Stringable $message,
array $variables = [],
int $severity = WATCHDOG_NOTICE,
?string $link = null
): void {
$variables['link'] = $link ?? '';
\Drupal::logger($type)->log($severity, $message, $variables);
}

0 comments on commit 2930956

Please sign in to comment.