@@ -33,20 +33,30 @@ class TelegramFormatter implements FormatterInterface
33
33
*/
34
34
private $ separator ;
35
35
36
+ /**
37
+ * @var string
38
+ */
39
+ private $ tags ;
40
+
36
41
/**
37
42
* Formatter constructor
38
43
*
39
44
* @param bool $html Format as HTML or not
40
45
* @param string $format The format of the message
41
46
* @param string $dateFormat The format of the timestamp: one supported by DateTime::format
42
47
* @param string $separator Record separator used when sending batch of logs in one message
48
+ * @param string $tags Tags to be added to the message
43
49
*/
44
- public function __construct ($ html = true , $ format = null , $ dateFormat = null , $ separator = '- ' )
50
+ public function __construct ($ html = true , $ format = null , $ dateFormat = null , $ separator = '- ' , $ tags = '' )
45
51
{
46
52
$ this ->html = $ html ;
47
53
$ this ->format = $ format ?: self ::MESSAGE_FORMAT ;
48
54
$ this ->dateFormat = $ dateFormat ?: self ::DATE_FORMAT ;
49
55
$ this ->separator = $ separator ;
56
+ if (is_null ($ tags )) {
57
+ $ tags = '' ;
58
+ }
59
+ $ this ->tags = explode (', ' , $ tags );
50
60
}
51
61
52
62
/**
@@ -104,6 +114,7 @@ private function getMessageForException($exception)
104
114
. '<b>Message:</b> ' . $ exception ->getMessage () . PHP_EOL
105
115
. '<b>Exception:</b> ' . get_class ($ exception ) . PHP_EOL
106
116
. '<b>Code:</b> ' . $ code . PHP_EOL
117
+ . '<b>Tags:</b> ' . $ this ->getTags () . PHP_EOL
107
118
. '<b>File:</b> ' . $ exception ->getFile () . PHP_EOL
108
119
. '<b>Line:</b> ' . $ exception ->getLine () . PHP_EOL
109
120
. '<b>Url:</b> ' . urldecode ($ request ->url ()) . PHP_EOL
@@ -140,6 +151,18 @@ private function getMessageForException($exception)
140
151
return $ message ;
141
152
}
142
153
154
+ private function getTags ()
155
+ {
156
+ $ message = '' ;
157
+ foreach ($ this ->tags as $ tag ) {
158
+ if (!empty ($ tag )) {
159
+ $ message .= '# ' . $ tag . ' ' ;
160
+ }
161
+ }
162
+
163
+ return $ message ;
164
+ }
165
+
143
166
private function getMessageForLog ($ record )
144
167
{
145
168
$ message = $ this ->format ;
0 commit comments