-
-
Notifications
You must be signed in to change notification settings - Fork 978
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor out base TextLogger from StreamLogger (#2406)
* Refactor out base TextWriterLogger from StreamLogger * rename to TextLogger * fix Id * rearrange
- Loading branch information
Showing
2 changed files
with
32 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
using System; | ||
using System.IO; | ||
using System.IO; | ||
using JetBrains.Annotations; | ||
|
||
namespace BenchmarkDotNet.Loggers | ||
{ | ||
public class StreamLogger : ILogger, IDisposable | ||
public class StreamLogger : TextLogger | ||
{ | ||
private readonly StreamWriter writer; | ||
|
||
public StreamLogger(StreamWriter writer) => this.writer = writer; | ||
|
||
public void Dispose() => writer.Dispose(); | ||
public StreamLogger(StreamWriter writer) : base(writer) { } | ||
|
||
[PublicAPI] | ||
public StreamLogger(string filePath, bool append = false) => writer = new StreamWriter(filePath, append); | ||
|
||
public string Id => nameof(StreamLogger); | ||
public int Priority => 0; | ||
public void Write(LogKind logKind, string text) => writer.Write(text); | ||
|
||
public void WriteLine() => writer.WriteLine(); | ||
|
||
public void WriteLine(LogKind logKind, string text) => writer.WriteLine(text); | ||
public StreamLogger(string filePath, bool append = false) | ||
: this(new StreamWriter(filePath, append)) | ||
{ } | ||
|
||
public void Flush() => writer.Flush(); | ||
public override string Id => nameof(StreamLogger); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.IO; | ||
|
||
namespace BenchmarkDotNet.Loggers | ||
{ | ||
public class TextLogger : ILogger, IDisposable | ||
{ | ||
private readonly TextWriter writer; | ||
|
||
public TextLogger(TextWriter writer) => this.writer = writer; | ||
|
||
public virtual string Id => nameof(TextLogger); | ||
public int Priority => 0; | ||
|
||
public void Write(LogKind logKind, string text) => writer.Write(text); | ||
|
||
public void WriteLine() => writer.WriteLine(); | ||
|
||
public void WriteLine(LogKind logKind, string text) => writer.WriteLine(text); | ||
|
||
public void Flush() => writer.Flush(); | ||
|
||
public void Dispose() => writer.Dispose(); | ||
} | ||
} |