diff --git a/README.md b/README.md index ea32354..bae4d74 100644 --- a/README.md +++ b/README.md @@ -2488,13 +2488,13 @@ logging.basicConfig( >>> logging.basicConfig(level='WARNING') >>> logger = logging.getLogger('my_module') >>> handler = logging.FileHandler('test.log') ->>> formatter = logging.Formatter('%(asctime)s - %(levelname)s:%(name)s:%(message)s') +>>> formatter = logging.Formatter('%(asctime)s %(levelname)s:%(name)s:%(message)s') >>> handler.setFormatter(formatter) >>> logger.addHandler(handler) >>> logger.critical('Running out of disk space.') CRITICAL:my_module:Running out of disk space. >>> open('test.log').read() -2023-02-07 23:21:01,430 - CRITICAL:my_module:Running out of disk space. +2023-02-07 23:21:01,430 CRITICAL:my_module:Running out of disk space. ``` diff --git a/index.html b/index.html index 78431e8..b99166c 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
>>> logging.basicConfig(level='WARNING')
>>> logger = logging.getLogger('my_module')
>>> handler = logging.FileHandler('test.log')
->>> formatter = logging.Formatter('%(asctime)s - %(levelname)s:%(name)s:%(message)s')
+>>> formatter = logging.Formatter('%(asctime)s %(levelname)s:%(name)s:%(message)s')
>>> handler.setFormatter(formatter)
>>> logger.addHandler(handler)
>>> logger.critical('Running out of disk space.')
CRITICAL:my_module:Running out of disk space.
>>> open('test.log').read()
-2023-02-07 23:21:01,430 - CRITICAL:my_module:Running out of disk space.
+2023-02-07 23:21:01,430 CRITICAL:my_module:Running out of disk space.
# $ pip3 install requests beautifulsoup4
@@ -2927,7 +2927,7 @@ $ pyinstaller script.py --add-data '<path>:.'
diff --git a/parse.js b/parse.js
index 76b2581..eb05a8f 100755
--- a/parse.js
+++ b/parse.js
@@ -169,6 +169,18 @@ const PROGRESS_BAR =
'... sleep(1)\n' +
'Processing: 100%|████████████████████| 3/3 [00:03<00:00, 1.00s/it]\n';
+const LOGGING_EXAMPLE =
+ '>>> logging.basicConfig(level=\'WARNING\')\n' +
+ '>>> logger = logging.getLogger(\'my_module\')\n' +
+ '>>> handler = logging.FileHandler(\'test.log\')\n' +
+ '>>> formatter = logging.Formatter(\'%(asctime)s %(levelname)s:%(name)s:%(message)s\')\n' +
+ '>>> handler.setFormatter(formatter)\n' +
+ '>>> logger.addHandler(handler)\n' +
+ '>>> logger.critical(\'Running out of disk space.\')\n' +
+ 'CRITICAL:my_module:Running out of disk space.\n' +
+ '>>> open(\'test.log\').read()\n' +
+ '2023-02-07 23:21:01,430 CRITICAL:my_module:Running out of disk space.\n';
+
const AUDIO =
'from math import pi, sin\n' +
'samples_f = (sin(i * 2 * pi * 440 / 44100) for i in range(100_000))\n' +
@@ -756,6 +768,7 @@ function fixHighlights() {
$(`code:contains(ValueError: malformed node)`).html(EVAL);
$(`code:contains(import asyncio, collections, curses, curses.textpad, enum, random)`).html(COROUTINES);
$(`code:contains(pip3 install tqdm)`).html(PROGRESS_BAR);
+ $(`code:contains(>>> logging.basicConfig(level=)`).html(LOGGING_EXAMPLE);
$(`code:contains(samples_f = (sin(i *)`).html(AUDIO);
$(`code:contains(collections, dataclasses, enum, io, itertools)`).html(MARIO);
$(`code:contains(pip3 install pyinstaller)`).html(PYINSTALLER);