Skip to content

Commit

Permalink
[dotnet] Change date format for file log
Browse files Browse the repository at this point in the history
  • Loading branch information
nvborisenko committed Dec 8, 2023
1 parent ae655ba commit 7f224aa
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions dotnet/src/webdriver/Internal/Logging/FileLogHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ public class FileLogHandler : ILogHandler, IDisposable
/// <summary>
/// Initializes a new instance of the <see cref="FileLogHandler"/> class with the specified file path.
/// </summary>
/// <param name="path">The path of the log file.</param>
public FileLogHandler(string path)
/// <param name="filePath">The path of the log file.</param>
public FileLogHandler(string filePath)
{
if (string.IsNullOrEmpty(path)) throw new ArgumentException("File log path cannot be null or empty.", nameof(path));
if (string.IsNullOrEmpty(filePath)) throw new ArgumentException("File log path cannot be null or empty.", nameof(filePath));

var directory = Path.GetDirectoryName(path);
var directory = Path.GetDirectoryName(filePath);
if (!string.IsNullOrWhiteSpace(directory) && !Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}

_fileStream = File.Open(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
_fileStream = File.Open(filePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read);
_fileStream.Seek(0, SeekOrigin.End);
_streamWriter = new StreamWriter(_fileStream, System.Text.Encoding.UTF8)
{
Expand All @@ -47,7 +47,7 @@ public void Handle(LogEvent logEvent)
{
lock (_lockObj)
{
_streamWriter.WriteLine($"{logEvent.Timestamp:r} {_levels[(int)logEvent.Level]} {logEvent.IssuedBy.Name}: {logEvent.Message}");
_streamWriter.WriteLine($"{logEvent.Timestamp:yyyy-MM-dd HH:mm:ss.fff} {_levels[(int)logEvent.Level]} {logEvent.IssuedBy.Name}: {logEvent.Message}");
}
}

Expand Down

0 comments on commit 7f224aa

Please sign in to comment.