Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid string.Concat(params string[]) in SimpleConsoleFormatter.CreateDefaultLogMessage #44765

Merged
merged 1 commit into from
Nov 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;

Expand Down Expand Up @@ -78,7 +74,19 @@ private void CreateDefaultLogMessage<TState>(TextWriter textWriter, in LogEntry<
// Request received

// category and event id
textWriter.Write(LoglevelPadding + logEntry.Category + '[' + eventId + "]");
textWriter.Write(LoglevelPadding);
textWriter.Write(logEntry.Category);
textWriter.Write('[');

#if NETCOREAPP
Span<char> span = stackalloc char[10];
if (eventId.TryFormat(span, out int charsWritten))
textWriter.Write(span.Slice(0, charsWritten));
else
#endif
textWriter.Write(eventId.ToString());

textWriter.Write(']');
if (!singleLine)
{
textWriter.Write(Environment.NewLine);
Expand Down Expand Up @@ -177,7 +185,8 @@ private void WriteScopeInformation(TextWriter textWriter, IExternalScopeProvider
if (paddingNeeded)
{
paddingNeeded = false;
state.Write(_messagePadding + "=> ");
state.Write(_messagePadding);
state.Write("=> ");
}
else
{
Expand Down