Skip to content

Commit

Permalink
[dotnet] Don't output to user's console, rather use logging
Browse files Browse the repository at this point in the history
Fixes #13410
  • Loading branch information
nvborisenko committed Jan 8, 2024
1 parent 9bcccf2 commit fffd05c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion dotnet/src/webdriver/DriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using OpenQA.Selenium.Internal.Logging;
using OpenQA.Selenium.Remote;

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

/// <summary>
/// Initializes a new instance of the <see cref="DriverService"/> class.
Expand Down Expand Up @@ -216,6 +218,7 @@ protected virtual bool IsInitialized
get
{
bool isInitialized = false;

try
{
using (var httpClient = new HttpClient())
Expand All @@ -236,7 +239,7 @@ protected virtual bool IsInitialized
}
catch (Exception ex) when (ex is HttpRequestException || ex is TaskCanceledException)
{
Console.WriteLine(ex.Message);
logger.Trace(ex.ToString());
}

return isInitialized;
Expand Down
5 changes: 4 additions & 1 deletion dotnet/src/webdriver/Internal/FileUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// limitations under the License.
// </copyright>

using OpenQA.Selenium.Internal.Logging;
using System;
using System.Globalization;
using System.IO;
Expand All @@ -28,6 +29,8 @@ namespace OpenQA.Selenium.Internal
/// </summary>
internal static class FileUtilities
{
private static readonly ILogger logger = Log.GetLogger(typeof(FileUtilities));

/// <summary>
/// Recursively copies a directory.
/// </summary>
Expand Down Expand Up @@ -99,7 +102,7 @@ public static void DeleteDirectory(string directoryToDelete)

if (Directory.Exists(directoryToDelete))
{
Console.WriteLine("Unable to delete directory '{0}'", directoryToDelete);
logger.Trace($"Unable to delete directory '{directoryToDelete}'");
}
}

Expand Down
5 changes: 4 additions & 1 deletion dotnet/src/webdriver/Safari/SafariDriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium.Internal;
using OpenQA.Selenium.Internal.Logging;

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

private bool useLegacyProtocol;

private readonly static ILogger logger = Log.GetLogger<SafariDriverService>();

/// <summary>
/// Initializes a new instance of the <see cref="SafariDriverService"/> class.
/// </summary>
Expand Down Expand Up @@ -150,7 +153,7 @@ protected override bool IsInitialized
// check.
catch (Exception ex) when (ex is HttpRequestException || ex is TaskCanceledException)
{
Console.WriteLine(ex);
logger.Trace(ex.ToString());
}
}
}
Expand Down

0 comments on commit fffd05c

Please sign in to comment.