Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
LogWriter.LogFile.FileName を **Path** に改名
Browse files Browse the repository at this point in the history
  • Loading branch information
Takym committed Jun 5, 2021
1 parent a4b32c0 commit bc848ce
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Covid19Radar/Covid19Radar/Services/Logs/LogWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void WriteLine(DateTime jstNow, string line)
{
var file = _log_file;
string path = _log_path.LogFilePath(jstNow);
if (file is null || file.FileName != path) {
if (file is null || file.Path != path) {
var newFile = new LogFile(path, _encoding);
do {
if (Interlocked.CompareExchange(ref _log_file, newFile, file) == file) {
Expand All @@ -89,7 +89,7 @@ private void WriteLine(DateTime jstNow, string line)
}
Thread.Yield();
file = _log_file;
} while (file is null || file.FileName != path);
} while (file is null || file.Path != path);
}
file.WriteLine(line);
}
Expand Down Expand Up @@ -165,23 +165,23 @@ private sealed class LogFile : IDisposable
private readonly Encoding _encoding;
private readonly Lazy<StreamWriter> _writer;

internal string FileName { get; }
internal string Path { get; }

internal LogFile(string path, Encoding enc)
{
string dir = Path.GetDirectoryName(path);
string dir = System.IO.Path.GetDirectoryName(path);
if (!Directory.Exists(dir)) {
Directory.CreateDirectory(dir);
}

this.FileName = path;
_encoding = enc;
_writer = new Lazy<StreamWriter>(this.OpenFile, LazyThreadSafetyMode.PublicationOnly);
this.Path = path;
_encoding = enc;
_writer = new Lazy<StreamWriter>(this.OpenFile, LazyThreadSafetyMode.PublicationOnly);
}

private StreamWriter OpenFile()
{
return new StreamWriter(new FileStream(this.FileName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite), _encoding) {
return new StreamWriter(new FileStream(this.Path, FileMode.Append, FileAccess.Write, FileShare.ReadWrite), _encoding) {
AutoFlush = true
};
}
Expand Down

0 comments on commit bc848ce

Please sign in to comment.