Skip to content

Commit fffd05c

Browse files
committed
[dotnet] Don't output to user's console, rather use logging
Fixes #13410
1 parent 9bcccf2 commit fffd05c

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

dotnet/src/webdriver/DriverService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using System.Net;
2424
using System.Net.Http;
2525
using System.Threading.Tasks;
26+
using OpenQA.Selenium.Internal.Logging;
2627
using OpenQA.Selenium.Remote;
2728

2829
namespace OpenQA.Selenium
@@ -41,6 +42,7 @@ public abstract class DriverService : ICommandServer
4142
private bool isDisposed;
4243
private Process driverServiceProcess;
4344
private TimeSpan initializationTimeout = TimeSpan.FromSeconds(20);
45+
private readonly static ILogger logger = Log.GetLogger<DriverService>();
4446

4547
/// <summary>
4648
/// Initializes a new instance of the <see cref="DriverService"/> class.
@@ -216,6 +218,7 @@ protected virtual bool IsInitialized
216218
get
217219
{
218220
bool isInitialized = false;
221+
219222
try
220223
{
221224
using (var httpClient = new HttpClient())
@@ -236,7 +239,7 @@ protected virtual bool IsInitialized
236239
}
237240
catch (Exception ex) when (ex is HttpRequestException || ex is TaskCanceledException)
238241
{
239-
Console.WriteLine(ex.Message);
242+
logger.Trace(ex.ToString());
240243
}
241244

242245
return isInitialized;

dotnet/src/webdriver/Internal/FileUtilities.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// limitations under the License.
1717
// </copyright>
1818

19+
using OpenQA.Selenium.Internal.Logging;
1920
using System;
2021
using System.Globalization;
2122
using System.IO;
@@ -28,6 +29,8 @@ namespace OpenQA.Selenium.Internal
2829
/// </summary>
2930
internal static class FileUtilities
3031
{
32+
private static readonly ILogger logger = Log.GetLogger(typeof(FileUtilities));
33+
3134
/// <summary>
3235
/// Recursively copies a directory.
3336
/// </summary>
@@ -99,7 +102,7 @@ public static void DeleteDirectory(string directoryToDelete)
99102

100103
if (Directory.Exists(directoryToDelete))
101104
{
102-
Console.WriteLine("Unable to delete directory '{0}'", directoryToDelete);
105+
logger.Trace($"Unable to delete directory '{directoryToDelete}'");
103106
}
104107
}
105108

dotnet/src/webdriver/Safari/SafariDriverService.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using System.Text;
2424
using System.Threading.Tasks;
2525
using OpenQA.Selenium.Internal;
26+
using OpenQA.Selenium.Internal.Logging;
2627

2728
namespace OpenQA.Selenium.Safari
2829
{
@@ -35,6 +36,8 @@ public sealed class SafariDriverService : DriverService
3536

3637
private bool useLegacyProtocol;
3738

39+
private readonly static ILogger logger = Log.GetLogger<SafariDriverService>();
40+
3841
/// <summary>
3942
/// Initializes a new instance of the <see cref="SafariDriverService"/> class.
4043
/// </summary>
@@ -150,7 +153,7 @@ protected override bool IsInitialized
150153
// check.
151154
catch (Exception ex) when (ex is HttpRequestException || ex is TaskCanceledException)
152155
{
153-
Console.WriteLine(ex);
156+
logger.Trace(ex.ToString());
154157
}
155158
}
156159
}

0 commit comments

Comments
 (0)