class CleanerLogger in Cleaner 8
Class CleanerLogger.
@package Drupal\cleaner\Logger
Hierarchy
- class \Drupal\cleaner\Logger\CleanerLogger
Expanded class hierarchy of CleanerLogger
1 string reference to 'CleanerLogger'
1 service uses CleanerLogger
File
- src/
Logger/ CleanerLogger.php, line 12
Namespace
Drupal\cleaner\LoggerView source
class CleanerLogger {
/**
* Log levels array.
*
* @var array
*/
private static $levels = [
LogLevel::EMERGENCY,
LogLevel::ALERT,
LogLevel::CRITICAL,
LogLevel::ERROR,
LogLevel::WARNING,
LogLevel::NOTICE,
LogLevel::INFO,
LogLevel::DEBUG,
];
/**
* Write a log into the database.
*
* @param string $level
* Log level.
* @param string $message
* Log message text.
*/
public static function log($level, $message) {
if (!empty($message) && static::isAvailable($level)) {
\Drupal::logger('cleaner')
->log($level, $message);
}
}
/**
* Check if the specified log level is available.
*
* @param string|null $level
* Log level.
*
* @return bool
* Checking result.
*/
private static function isAvailable($level = NULL) {
return (bool) (!empty($level) && in_array($level, static::$levels));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CleanerLogger:: |
private static | property | Log levels array. | |
CleanerLogger:: |
private static | function | Check if the specified log level is available. | |
CleanerLogger:: |
public static | function | Write a log into the database. |