47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
abstract class stTaskLogger implements stTaskLoggerInterface
|
|
{
|
|
const TYPE_INFO = 0;
|
|
const TYPE_WARNING = 1;
|
|
const TYPE_ERROR = 2;
|
|
|
|
public function log(int $type, string $message, ?array $messageParams = null): stTaskLoggerInterface
|
|
{
|
|
$this->dispatcher->notify(new sfEvent($this, 'task.logger.log', array(
|
|
'task' => $this->task,
|
|
'type' => $type,
|
|
'message' => $message,
|
|
'message_params' => $messageParams
|
|
)));
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function info(string $message, array $messageParams = null): stTaskLoggerInterface
|
|
{
|
|
return $this->log(self::TYPE_INFO, $message, $messageParams);
|
|
}
|
|
|
|
public function error(string $message, array $messageParams = null): stTaskLoggerInterface
|
|
{
|
|
return $this->log(self::TYPE_ERROR, $message, $messageParams);
|
|
}
|
|
|
|
public function warning(string $message, array $messageParams = null): stTaskLoggerInterface
|
|
{
|
|
return $this->log(self::TYPE_WARNING, $message, $messageParams);
|
|
}
|
|
|
|
public function exception(Throwable $e): stTaskLoggerInterface
|
|
{
|
|
$this->error('%message% w linii %line% w pliku %file%:%trace%', array(
|
|
'%message%' => $e->getMessage(),
|
|
'%line%' => $e->getLine(),
|
|
'%file%' => $e->getFile(),
|
|
"%trace%" => "\n".$e->getTraceAsString(),
|
|
));
|
|
|
|
return $this;
|
|
}
|
|
} |