Skip to content

Commit 05b1fbd

Browse files
committed
Update Python logging examples in documentation. (#2206)[deploy site]
* Update Python logging examples in documentation. This adds information to the logging docs in `documentation/webdriver/troubleshooting/`` for setting up log handlers in Python. This is necessary to get log output. * Add file logging to Python logging examples --------- Co-authored-by: Sri Harsha <12621691+harsha509@users.noreply.github.com> e4f3470
1 parent 2e64596 commit 05b1fbd

File tree

35 files changed

+223
-143
lines changed

35 files changed

+223
-143
lines changed

documentation/_print/index.html

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8765,7 +8765,12 @@
87658765
to look at the important Selenium logs,
87668766
take a look at the <a href=https://github.com/titusfortner/selenium-logger#selenium-logger>Selenium Logger project</a></p></div><div class="tab-body tab-pane fade" id=tabs-00-01 role=tabpanel aria-labelled-by=tabs-00-01-tab tabindex=0><p>Python logs are typically created per module. You can match all submodules by referencing the top
87678767
level module. So to work with all loggers in selenium module, you can do this:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-py data-lang=py><span style=display:flex><span> <span style=color:#000>logger</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>logging</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>getLogger</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>&#39;selenium&#39;</span><span style=color:#000;font-weight:700>)</span></span></span></code></pre></div><div class="text-end pb-2"><a href=https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk//examples/python/tests/troubleshooting/test_logging.py#L5 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
8768-
<strong>View full example on GitHub</strong></a></div></div><div class="tab-body tab-pane fade" id=tabs-00-02 role=tabpanel aria-labelled-by=tabs-00-02-tab tabindex=0><p>.NET logger is managed with a static class, so all access to logging is managed simply by referencing <code>Log</code> from the <code>OpenQA.Selenium.Internal.Logging</code> namespace.</p></div><div class="tab-body tab-pane fade" id=tabs-00-03 role=tabpanel aria-labelled-by=tabs-00-03-tab tabindex=0><p>If you want to see as much debugging as possible in all the classes,
8768+
<strong>View full example on GitHub</strong></a></div><p>You must also create and add a log handler (<code>StreamHandler</code>, <code>FileHandler</code>, etc).</p><p>To save logs to a file, you can do this:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-py data-lang=py><span style=display:flex><span><span style=color:#000>log_path</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#4e9a06>&#39;/path/to/log&#39;</span>
8769+
</span></span><span style=display:flex><span><span style=color:#000>handler</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>logging</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>FileHandler</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>log_path</span><span style=color:#000;font-weight:700>)</span>
8770+
</span></span><span style=display:flex><span><span style=color:#000>logger</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>addHandler</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>handler</span><span style=color:#000;font-weight:700>)</span>
8771+
</span></span></code></pre></div><p>To display logs in the console, you can do this:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-py data-lang=py><span style=display:flex><span><span style=color:#000>handler</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>logging</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>StreamHandler</span><span style=color:#000;font-weight:700>()</span>
8772+
</span></span><span style=display:flex><span><span style=color:#000>logger</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>addHandler</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>handler</span><span style=color:#000;font-weight:700>)</span>
8773+
</span></span></code></pre></div></div><div class="tab-body tab-pane fade" id=tabs-00-02 role=tabpanel aria-labelled-by=tabs-00-02-tab tabindex=0><p>.NET logger is managed with a static class, so all access to logging is managed simply by referencing <code>Log</code> from the <code>OpenQA.Selenium.Internal.Logging</code> namespace.</p></div><div class="tab-body tab-pane fade" id=tabs-00-03 role=tabpanel aria-labelled-by=tabs-00-03-tab tabindex=0><p>If you want to see as much debugging as possible in all the classes,
87698774
you can turn on debugging globally in Ruby by setting <code>$DEBUG = true</code>.</p><p>For more fine-tuned control, Ruby Selenium created its own Logger class to wrap the default <code>Logger</code> class.
87708775
This implementation provides some interesting additional features.
87718776
Obtain the logger directly from the <code>#logger</code>class method on the <code>Selenium::WebDriver</code> module:</p><p><a href=https://github.com/SeleniumHQ/selenium/releases/tag/selenium-4.10.0><span class=selenium-badge-version data-bs-toggle=tooltip data-bs-placement=right title="This code requires Selenium v4.10 or greater">Selenium v4.10</span></a></p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-rb data-lang=rb><span style=display:flex><span> <span style=color:#000>logger</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>Selenium</span><span style=color:#ce5c00;font-weight:700>::</span><span style=color:#000>WebDriver</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>logger</span></span></span></code></pre></div><div class="text-end pb-2"><a href=https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk//examples/ruby/spec/troubleshooting/logging_spec.rb#L11 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
@@ -13962,7 +13967,7 @@
1396213967
No patent liability is assumed with respect
1396313968
to the use of the information contained herein.</p><h2 id=attributions>Attributions</h2><h4 id=selenium-main-repositorygithubcomseleniumhqselenium><a href=//github.com/SeleniumHQ/selenium/>Selenium Main Repository</a></h4><style type=text/css>.ghContributors{display:flex;flex-flow:wrap;align-content:flex-start}.ghContributors>div{width:50%;display:inline-flex;margin-bottom:5px}.ghContributors>div label{padding-left:4px}.ghContributors>div span{font-size:x-small;padding-left:4px}</style><div class=ghContributors><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/28229?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
1396413969
<label><a href=https://github.com/shs96c>@shs96c</a></label>
13965-
<span class=contributions>5338 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/617090?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
13970+
<span class=contributions>5339 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/617090?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
1396613971
<label><a href=https://github.com/barancev>@barancev</a></label>
1396713972
<span class=contributions>3352 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/352840?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
1396813973
<label><a href=https://github.com/jimevans>@jimevans</a></label>
@@ -14006,11 +14011,11 @@
1400614011
<label><a href=https://github.com/symonk>@symonk</a></label>
1400714012
<span class=contributions>203 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/122800?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
1400814013
<label><a href=https://github.com/davehunt>@davehunt</a></label>
14009-
<span class=contributions>200 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/455056?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
14010-
<label><a href=https://github.com/hbchai>@hbchai</a></label>
14011-
<span class=contributions>191 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/22616990?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
14014+
<span class=contributions>200 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/22616990?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
1401214015
<label><a href=https://github.com/nvborisenko>@nvborisenko</a></label>
14013-
<span class=contributions>190 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/4405962?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
14016+
<span class=contributions>193 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/455056?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
14017+
<label><a href=https://github.com/hbchai>@hbchai</a></label>
14018+
<span class=contributions>191 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/4405962?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
1401414019
<label><a href=https://github.com/lmtierney>@lmtierney</a></label>
1401514020
<span class=contributions>179 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/696749?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
1401614021
<label><a href=https://github.com/freynaud>@freynaud</a></label>
@@ -14020,14 +14025,14 @@
1402014025
<label><a href=https://github.com/nirvdrum>@nirvdrum</a></label>
1402114026
<span class=contributions>133 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/3331063?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
1402214027
<label><a href=https://github.com/selenium-ci>@selenium-ci</a></label>
14023-
<span class=contributions>131 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/1168195?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
14028+
<span class=contributions>132 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/1168195?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
1402414029
<label><a href=https://github.com/sevaseva>@sevaseva</a></label>
1402514030
<span class=contributions>115 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/140960?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
1402614031
<label><a href=https://github.com/gigix>@gigix</a></label>
14032+
<span class=contributions>109 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/12619902?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
14033+
<label><a href=https://github.com/RenderMichael>@RenderMichael</a></label>
1402714034
<span class=contributions>109 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/10137971?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
1402814035
<label><a href=https://github.com/juangj>@juangj</a></label>
14029-
<span class=contributions>108 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/12619902?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
14030-
<label><a href=https://github.com/RenderMichael>@RenderMichael</a></label>
1403114036
<span class=contributions>108 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/1000?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
1403214037
<label><a href=https://github.com/aslakhellesoy>@aslakhellesoy</a></label>
1403314038
<span class=contributions>94 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/in/2740?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>

documentation/about/_print/index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
No patent liability is assumed with respect
4242
to the use of the information contained herein.</p><h2 id=attributions>Attributions</h2><h4 id=selenium-main-repositorygithubcomseleniumhqselenium><a href=//github.com/SeleniumHQ/selenium/>Selenium Main Repository</a></h4><style type=text/css>.ghContributors{display:flex;flex-flow:wrap;align-content:flex-start}.ghContributors>div{width:50%;display:inline-flex;margin-bottom:5px}.ghContributors>div label{padding-left:4px}.ghContributors>div span{font-size:x-small;padding-left:4px}</style><div class=ghContributors><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/28229?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
4343
<label><a href=https://github.com/shs96c>@shs96c</a></label>
44-
<span class=contributions>5338 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/617090?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
44+
<span class=contributions>5339 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/617090?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
4545
<label><a href=https://github.com/barancev>@barancev</a></label>
4646
<span class=contributions>3352 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/352840?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
4747
<label><a href=https://github.com/jimevans>@jimevans</a></label>
@@ -85,11 +85,11 @@
8585
<label><a href=https://github.com/symonk>@symonk</a></label>
8686
<span class=contributions>203 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/122800?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
8787
<label><a href=https://github.com/davehunt>@davehunt</a></label>
88-
<span class=contributions>200 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/455056?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
89-
<label><a href=https://github.com/hbchai>@hbchai</a></label>
90-
<span class=contributions>191 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/22616990?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
88+
<span class=contributions>200 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/22616990?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
9189
<label><a href=https://github.com/nvborisenko>@nvborisenko</a></label>
92-
<span class=contributions>190 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/4405962?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
90+
<span class=contributions>193 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/455056?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
91+
<label><a href=https://github.com/hbchai>@hbchai</a></label>
92+
<span class=contributions>191 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/4405962?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
9393
<label><a href=https://github.com/lmtierney>@lmtierney</a></label>
9494
<span class=contributions>179 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/696749?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
9595
<label><a href=https://github.com/freynaud>@freynaud</a></label>
@@ -99,14 +99,14 @@
9999
<label><a href=https://github.com/nirvdrum>@nirvdrum</a></label>
100100
<span class=contributions>133 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/3331063?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
101101
<label><a href=https://github.com/selenium-ci>@selenium-ci</a></label>
102-
<span class=contributions>131 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/1168195?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
102+
<span class=contributions>132 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/1168195?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
103103
<label><a href=https://github.com/sevaseva>@sevaseva</a></label>
104104
<span class=contributions>115 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/140960?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
105105
<label><a href=https://github.com/gigix>@gigix</a></label>
106+
<span class=contributions>109 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/12619902?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
107+
<label><a href=https://github.com/RenderMichael>@RenderMichael</a></label>
106108
<span class=contributions>109 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/10137971?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
107109
<label><a href=https://github.com/juangj>@juangj</a></label>
108-
<span class=contributions>108 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/12619902?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
109-
<label><a href=https://github.com/RenderMichael>@RenderMichael</a></label>
110110
<span class=contributions>108 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/1000?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
111111
<label><a href=https://github.com/aslakhellesoy>@aslakhellesoy</a></label>
112112
<span class=contributions>94 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/in/2740?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>

0 commit comments

Comments
 (0)