Skip to content

Commit 847cee8

Browse files
committed
Addressing PR comments
1 parent d516abe commit 847cee8

File tree

3 files changed

+8
-22
lines changed

3 files changed

+8
-22
lines changed

dotnet/src/webdriver/DriverService.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,6 @@ public int ProcessId
154154
/// </summary>
155155
public string? DriverServicePath { get; set; }
156156

157-
/// <summary>
158-
/// Collects the driver log output and writes it to the console. Defaults to <see langword="true"/>.
159-
/// Internal variable to avoid using the stream when logs are sent to a file.
160-
/// </summary>
161-
protected bool WriteDriverLogToConsole { get; set; } = true;
162-
163157
/// <summary>
164158
/// Gets the command-line arguments for the driver service.
165159
/// </summary>
@@ -255,8 +249,8 @@ public void Start()
255249
this.driverServiceProcess.StartInfo.RedirectStandardOutput = true;
256250
this.driverServiceProcess.StartInfo.RedirectStandardError = true;
257251

258-
this.driverServiceProcess.OutputDataReceived += (s, e) => this.OnDriverProcessDataReceived(s, e, isError: false);
259-
this.driverServiceProcess.ErrorDataReceived += (s, e) => this.OnDriverProcessDataReceived(s, e, isError: true);
252+
this.driverServiceProcess.OutputDataReceived += this.OnDriverProcessDataReceived;
253+
this.driverServiceProcess.ErrorDataReceived += this.OnDriverProcessDataReceived;
260254

261255
DriverProcessStartingEventArgs eventArgs = new DriverProcessStartingEventArgs(this.driverServiceProcess.StartInfo);
262256
this.OnDriverProcessStarting(eventArgs);
@@ -332,18 +326,14 @@ protected virtual void OnDriverProcessStarted(DriverProcessStartedEventArgs even
332326
/// <param name="sender">The sender of the event.</param>
333327
/// <param name="args">The data received event arguments.</param>
334328
/// <param name="isError">A value indicating whether the data received is from the error stream.</param>
335-
protected virtual void OnDriverProcessDataReceived(object sender, DataReceivedEventArgs args, bool isError)
329+
protected virtual void OnDriverProcessDataReceived(object sender, DataReceivedEventArgs args)
336330
{
337331
if (string.IsNullOrEmpty(args.Data))
338332
return;
339333

340-
if (this.WriteDriverLogToConsole && !isError && _logger.IsEnabled(LogEventLevel.Info))
341-
{
342-
_logger.Info(args.Data);
343-
}
344-
if (this.WriteDriverLogToConsole && isError && _logger.IsEnabled(LogEventLevel.Error))
334+
if (_logger.IsEnabled(LogEventLevel.Trace))
345335
{
346-
_logger.Error(args.Data);
336+
_logger.Trace(args.Data);
347337
}
348338
}
349339

dotnet/src/webdriver/Firefox/FirefoxDriverService.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
using System.Globalization;
2424
using System.IO;
2525
using System.Text;
26-
using OpenQA.Selenium.Internal.Logging;
2726

2827
namespace OpenQA.Selenium.Firefox;
2928

@@ -33,7 +32,6 @@ namespace OpenQA.Selenium.Firefox;
3332
public sealed class FirefoxDriverService : DriverService
3433
{
3534
private const string DefaultFirefoxDriverServiceFileName = "geckodriver";
36-
private static readonly ILogger _logger = Log.GetLogger(typeof(FirefoxDriverService));
3735

3836
/// <summary>
3937
/// Process management fields for the log writer.
@@ -235,7 +233,6 @@ protected override void OnDriverProcessStarting(DriverProcessStartingEventArgs e
235233
{
236234
if (!string.IsNullOrEmpty(this.LogPath))
237235
{
238-
this.WriteDriverLogToConsole = false;
239236
string? directory = Path.GetDirectoryName(this.LogPath);
240237
if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
241238
{
@@ -254,7 +251,7 @@ protected override void OnDriverProcessStarting(DriverProcessStartingEventArgs e
254251
/// <param name="sender">The sender of the event.</param>
255252
/// <param name="args">The data received event arguments.</param>
256253
/// <param name="isError">A value indicating whether the data received is from the error stream.</param>
257-
protected override void OnDriverProcessDataReceived(object sender, DataReceivedEventArgs args, bool isError)
254+
protected override void OnDriverProcessDataReceived(object sender, DataReceivedEventArgs args)
258255
{
259256
if (string.IsNullOrEmpty(args.Data))
260257
return;
@@ -264,12 +261,11 @@ protected override void OnDriverProcessDataReceived(object sender, DataReceivedE
264261
if (logWriter != null)
265262
{
266263
logWriter.WriteLine(args.Data);
267-
logWriter.Flush();
268264
}
269265
}
270266
else
271267
{
272-
base.OnDriverProcessDataReceived(sender, args, isError);
268+
base.OnDriverProcessDataReceived(sender, args);
273269
}
274270
}
275271

dotnet/test/firefox/FirefoxDriverServiceTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void ShouldRedirectGeckoDriverLogsToFile()
7979
[Test]
8080
public void ShouldRedirectGeckoDriverLogsToConsole()
8181
{
82-
Log.SetLevel(LogEventLevel.Info).Handlers.Add(testLogHandler);
82+
Log.SetLevel(LogEventLevel.Trace).Handlers.Add(testLogHandler);
8383
FirefoxOptions options = new FirefoxOptions();
8484
options.LogLevel = FirefoxDriverLogLevel.Info;
8585

0 commit comments

Comments
 (0)