Пример #1
0
 public function testFallback()
 {
     $fallback = 'I\'ll notify you';
     $attachment = new Attachment($fallback);
     $this->assertTrue(isset($attachment->get()['fallback']));
     $this->assertEquals($fallback, $attachment->get()['fallback']);
     $this->assertContains('"fallback":"' . $fallback . '"', json_encode($attachment));
     $this->setExpectedException('InvalidArgumentException', 'The fallback is required');
     new Attachment('');
 }
 /**
  * TraceAttachment constructor.
  *
  * @param ErrorInterface $error
  * @param StringFormat $formatter
  */
 public function __construct(ErrorInterface $error, StringFormat $formatter)
 {
     parent::__construct('Trace');
     $this->error = $error;
     $this->formatter = $formatter;
     $this->setTitle(new Title('Trace'));
     $this->setText($formatter->arrayToNumberedList(array_map(function ($traceItem) {
         return $this->parseTraceItem($traceItem);
     }, $this->error->getTrace())));
 }
 /**
  * @param ErrorInterface $error
  * @param StringFormat $formatter
  */
 public function __construct(ErrorInterface $error, StringFormat $formatter)
 {
     parent::__construct('Parameters');
     $this->error = $error;
     $this->formatter = $formatter;
     $this->setTitle(new Title('Parameters'));
     foreach ((array) $this->error->getParameters() as $name => $parameter) {
         $this->addField(new Field($name, $this->parseParameter($parameter)));
     }
 }
 /**
  * BasicInfoAttachment constructor.
  *
  * @param array $record
  * @param ErrorInterface $error
  */
 public function __construct(array $record, ErrorInterface $error = null)
 {
     $this->record = $record;
     $this->error = $error;
     $message = $this->error !== null ? $this->error->getMessage() : $this->record['message'];
     parent::__construct($message);
     $this->setColour($this->getColourForLoggerLevel());
     $this->setText(sprintf('*Error:* %s', $this->record['level_name']));
     $this->addField(new Field('What', $message));
     $this->addField(new Field('When', $this->record['datetime']->format('d/m/Y H:i:s'), true));
     $this->addRecordDataAsJsonEncodedField('context', 'Context');
     $this->addRecordDataAsJsonEncodedField('extra', 'Extra');
     if ($this->error !== null) {
         $this->addField(new Field('Line', $this->error->getLine(), true));
         $this->addField(new Field('File', $this->error->getFile()));
     }
 }