46 class Logger implements LoggerInterface
71 if (!isset($instance)) {
73 $instance =
new $class();
75 set_error_handler(array($instance,
'handleError'));
77 set_exception_handler(array($instance,
'handleException'));
95 public function handleError($errno, $errstr, $errfile, $errline)
97 if ($this->logging_active && ($errno & error_reporting())) {
102 $msg =
': ' . sprintf(
112 $this->
log(LogLevel::NOTICE,
$msg);
116 $this->
log(LogLevel::NOTICE,
$msg);
128 @$this->
log(LogLevel::CRITICAL,
$msg);
132 $this->
log(LogLevel::ERROR,
$msg);
137 if ($errno == E_USER_ERROR) {
139 if (substr($errstr, 0,
'8') ==
'notrace:') {
141 $errstr = substr($errstr, 8);
145 $trace = debug_backtrace();
147 if (
'cli' == php_sapi_name()) {
148 foreach ($trace as $step) {
149 if (isset($step[
'file'])) {
150 fprintf(STDERR,
"%s (%d)\n", $this->
sanitizePath($step[
'file']), $step[
'line']);
155 foreach ($trace as $step) {
156 if (isset($step[
'file'])) {
157 printf(
"%s (%d)\n<br />", $this->
sanitizePath($step[
'file']), $step[
'line']);
178 $msg = $e->__toString();
185 if (
'cli' == php_sapi_name()) {
186 fprintf(STDERR,
"\nError : %s\n",
$msg);
190 @$this->
log(LogLevel::CRITICAL,
$msg);
236 if (is_object($logger) && method_exists($logger,
'log')) {
237 $this->loggers[] = $logger;
238 $this->logging_active =
true;
250 public function emergency($message, array $context = array())
252 $this->
log(LogLevel::EMERGENCY, $message, $context);
266 public function alert($message, array $context = array())
268 $this->
log(LogLevel::ALERT, $message, $context);
281 public function critical($message, array $context = array())
283 $this->
log(LogLevel::CRITICAL, $message, $context);
295 public function error($message, array $context = array())
297 $this->
log(LogLevel::ERROR, $message, $context);
311 public function warning($message, array $context = array())
324 public function notice($message, array $context = array())
326 $this->
log(LogLevel::NOTICE, $message, $context);
339 public function info($message, array $context = array())
341 $this->
log(LogLevel::INFO, $message, $context);
352 public function debug($message, array $context = array())
354 $this->
log(LogLevel::DEBUG, $message, $context);
366 public function log($level, $message, array $context = array())
368 if (!empty($this->loggers)) {
369 foreach ($this->loggers as $logger) {
370 if (is_object($logger)) {
372 $logger->log($level, $message, $context);
373 }
catch (\Exception $e) {
393 if (!empty($this->loggers)) {
394 foreach ($this->loggers as $logger) {
395 if (is_object($logger) && method_exists($logger,
'quiet')) {
398 }
catch (\Exception $e) {
422 if (
$var==
'activated' && !$val) {
465 $xoops->deprecated(
'This use of XoopsLogger is deprecated since 2.6.0.');
log($level, $message, array $context=array())
emergency($message, array $context=array())
warning($message, array $context=array())
handleError($errno, $errstr, $errfile, $errline)
error($message, array $context=array())
const _XOOPS_FATAL_BACKTRACE
debug($message, array $context=array())
alert($message, array $context=array())
if(!is_object($module)||!$module->getVar('isactive')) $msg
info($message, array $context=array())
const _XOOPS_FATAL_MESSAGE
notice($message, array $context=array())
critical($message, array $context=array())