gh-121035: Improve logging flow diagram for dark/light modes. (GH-121254)

This commit is contained in:
Vinay Sajip 2024-07-02 09:13:37 +01:00 committed by GitHub
parent 4f1e1dff89
commit bfe0e4d769
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 62 additions and 11 deletions

View File

@ -385,6 +385,44 @@ following diagram.
.. raw:: html .. raw:: html
:file: logging_flow.svg :file: logging_flow.svg
.. raw:: html
<script>
/*
* This snippet is needed to handle the case where a light or dark theme is
* chosen via the theme is selected in the page. We call the existing handler
* and then add a dark-theme class to the body when the dark theme is selected.
* The SVG styling (above) then does the rest.
*
* If the pydoc theme is updated to set the dark-theme class, this snippet
* won't be needed any more.
*/
(function() {
var oldActivateTheme = activateTheme;
function updateBody(theme) {
let elem = document.body;
if (theme === 'dark') {
elem.classList.add('dark-theme');
}
else {
elem.classList.remove('dark-theme');
}
}
activateTheme = function(theme) {
oldActivateTheme(theme);
updateBody(theme);
};
/*
* If the page is refreshed, make sure we update the body - the overriding
* of activateTheme won't have taken effect yet.
*/
updateBody(localStorage.getItem('currentTheme') || 'auto');
})();
</script>
Loggers Loggers
^^^^^^^ ^^^^^^^

View File

@ -16,7 +16,7 @@
stroke-opacity: 1; stroke-opacity: 1;
} }
polygon.filled { polygon.filled {
fill: #ff0000; fill: #000000;
} }
polyline { polyline {
fill: none; fill: none;
@ -36,6 +36,9 @@
polygon, rect, polyline, line { polygon, rect, polyline, line {
stroke: #ffffff; stroke: #ffffff;
} }
polygon.filled {
fill: #ffffff;
}
text { text {
fill: #ffffff; fill: #ffffff;
} }
@ -43,6 +46,15 @@
filter: invert(100%) hue-rotate(180deg) saturate(1.25); filter: invert(100%) hue-rotate(180deg) saturate(1.25);
} }
} }
body.dark-theme polygon, body.dark-theme rect, body.dark-theme polyline, body.dark-theme line {
stroke: #ffffff;
}
body.dark-theme polygon.filled {
fill: #ffffff;
}
body.dark-theme text {
fill: #ffffff;
}
</style> </style>
<defs /> <defs />
@ -57,7 +69,7 @@
<rect x="81.5533" y="106.469" width="44.45" height="25.9333" rx="0" ry="0" /> <rect x="81.5533" y="106.469" width="44.45" height="25.9333" rx="0" ry="0" />
<text font-size="6.77333" style="text-anchor: middle;" x="103.778" y="117.256"> <text font-size="6.77333" style="text-anchor: middle;" x="103.778" y="117.256">
<tspan x="103.778" y="117.256">Create</tspan> <tspan x="103.778" y="117.256">Create</tspan>
<tspan x="103.778" y="125.723">LogRecord</tspan> <tspan x="103.778" y="125.723" style="font-family: monospace">LogRecord</tspan>
</text> </text>
</g> </g>
<g> <g>
@ -100,7 +112,7 @@
<g> <g>
<rect x="75.2033" y="249.478" width="57.15" height="34.4" rx="0" ry="0" /> <rect x="75.2033" y="249.478" width="57.15" height="34.4" rx="0" ry="0" />
<text font-size="6.77333" style="text-anchor: middle;" x="103.778" y="260.265"> <text font-size="6.77333" style="text-anchor: middle;" x="103.778" y="260.265">
<tspan x="103.778" y="260.265">Pass to</tspan> <tspan x="103.778" y="260.265">Pass record to</tspan>
<tspan x="103.778" y="268.732">handlers of</tspan> <tspan x="103.778" y="268.732">handlers of</tspan>
<tspan x="103.778" y="277.198">current logger</tspan> <tspan x="103.778" y="277.198">current logger</tspan>
</text> </text>
@ -135,16 +147,17 @@
</g> </g>
<g> <g>
<rect x="298.963" y="312.257" width="57.75" height="25.9333" rx="0" ry="0" /> <rect x="298.963" y="312.257" width="57.75" height="25.9333" rx="0" ry="0" />
<text font-size="6.77333" style="text-anchor: middle;" x="327.838" y="323.044"> <text font-size="6.77333" x="327.838" y="323.044">
<tspan x="327.838" y="324.100">Use lastResort</tspan> <tspan x="301" y="324.100">Use</tspan>
<tspan x="327.838" y="332.567">handler</tspan> <tspan x="315" y="324.100" style="font-family: monospace">lastResort</tspan>
<tspan x="316" y="332.567">handler</tspan>
</text> </text>
</g> </g>
<g> <g>
<polygon fill-rule="evenodd" points="320.041,35.7307 373.377,60.8536 320.041,85.9765 266.704,60.8536 " /> <polygon fill-rule="evenodd" points="320.041,35.7307 373.377,60.8536 320.041,85.9765 266.704,60.8536 " />
<text font-size="6.77333" style="text-anchor: middle;" x="320.041" y="58.6741"> <text font-size="6.77333" style="text-anchor: middle;" x="320.041" y="58.6741">
<tspan x="320.041" y="58.6741">Handler enabled for</tspan> <tspan x="320.041" y="58.6741">Handler enabled for</tspan>
<tspan x="320.041" y="67.1407">level of LogRecord?</tspan> <tspan x="320.041" y="67.1407">level of record?</tspan>
</text> </text>
</g> </g>
<g> <g>
@ -292,7 +305,7 @@
<tspan x="323.75" y="99.0042">Yes</tspan> <tspan x="323.75" y="99.0042">Yes</tspan>
</text> </text>
<text font-size="6.77323" style="text-anchor: middle;" x="355.762" y="18.2449"> <text font-size="6.77323" style="text-anchor: middle;" x="355.762" y="18.2449">
<tspan x="355.762" y="18.2449">LogRecord passed</tspan> <tspan x="355.762" y="18.2449">Record passed</tspan>
<tspan x="355.762" y="26.7116">to handler</tspan> <tspan x="355.762" y="26.7116">to handler</tspan>
</text> </text>
<line style="stroke-dasharray: 5" x1="330.96" y1="266.686" x2="377.733" y2="267.908" /> <line style="stroke-dasharray: 5" x1="330.96" y1="266.686" x2="377.733" y2="267.908" />

Before

(image error) Size: 13 KiB

After

(image error) Size: 14 KiB