-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFileReporter.cs
More file actions
27 lines (22 loc) · 799 Bytes
/
Copy pathFileReporter.cs
File metadata and controls
27 lines (22 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
namespace SCAScanner;
/// <summary>
/// File-based reporter. Writes plain text (no colors) to a file.
/// Always uses Detailed output level so log files are always complete.
/// </summary>
public sealed class FileReporter : BaseReporter, IDisposable
{
private readonly StreamWriter _writer;
public FileReporter(string filePath) : base(OutputLevel.Detailed)
{
_writer = new StreamWriter(filePath, append: false, encoding: System.Text.Encoding.UTF8);
}
protected override void Write(string text, ConsoleColor? color = null)
=> _writer.Write(text);
protected override void WriteLine(string text = "", ConsoleColor? color = null)
=> _writer.WriteLine(text);
public void Dispose()
{
_writer.Flush();
_writer.Dispose();
}
}