Ver código fonte

Merge branch '1.x'

Jordi Boggiano 7 anos atrás
pai
commit
9a2c747a0a

+ 2 - 2
src/Monolog/Handler/Slack/SlackRecord.php

@@ -229,7 +229,7 @@ class SlackRecord
      * Generates attachment field
      * Generates attachment field
      *
      *
      * @param string       $title
      * @param string       $title
-     * @param string|array $value\
+     * @param string|array $value
      *
      *
      * @return array
      * @return array
      */
      */
@@ -256,7 +256,7 @@ class SlackRecord
     private function generateAttachmentFields(array $data)
     private function generateAttachmentFields(array $data)
     {
     {
         $fields = array();
         $fields = array();
-        foreach ($data as $key => $value) {
+        foreach ($this->normalizerFormatter->format($data) as $key => $value) {
             $fields[] = $this->generateAttachmentField($key, $value);
             $fields[] = $this->generateAttachmentField($key, $value);
         }
         }
 
 

+ 5 - 0
src/Monolog/Handler/SlackHandler.php

@@ -75,6 +75,11 @@ class SlackHandler extends SocketHandler
         return $this->slackRecord;
         return $this->slackRecord;
     }
     }
 
 
+    public function getToken()
+    {
+        return $this->token;
+    }
+
     /**
     /**
      * {@inheritdoc}
      * {@inheritdoc}
      *
      *

+ 8 - 0
tests/Monolog/Handler/Slack/SlackRecordTest.php

@@ -357,6 +357,14 @@ class SlackRecordTest extends TestCase
         $this->assertSame($record['datetime']->getTimestamp(), $attachment['ts']);
         $this->assertSame($record['datetime']->getTimestamp(), $attachment['ts']);
     }
     }
 
 
+    public function testContextHasException()
+    {
+        $record = $this->getRecord(Logger::CRITICAL, 'This is a critical message.', array('exception' => new \Exception()));
+        $slackRecord = new SlackRecord(null, null, true, null, false, true);
+        $data = $slackRecord->getSlackData($record);
+        $this->assertInternalType('string', $data['attachments'][0]['fields'][1]['value']);
+    }
+
     public function testExcludeExtraAndContextFields()
     public function testExcludeExtraAndContextFields()
     {
     {
         $record = $this->getRecord(
         $record = $this->getRecord(