Source of file Logger.php
Size: 3,521 Bytes - Last Modified: 2021-12-23T10:20:55+00:00
/var/www/docs.ssmods.com/process/src/thirdparty/css-crush/lib/CssCrush/Logger.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 | <?php /** * * PSR-3 compatible logger. * */ namespace CssCrush; class Logger { /** * System is unusable. * * @param string $message * @param array $context * @return null */ public function emergency($message, array $context = array()) { $this->error($message, $context); } /** * Action must be taken immediately. * * Example: Entire website down, database unavailable, etc. This should * trigger the SMS alerts and wake you up. * * @param string $message * @param array $context * @return null */ public function alert($message, array $context = array()) { $this->error($message, $context); } /** * Critical conditions. * * Example: Application component unavailable, unexpected exception. * * @param string $message * @param array $context * @return null */ public function critical($message, array $context = array()) { $this->error($message, $context); } /** * Runtime errors that do not require immediate action but should typically * be logged and monitored. * * @param string $message * @param array $context * @return null */ public function error($message, array $context = array()) { trigger_error($message, E_USER_ERROR); } /** * Exceptional occurrences that are not errors. * * Example: Use of deprecated APIs, poor use of an API, undesirable things * that are not necessarily wrong. * * @param string $message * @param array $context * @return null */ public function warning($message, array $context = array()) { trigger_error($message, E_USER_WARNING); } /** * Normal but significant events. * * @param string $message * @param array $context * @return null */ public function notice($message, array $context = array()) { trigger_error($message, E_USER_NOTICE); } /** * Interesting events. * * Example: User logs in, SQL logs. * * @param string $message * @param array $context * @return null */ public function info($message, array $context = array()) { $this->debug($message, $context); } /** * Detailed debug information. * * @param string $message * @param array $context * @return null */ public function debug($message, array $context = array()) { if (! empty($context['label'])) { $label = PHP_EOL . "$label" . PHP_EOL . str_repeat('=', strlen($label)) . PHP_EOL; } else { $label = ''; } if (is_string($message)) { Crush::$process->debugLog[] = "$label$message"; } else { ob_start(); ! empty($context['var_dump']) ? var_dump($message) : print_r($message); Crush::$process->debugLog[] = $label . ob_get_clean(); } } /** * Logs with an arbitrary level. * * @param mixed $level * @param string $message * @param array $context * @return null */ public function log($level, $message, array $context = array()) { $log_levels = array_flip(get_class_methods(__CLASS__)); unset($log_levels['log']); if (isset($log_levels[$level])) { return $this->$level($message, $context); } } } |