Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix comments and names
  • Loading branch information
RomanSoloweow committed Jul 20, 2024
commit 8688757f01f93bc2a86710b19835a97efc08e9de
2 changes: 1 addition & 1 deletion src/NLog/Internal/Strings/StringBuilderExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public static void ClearBuilder(this StringBuilder builder)
/// Copies the contents of the StringBuilder to the MemoryStream using the specified encoding (Without BOM/Preamble)
/// </summary>
/// <param name="builder">StringBuilder source</param>
/// <param name="targetStream">MemoryStream destination</param>
/// <param name="targetStream">Stream destination</param>
/// <param name="encoding">Encoding used for converter string into byte-stream</param>
/// <param name="transformBuffer">Helper char-buffer to minimize memory allocations</param>
public static void CopyToStream(this StringBuilder builder, Stream targetStream, Encoding encoding, char[] transformBuffer)
Expand Down
16 changes: 8 additions & 8 deletions src/NLog/Targets/FileTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1062,8 +1062,8 @@ protected override void Write(IList<AsyncLogEventInfo> logEvents)
int currentIndex = 0;
while (currentIndex < bucketCount)
{
var written = WriteToMemoryStream(bucket.Value, currentIndex, reusableStream);
AppendMemoryStreamToFile(fileName, bucket.Value[currentIndex].LogEvent, reusableStream, out var lastException);
var written = WriteToStream(bucket.Value, currentIndex, reusableStream);
AppendStreamToFile(fileName, bucket.Value[currentIndex].LogEvent, reusableStream, out var lastException);
for (int i = 0; i < written; ++i)
{
bucket.Value[currentIndex++].Continuation(lastException);
Expand All @@ -1073,7 +1073,7 @@ protected override void Write(IList<AsyncLogEventInfo> logEvents)
}
}

private int WriteToMemoryStream(IList<AsyncLogEventInfo> logEvents, int startIndex, Stream targetStream)
private int WriteToStream(IList<AsyncLogEventInfo> logEvents, int startIndex, Stream targetStream)
{
long maxBufferSize = BufferSize * 100; // Max Buffer Default = 30 KiloByte * 100 = 3 MegaByte

Expand Down Expand Up @@ -1173,7 +1173,7 @@ protected virtual byte[] TransformBytes(byte[] value)
/// <param name="logEvent">The log event to be formatted.</param>
/// <param name="formatBuilder"><see cref="StringBuilder"/> to help format log event.</param>
/// <param name="transformBuffer">Optional temporary char-array to help format log event.</param>
/// <param name="streamTarget">Destination <see cref="BufferPoolStream"/> for the encoded result.</param>
/// <param name="streamTarget">Destination <see cref="Stream"/> for the encoded result.</param>
protected virtual void RenderFormattedMessageToStream(LogEventInfo logEvent, StringBuilder formatBuilder, char[] transformBuffer, Stream streamTarget)
{
RenderFormattedMessage(logEvent, formatBuilder);
Expand Down Expand Up @@ -1206,7 +1206,7 @@ protected virtual void TransformStream(LogEventInfo logEvent, Stream stream)
{
}

private void AppendMemoryStreamToFile(string currentFileName, LogEventInfo firstLogEvent, Stream sourceStream, out Exception lastException)
private void AppendStreamToFile(string currentFileName, LogEventInfo firstLogEvent, Stream sourceStream, out Exception lastException)
{
try
{
Expand Down Expand Up @@ -2212,7 +2212,7 @@ private void ConditionalFlushOpenFileAppenders()
/// <see cref="FileTarget"/> instance and writes them.
/// </summary>
/// <param name="fileName">File name to be written.</param>
/// <param name="sourceStream">Raw sequence of <see langword="byte"/> to be written into the content part of the file.</param>
/// <param name="sourceStream">Stream <see langword="Stream"/> to be written into the content part of the file.</param>
/// <param name="initializedNewFile">File has just been opened.</param>
private void WriteToFile(string fileName, Stream sourceStream, bool initializedNewFile)
{
Expand Down Expand Up @@ -2435,7 +2435,7 @@ private void PrepareForNewFile(string fileName, LogEventInfo logEvent)
/// Header, Content and Footer.
/// </summary>
/// <param name="fileName">The name of the file to be written.</param>
/// <param name="sourceStream">Sequence of <see langword="byte"/> to be written in the content section of the file.</param>
/// <param name="sourceStream">Stream <see langword="Stream"/> to be written in the content section of the file.</param>
/// <param name="firstAttempt">First attempt to write?</param>
/// <remarks>This method is used when the content of the log file is re-written on every write.</remarks>
private void ReplaceFileContent(string fileName, Stream sourceStream, bool firstAttempt)
Expand Down Expand Up @@ -2513,7 +2513,7 @@ private void WriteHeaderAndBom(BaseFileAppender appender)
/// transformations required from the <see cref="Layout"/>.
/// </summary>
/// <param name="layout">The layout used to render output message.</param>
/// <param name="targetStream"></param>
/// <param name="targetStream">Stream <see langword="Stream"/> to write layout</param>
/// <remarks>Usually it is used to render the header and hooter of the files.</remarks>
private void WriteLayout(Layout layout, Stream targetStream)
{
Expand Down