Skip to content

Commit

Permalink
Replace markdown with html
Browse files Browse the repository at this point in the history
Markdown formatting was replaced with an HTML one to avoid misformatting caused by stack trace's special characters
  • Loading branch information
Bardin08 committed Nov 5, 2021
1 parent 1067ada commit 0c0a449
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/X.Extensions.Logging.Telegram/TelegramMessageFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public string Format<TState>(
var sb = new StringBuilder();

sb.Append(_options.UseEmoji
? $"{ToEmoji(logLevel)} *{DateTime.Now:HH:mm:ss}* {ToString(logLevel)}"
: $"*{DateTime.Now:HH:mm:ss}* {ToString(logLevel)}");
? $"{ToEmoji(logLevel)} <b>{DateTime.Now:HH:mm:ss}</b> {ToString(logLevel)}"
: $"<b>{DateTime.Now:HH:mm:ss}</b> {ToString(logLevel)}");

sb.AppendLine();
sb.Append($"`{_name}`");
sb.Append($"<pre>{_name}</pre>");

sb.AppendLine();
sb.AppendLine($"Message: {message}");
Expand All @@ -45,14 +45,14 @@ public string Format<TState>(
if (exception != null)
{
sb.AppendLine();
sb.AppendLine($"`{exception}`");
sb.AppendLine($"<pre>{exception}</pre>");
sb.AppendLine();
}

if (!string.IsNullOrWhiteSpace(_options.Source))
{
sb.AppendLine();
sb.Append($"_Source: {_options.Source}_");
sb.Append($"<i>Source: {_options.Source}</i>");
}

sb.AppendLine();
Expand Down
2 changes: 1 addition & 1 deletion src/X.Extensions.Logging.Telegram/TelegramWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public TelegramWriter(string accessToken, string chatId)
}

public async Task Write(string message) =>
await _client.SendTextMessageAsync(_chatId, message, ParseMode.Markdown);
await _client.SendTextMessageAsync(_chatId, message, ParseMode.Html);
}
}

0 comments on commit 0c0a449

Please sign in to comment.