Skip to content

Commit ef6c472

Browse files
[dotnet] Enabling Chrome and Edge driver services to set log level (#16098)
* [dotnet] Enabling Chrome and Edge driver services to set log level Helps with #12273 * [dotnet] Format script. * Update dotnet/src/webdriver/Chromium/ChromiumDriverService.cs Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com> * Following convention --------- Co-authored-by: qodo-merge-pro[bot] <151058649+qodo-merge-pro[bot]@users.noreply.github.com>
1 parent 0f831ba commit ef6c472

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// <copyright file="ChromiumDriverLogLevel.cs" company="Selenium Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
// </copyright>
19+
20+
namespace OpenQA.Selenium.Chromium;
21+
22+
/// <summary>
23+
/// Represents the valid values of logging levels available with the Chromium based drivers.
24+
/// </summary>
25+
public enum ChromiumDriverLogLevel
26+
{
27+
/// <summary>
28+
/// Represents the value All, the most detailed logging level available.
29+
/// </summary>
30+
All,
31+
32+
/// <summary>
33+
/// Represents the Debug value
34+
/// </summary>
35+
Debug,
36+
37+
/// <summary>
38+
/// Represents the Info value
39+
/// </summary>
40+
Info,
41+
42+
/// <summary>
43+
/// Represents the Warning value
44+
/// </summary>
45+
Warning ,
46+
47+
/// <summary>
48+
/// Represents the Severe value
49+
/// </summary>
50+
Severe,
51+
52+
/// <summary>
53+
/// Represents the Off value, nothing gets logged
54+
/// </summary>
55+
Off,
56+
57+
/// <summary>
58+
/// Represents that the logging value is unspecified, and should be the default level.
59+
/// </summary>
60+
Default
61+
}

dotnet/src/webdriver/Chromium/ChromiumDriverService.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ protected ChromiumDriverService(string? executablePath, string? executableFileNa
8484
/// </summary>
8585
public bool EnableAppendLog { get; set; }
8686

87+
/// <summary>
88+
/// Gets or sets the level at which log output is displayed.
89+
/// </summary>
90+
public ChromiumDriverLogLevel LogLevel { get; set; } = ChromiumDriverLogLevel.Default;
91+
8792
/// <summary>
8893
/// <para>Gets or sets the comma-delimited list of IP addresses that are approved to connect to this instance of the Chrome driver.</para>
8994
/// <para>A value of <see langword="null"/> or <see cref="string.Empty"/> means only the local loopback address can connect.</para>
@@ -154,6 +159,15 @@ protected override string CommandLineArguments
154159
argsBuilder.Append(string.Format(CultureInfo.InvariantCulture, " -allowed-ips={0}", this.AllowedIPAddresses));
155160
}
156161

162+
if (this.LogLevel != ChromiumDriverLogLevel.Default)
163+
{
164+
if (Enum.IsDefined(typeof(ChromiumDriverLogLevel), this.LogLevel))
165+
{
166+
argsBuilder.Append(string.Format(CultureInfo.InvariantCulture, " --log-level={0}", this.LogLevel.ToString().ToUpperInvariant()));
167+
}
168+
}
169+
170+
157171
return argsBuilder.ToString();
158172
}
159173
}

0 commit comments

Comments
 (0)