Skip to content

Commit a874c10

Browse files
committed
improve logger usage in laravel for html content
1 parent acd9087 commit a874c10

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/TelegramFormatter.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,14 @@ private function getMessageForLog($record)
145145
$message = $this->format;
146146
$lineFormatter = new LineFormatter();
147147

148-
$record['message'] = preg_replace('/<([^<]+)>/', '&lt;$1&gt;', $record['message']); // Replace '<' and '>' with their special codes
149-
$record['message'] = preg_replace('/^Stack trace:\n((^#\d.*\n?)*)$/m', "\n<b>Stack trace:</b>\n<code>$1</code>", $record['message']); // Put the stack trace inside <code></code> tags
148+
if (strpos($record['message'], 'Stack trace') !== false) {
149+
// Replace '<' and '>' with their special codes
150+
$record['message'] = preg_replace('/<([^<]+)>/', '&lt;$1&gt;', $record['message']);
151+
152+
// Put the stack trace inside <code></code> tags
153+
$record['message'] = preg_replace('/^Stack trace:\n((^#\d.*\n?)*)$/m', "\n<b>Stack trace:</b>\n<code>$1</code>", $record['message']);
154+
}
155+
150156
$message = str_replace('%message%', $record['message'], $message);
151157

152158
if ($record['context']) {

0 commit comments

Comments
 (0)