Skip to content

Commit 7f224aa

Browse files
committed
[dotnet] Change date format for file log
1 parent ae655ba commit 7f224aa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

dotnet/src/webdriver/Internal/Logging/FileLogHandler.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ public class FileLogHandler : ILogHandler, IDisposable
2020
/// <summary>
2121
/// Initializes a new instance of the <see cref="FileLogHandler"/> class with the specified file path.
2222
/// </summary>
23-
/// <param name="path">The path of the log file.</param>
24-
public FileLogHandler(string path)
23+
/// <param name="filePath">The path of the log file.</param>
24+
public FileLogHandler(string filePath)
2525
{
26-
if (string.IsNullOrEmpty(path)) throw new ArgumentException("File log path cannot be null or empty.", nameof(path));
26+
if (string.IsNullOrEmpty(filePath)) throw new ArgumentException("File log path cannot be null or empty.", nameof(filePath));
2727

28-
var directory = Path.GetDirectoryName(path);
28+
var directory = Path.GetDirectoryName(filePath);
2929
if (!string.IsNullOrWhiteSpace(directory) && !Directory.Exists(directory))
3030
{
3131
Directory.CreateDirectory(directory);
3232
}
3333

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

0 commit comments

Comments
 (0)