@@ -33,20 +33,30 @@ class TelegramFormatter implements FormatterInterface
3333 */
3434 private $ separator ;
3535
36+ /**
37+ * @var string
38+ */
39+ private $ tags ;
40+
3641 /**
3742 * Formatter constructor
3843 *
3944 * @param bool $html Format as HTML or not
4045 * @param string $format The format of the message
4146 * @param string $dateFormat The format of the timestamp: one supported by DateTime::format
4247 * @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
4349 */
44- public function __construct ($ html = true , $ format = null , $ dateFormat = null , $ separator = '- ' )
50+ public function __construct ($ html = true , $ format = null , $ dateFormat = null , $ separator = '- ' , $ tags = '' )
4551 {
4652 $ this ->html = $ html ;
4753 $ this ->format = $ format ?: self ::MESSAGE_FORMAT ;
4854 $ this ->dateFormat = $ dateFormat ?: self ::DATE_FORMAT ;
4955 $ this ->separator = $ separator ;
56+ if (is_null ($ tags )) {
57+ $ tags = '' ;
58+ }
59+ $ this ->tags = explode (', ' , $ tags );
5060 }
5161
5262 /**
@@ -104,6 +114,7 @@ private function getMessageForException($exception)
104114 . '<b>Message:</b> ' . $ exception ->getMessage () . PHP_EOL
105115 . '<b>Exception:</b> ' . get_class ($ exception ) . PHP_EOL
106116 . '<b>Code:</b> ' . $ code . PHP_EOL
117+ . '<b>Tags:</b> ' . $ this ->getTags () . PHP_EOL
107118 . '<b>File:</b> ' . $ exception ->getFile () . PHP_EOL
108119 . '<b>Line:</b> ' . $ exception ->getLine () . PHP_EOL
109120 . '<b>Url:</b> ' . urldecode ($ request ->url ()) . PHP_EOL
@@ -140,6 +151,18 @@ private function getMessageForException($exception)
140151 return $ message ;
141152 }
142153
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+
143166 private function getMessageForLog ($ record )
144167 {
145168 $ message = $ this ->format ;
0 commit comments