chunk_id stringlengths 36 36 | source stringclasses 35
values | source_url stringlengths 0 290 | upstream_license stringclasses 1
value | document_id stringlengths 36 36 | chunk_index int64 0 324k | retrieved_at stringclasses 2
values | chunker_version stringclasses 4
values | content_hash stringlengths 15 64 | content stringlengths 50 44.7k | namespace stringclasses 9
values | source_name stringclasses 35
values | raw_text stringlengths 50 44.7k | cleaned_text stringlengths 50 44.7k | tags stringclasses 49
values | collection_name stringclasses 11
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
829fe4ff-f881-486f-a1e2-f7456b8d0df3 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,601 | supabase-export-v2 | 15a5fe14bf83f0f7 | import logging import logging.config import logging.handlers from multiprocessing import Process, Queue, Event, current_process import os import random import time
class MyHandler:
"""
A simple handler for logging events. It runs in the listener process and
dispatches events to loggers based on the name in the recei... | trusted_official_docs | CPython Docs | import logging import logging.config import logging.handlers from multiprocessing import Process, Queue, Event, current_process import os import random import time
class MyHandler:
"""
A simple handler for logging events. It runs in the listener process and
dispatches events to loggers based on the name in the recei... | import logging import logging.config import logging.handlers from multiprocessing import Process, Queue, Event, current_process import os import random import time
class MyHandler:
"""
A simple handler for logging events. It runs in the listener process and
dispatches events to loggers based on the name in the recei... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
832538e1-f558-4a2b-a414-4dffe130f335 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,216 | supabase-export-v2 | 00e75dc6f0a0fb57 | add it to the handlers formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) ch.setFormatter(formatter) # add the handlers to the logger logger.addHandler(fh) logger.addHandler(ch)
logger.info('creating an instance of auxiliary_module.Auxiliary')
a = auxiliary... | trusted_official_docs | CPython Docs | add it to the handlers formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) ch.setFormatter(formatter) # add the handlers to the logger logger.addHandler(fh) logger.addHandler(ch)
logger.info('creating an instance of auxiliary_module.Auxiliary')
a = auxiliary... | add it to the handlers formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setFormatter(formatter) ch.setFormatter(formatter) # add the handlers to the logger logger.addHandler(fh) logger.addHandler(ch)
logger.info('creating an instance of auxiliary_module.Auxiliary')
a = auxiliary... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8385f496-ece4-4df9-a835-e146d09b294e | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,232 | supabase-export-v2 | cb2037d89a8348a7 | .. code-block:: none
0 Thread-1 Hi from myfunc
3 MainThread Hello from main
505 Thread-1 Hi from myfunc
755 MainThread Hello from main
1007 Thread-1 Hi from myfunc
1507 MainThread Hello from main
1508 Thread-1 Hi from myfunc
2010 Thread-1 Hi from myfunc
2258 MainThread Hello from main
2512 Thread-1 Hi from myf... | trusted_official_docs | CPython Docs | .. code-block:: none
0 Thread-1 Hi from myfunc
3 MainThread Hello from main
505 Thread-1 Hi from myfunc
755 MainThread Hello from main
1007 Thread-1 Hi from myfunc
1507 MainThread Hello from main
1508 Thread-1 Hi from myfunc
2010 Thread-1 Hi from myfunc
2258 MainThread Hello from main
2512 Thread-1 Hi from myf... | .. code-block:: none
0 Thread-1 Hi from myfunc
3 MainThread Hello from main
505 Thread-1 Hi from myfunc
755 MainThread Hello from main
1007 Thread-1 Hi from myfunc
1507 MainThread Hello from main
1508 Thread-1 Hi from myfunc
2010 Thread-1 Hi from myfunc
2258 MainThread Hello from main
2512 Thread-1 Hi from myf... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
840c63fe-2e7c-436c-a519-36c610a5fdf9 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,597 | supabase-export-v2 | a3164fd441730bbf | A more elaborate multiprocessing example ----------------------------------------
The following working example shows how logging can be used with multiprocessing
using configuration files. The configurations are fairly simple, but serve to
illustrate how more complex ones could be implemented in a real multiprocessing... | trusted_official_docs | CPython Docs | A more elaborate multiprocessing example ----------------------------------------
The following working example shows how logging can be used with multiprocessing
using configuration files. The configurations are fairly simple, but serve to
illustrate how more complex ones could be implemented in a real multiprocessing... | A more elaborate multiprocessing example ----------------------------------------
The following working example shows how logging can be used with multiprocessing
using configuration files. The configurations are fairly simple, but serve to
illustrate how more complex ones could be implemented in a real multiprocessing... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
84b7123b-1297-467a-af66-ee97673ab381 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,595 | supabase-export-v2 | 7034c3731679f21b | .. code-block:: shell-session
$ ls rotated.log*
rotated.log rotated.log.2.gz rotated.log.4.gz
rotated.log.1.gz rotated.log.3.gz rotated.log.5.gz
$ zcat rotated.log.1.gz
2023-01-20 02:28:17,767 Message no. 996
2023-01-20 02:28:17,767 Message no. 997
2023-01-20 02:28:17,767 Message no. 998 | trusted_official_docs | CPython Docs | .. code-block:: shell-session
$ ls rotated.log*
rotated.log rotated.log.2.gz rotated.log.4.gz
rotated.log.1.gz rotated.log.3.gz rotated.log.5.gz
$ zcat rotated.log.1.gz
2023-01-20 02:28:17,767 Message no. 996
2023-01-20 02:28:17,767 Message no. 997
2023-01-20 02:28:17,767 Message no. 998 | .. code-block:: shell-session
$ ls rotated.log*
rotated.log rotated.log.2.gz rotated.log.4.gz
rotated.log.1.gz rotated.log.3.gz rotated.log.5.gz
$ zcat rotated.log.1.gz
2023-01-20 02:28:17,767 Message no. 996
2023-01-20 02:28:17,767 Message no. 997
2023-01-20 02:28:17,767 Message no. 998 | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8616a986-19f9-429b-ae22-0f9488c3fb8e | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,431 | supabase-export-v2 | e1a5f3711454435c | def filter(record: logging.LogRecord): record = copy.copy(record) record.user = 'jim' return record
if __name__ == '__main__':
logger = logging.getLogger()
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
formatter = logging.Formatter('%(message)s from %(user)-8s')
handler.setFormatter(formatter)
h... | trusted_official_docs | CPython Docs | def filter(record: logging.LogRecord): record = copy.copy(record) record.user = 'jim' return record
if __name__ == '__main__':
logger = logging.getLogger()
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
formatter = logging.Formatter('%(message)s from %(user)-8s')
handler.setFormatter(formatter)
h... | def filter(record: logging.LogRecord): record = copy.copy(record) record.user = 'jim' return record
if __name__ == '__main__':
logger = logging.getLogger()
logger.setLevel(logging.INFO)
handler = logging.StreamHandler()
formatter = logging.Formatter('%(message)s from %(user)-8s')
handler.setFormatter(formatter)
h... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
873ccb72-3f58-4ce7-92db-39b32745d691 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,954 | supabase-export-v2 | 69ed579d2047ce65 | Using loggers as attributes in a class or passing them as parameters ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
While there might be unusual cases where you'll need to do this, in general
there is no point because loggers are singletons. Code can always access a
given logger instance by name u... | trusted_official_docs | CPython Docs | Using loggers as attributes in a class or passing them as parameters ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
While there might be unusual cases where you'll need to do this, in general
there is no point because loggers are singletons. Code can always access a
given logger instance by name u... | Using loggers as attributes in a class or passing them as parameters ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
While there might be unusual cases where you'll need to do this, in general
there is no point because loggers are singletons. Code can always access a
given logger instance by name u... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
87a7fdd4-4eb2-4d71-a422-08e8846bc53b | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,575 | supabase-export-v2 | 593aa2286327beb1 | 613 Message no. 5 DEBUG myapp 613 Message no. 6 CRITICAL myapp.lib1 613 Message no. 7 INFO myapp.lib1 613 Message no. 8 (and so on)
In the second sender shell: | trusted_official_docs | CPython Docs | 613 Message no. 5 DEBUG myapp 613 Message no. 6 CRITICAL myapp.lib1 613 Message no. 7 INFO myapp.lib1 613 Message no. 8 (and so on)
In the second sender shell: | 613 Message no. 5 DEBUG myapp 613 Message no. 6 CRITICAL myapp.lib1 613 Message no. 7 INFO myapp.lib1 613 Message no. 8 (and so on)
In the second sender shell: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
87c38a85-88ec-49ad-8bd4-29e061265b83 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,299 | supabase-export-v2 | 411cba58de1dd836 | configurations make, until Ctrl+C is pressed while True: logger.debug('debug message') logger.info('info message') logger.warning('warn message') logger.error('error message') logger.critical('critical message') time.sleep(5) except KeyboardInterrupt: # cleanup logging.config.stopListening() t.join()
And here is a scri... | trusted_official_docs | CPython Docs | configurations make, until Ctrl+C is pressed while True: logger.debug('debug message') logger.info('info message') logger.warning('warn message') logger.error('error message') logger.critical('critical message') time.sleep(5) except KeyboardInterrupt: # cleanup logging.config.stopListening() t.join()
And here is a scri... | configurations make, until Ctrl+C is pressed while True: logger.debug('debug message') logger.info('info message') logger.warning('warn message') logger.error('error message') logger.critical('critical message') time.sleep(5) except KeyboardInterrupt: # cleanup logging.config.stopListening() t.join()
And here is a scri... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8868bb4d-3f7d-4258-9ca8-1c61ccc13dc8 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,725 | supabase-export-v2 | e398c90ce454542b | Speaking logging messages -------------------------
There might be situations when it is desirable to have logging messages rendered
in an audible rather than a visible format. This is easy to do if you have
text-to-speech (TTS) functionality available in your system, even if it doesn't have
a Python binding. Most TTS ... | trusted_official_docs | CPython Docs | Speaking logging messages -------------------------
There might be situations when it is desirable to have logging messages rendered
in an audible rather than a visible format. This is easy to do if you have
text-to-speech (TTS) functionality available in your system, even if it doesn't have
a Python binding. Most TTS ... | Speaking logging messages -------------------------
There might be situations when it is desirable to have logging messages rendered
in an audible rather than a visible format. This is easy to do if you have
text-to-speech (TTS) functionality available in your system, even if it doesn't have
a Python binding. Most TTS ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8886a329-6b30-468a-8f39-663d89f6f1ee | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,827 | supabase-export-v2 | c6089b9e3e05d390 | $ python app.py stop foo bar INFO stop Stopped the 'foo' and 'bar' services.
$ python app.py restart foo bar baz
INFO restart Restarted the 'foo', 'bar' and 'baz' services. | trusted_official_docs | CPython Docs | $ python app.py stop foo bar INFO stop Stopped the 'foo' and 'bar' services.
$ python app.py restart foo bar baz
INFO restart Restarted the 'foo', 'bar' and 'baz' services. | $ python app.py stop foo bar INFO stop Stopped the 'foo' and 'bar' services.
$ python app.py restart foo bar baz
INFO restart Restarted the 'foo', 'bar' and 'baz' services. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
88e72490-ac8d-46ce-a040-579c04d1ac79 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,625 | supabase-export-v2 | 673299112939a5a8 | like, but make sure that the data that appears in there after substitution is always ASCII (that way, it will remain unchanged after UTF-8 encoding).
#. Replace the Unicode section with whatever placeholders you like; if the data
which appears there after substitution contains characters outside the ASCII
range, that... | trusted_official_docs | CPython Docs | like, but make sure that the data that appears in there after substitution is always ASCII (that way, it will remain unchanged after UTF-8 encoding).
#. Replace the Unicode section with whatever placeholders you like; if the data
which appears there after substitution contains characters outside the ASCII
range, that... | like, but make sure that the data that appears in there after substitution is always ASCII (that way, it will remain unchanged after UTF-8 encoding).
#. Replace the Unicode section with whatever placeholders you like; if the data
which appears there after substitution contains characters outside the ASCII
range, that... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
89180aa1-3b30-4e14-aca1-6af9e390bca2 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,456 | supabase-export-v2 | e926d454eb301965 | logging.ERROR, logging.CRITICAL] loggers = ['foo', 'foo.bar', 'foo.bar.baz', 'spam', 'spam.ham', 'spam.ham.eggs'] for i in range(100): lvl = random.choice(levels) logger = logging.getLogger(random.choice(loggers)) logger.log(lvl, 'Message no. %d', i)
if __name__ == '__main__':
q = Queue()
d = {
'version': 1,
'forma... | trusted_official_docs | CPython Docs | logging.ERROR, logging.CRITICAL] loggers = ['foo', 'foo.bar', 'foo.bar.baz', 'spam', 'spam.ham', 'spam.ham.eggs'] for i in range(100): lvl = random.choice(levels) logger = logging.getLogger(random.choice(loggers)) logger.log(lvl, 'Message no. %d', i)
if __name__ == '__main__':
q = Queue()
d = {
'version': 1,
'forma... | logging.ERROR, logging.CRITICAL] loggers = ['foo', 'foo.bar', 'foo.bar.baz', 'spam', 'spam.ham', 'spam.ham.eggs'] for i in range(100): lvl = random.choice(levels) logger = logging.getLogger(random.choice(loggers)) logger.log(lvl, 'Message no. %d', i)
if __name__ == '__main__':
q = Queue()
d = {
'version': 1,
'forma... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8a1aa784-eb0a-40b3-98e2-8b9c89ae1a2c | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,518 | supabase-export-v2 | 055567e3e21b8c26 | and including the logger where further propagation up the hierarchy is disabled). Before Python 3.2, there were only two places where this creation was done:
* :meth:`Logger.makeRecord`, which is called in the normal process of
logging an event. This invoked :class:`LogRecord` directly to create an
instance. * :func:... | trusted_official_docs | CPython Docs | and including the logger where further propagation up the hierarchy is disabled). Before Python 3.2, there were only two places where this creation was done:
* :meth:`Logger.makeRecord`, which is called in the normal process of
logging an event. This invoked :class:`LogRecord` directly to create an
instance. * :func:... | and including the logger where further propagation up the hierarchy is disabled). Before Python 3.2, there were only two places where this creation was done:
* :meth:`Logger.makeRecord`, which is called in the normal process of
logging an event. This invoked :class:`LogRecord` directly to create an
instance. * :func:... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8a1b1f65-327e-4a99-9210-c6d9eaf30a03 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,213 | supabase-export-v2 | bab2720512264abe | Using logging in multiple modules ---------------------------------
Multiple calls to ``logging.getLogger('someLogger')`` return a reference to the
same logger object. This is true not only within the same module, but also
across modules as long as it is in the same Python interpreter process. It is
true for references... | trusted_official_docs | CPython Docs | Using logging in multiple modules ---------------------------------
Multiple calls to ``logging.getLogger('someLogger')`` return a reference to the
same logger object. This is true not only within the same module, but also
across modules as long as it is in the same Python interpreter process. It is
true for references... | Using logging in multiple modules ---------------------------------
Multiple calls to ``logging.getLogger('someLogger')`` return a reference to the
same logger object. This is true not only within the same module, but also
across modules as long as it is in the same Python interpreter process. It is
true for references... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8b56fe92-ee73-4059-9a76-980ead75adfd | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,672 | supabase-export-v2 | 84423c8fd1fe64dc | where the function resides. In the above working script, using ``'ext://__main__.owned_file_handler'`` should work. Here, the actual callable is resolved by :func:`dictConfig` from the ``ext://`` specification.
This example hopefully also points the way to how you could implement other
types of file change - e.g. setti... | trusted_official_docs | CPython Docs | where the function resides. In the above working script, using ``'ext://__main__.owned_file_handler'`` should work. Here, the actual callable is resolved by :func:`dictConfig` from the ``ext://`` specification.
This example hopefully also points the way to how you could implement other
types of file change - e.g. setti... | where the function resides. In the above working script, using ``'ext://__main__.owned_file_handler'`` should work. Here, the actual callable is resolved by :func:`dictConfig` from the ``ext://`` specification.
This example hopefully also points the way to how you could implement other
types of file change - e.g. setti... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8d136c5f-5467-4cf7-85ad-a7ba63cd5f66 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,442 | supabase-export-v2 | bd50c88c8729955f | which would be filtered out between processes. # # The size of the rotated files is made small so you can see the results easily.
def listener_configurer():
root = logging.getLogger()
h = logging.handlers.RotatingFileHandler('mptest.log', 'a', 300, 10)
f = logging.Formatter('%(asctime)s %(processName)-10s %(name)s %... | trusted_official_docs | CPython Docs | which would be filtered out between processes. # # The size of the rotated files is made small so you can see the results easily.
def listener_configurer():
root = logging.getLogger()
h = logging.handlers.RotatingFileHandler('mptest.log', 'a', 300, 10)
f = logging.Formatter('%(asctime)s %(processName)-10s %(name)s %... | which would be filtered out between processes. # # The size of the rotated files is made small so you can see the results easily.
def listener_configurer():
root = logging.getLogger()
h = logging.handlers.RotatingFileHandler('mptest.log', 'a', 300, 10)
f = logging.Formatter('%(asctime)s %(processName)-10s %(name)s %... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8f134f53-1a39-49b5-b751-51a1288395b0 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,436 | supabase-export-v2 | 512eb518d68f98ac | in more detail and includes a working socket receiver which can be used as a starting point for you to adapt in your own applications.
You could also write your own handler which uses the :class:`~multiprocessing.Lock`
class from the :mod:`multiprocessing` module to serialize access to the
file from your processes. The... | trusted_official_docs | CPython Docs | in more detail and includes a working socket receiver which can be used as a starting point for you to adapt in your own applications.
You could also write your own handler which uses the :class:`~multiprocessing.Lock`
class from the :mod:`multiprocessing` module to serialize access to the
file from your processes. The... | in more detail and includes a working socket receiver which can be used as a starting point for you to adapt in your own applications.
You could also write your own handler which uses the :class:`~multiprocessing.Lock`
class from the :mod:`multiprocessing` module to serialize access to the
file from your processes. The... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8f42e03b-5ea3-4203-bf37-2aa15e6b71dc | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,846 | supabase-export-v2 | def7874f89a05f83 | import logging import random import sys import time
# Deal with minor differences between different Qt packages
try:
from PySide6 import QtCore, QtGui, QtWidgets
Signal = QtCore.Signal
Slot = QtCore.Slot
except ImportError:
try:
from PyQt6 import QtCore, QtGui, QtWidgets
Signal = QtCore.pyqtSignal
Slot = QtCor... | trusted_official_docs | CPython Docs | import logging import random import sys import time
# Deal with minor differences between different Qt packages
try:
from PySide6 import QtCore, QtGui, QtWidgets
Signal = QtCore.Signal
Slot = QtCore.Slot
except ImportError:
try:
from PyQt6 import QtCore, QtGui, QtWidgets
Signal = QtCore.pyqtSignal
Slot = QtCor... | import logging import random import sys import time
# Deal with minor differences between different Qt packages
try:
from PySide6 import QtCore, QtGui, QtWidgets
Signal = QtCore.Signal
Slot = QtCore.Slot
except ImportError:
try:
from PyQt6 import QtCore, QtGui, QtWidgets
Signal = QtCore.pyqtSignal
Slot = QtCor... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8f6149ed-7bd4-4606-947c-48b3b3752716 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,788 | supabase-export-v2 | 059beda407332483 | ask the manager to close the handler for you on block exit - you could do this if you don't need the handler any more.
To illustrate how it works, we can add the following block of code to the
above:: | trusted_official_docs | CPython Docs | ask the manager to close the handler for you on block exit - you could do this if you don't need the handler any more.
To illustrate how it works, we can add the following block of code to the
above:: | ask the manager to close the handler for you on block exit - you could do this if you don't need the handler any more.
To illustrate how it works, we can add the following block of code to the
above:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
8fa0ff9d-c0c6-4acd-99b2-a049f6fecd3b | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,914 | supabase-export-v2 | 350904f985768210 | class BufferingLoggerWriter(LoggerWriter): def __init__(self, logger, level): super().__init__(logger, level) self.buffer = ''
def write(self, message):
if '\n' not in message:
self.buffer += message
else:
parts = message.split('\n')
if self.buffer:
s = self.buffer + parts.pop(0)
self.logger.log(self.level, s)
... | trusted_official_docs | CPython Docs | class BufferingLoggerWriter(LoggerWriter): def __init__(self, logger, level): super().__init__(logger, level) self.buffer = ''
def write(self, message):
if '\n' not in message:
self.buffer += message
else:
parts = message.split('\n')
if self.buffer:
s = self.buffer + parts.pop(0)
self.logger.log(self.level, s)
... | class BufferingLoggerWriter(LoggerWriter): def __init__(self, logger, level): super().__init__(logger, level) self.buffer = ''
def write(self, message):
if '\n' not in message:
self.buffer += message
else:
parts = message.split('\n')
if self.buffer:
s = self.buffer + parts.pop(0)
self.logger.log(self.level, s)
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9081f906-82a1-4494-b036-27d58be6a846 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,704 | supabase-export-v2 | 8a6bf73d39d1cc96 | if __name__ == '__main__': logging.config.dictConfig(LOGGING) logging.debug('hello') logging.debug('hello - noshow')
This example shows how you can pass configuration data to the callable which
constructs the instance, in the form of keyword parameters. When run, the above
script will print: | trusted_official_docs | CPython Docs | if __name__ == '__main__': logging.config.dictConfig(LOGGING) logging.debug('hello') logging.debug('hello - noshow')
This example shows how you can pass configuration data to the callable which
constructs the instance, in the form of keyword parameters. When run, the above
script will print: | if __name__ == '__main__': logging.config.dictConfig(LOGGING) logging.debug('hello') logging.debug('hello - noshow')
This example shows how you can pass configuration data to the callable which
constructs the instance, in the form of keyword parameters. When run, the above
script will print: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
90d89a1b-8f1b-47b7-befa-d16f3bb3c3a2 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,743 | supabase-export-v2 | 91b4f43c78c307fc | logger = logging.getLogger(__name__) logger.addHandler(logging.NullHandler())
def log_if_errors(logger, target_handler=None, flush_level=None, capacity=None):
if target_handler is None:
target_handler = logging.StreamHandler()
if flush_level is None:
flush_level = logging.ERROR
if capacity is None:
capacity = 100... | trusted_official_docs | CPython Docs | logger = logging.getLogger(__name__) logger.addHandler(logging.NullHandler())
def log_if_errors(logger, target_handler=None, flush_level=None, capacity=None):
if target_handler is None:
target_handler = logging.StreamHandler()
if flush_level is None:
flush_level = logging.ERROR
if capacity is None:
capacity = 100... | logger = logging.getLogger(__name__) logger.addHandler(logging.NullHandler())
def log_if_errors(logger, target_handler=None, flush_level=None, capacity=None):
if target_handler is None:
target_handler = logging.StreamHandler()
if flush_level is None:
flush_level = logging.ERROR
if capacity is None:
capacity = 100... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
91ce62fb-5b18-4dc5-a727-f4023fdf8c4c | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,228 | supabase-export-v2 | 69b724a9b2d04682 | def worker(arg): while not arg['stop']: logging.debug('Hi from myfunc') time.sleep(0.5)
def main():
logging.basicConfig(level=logging.DEBUG, format='%(relativeCreated)6d %(threadName)s %(message)s')
info = {'stop': False}
thread = threading.Thread(target=worker, args=(info,))
thread.start()
while True:
try:
logg... | trusted_official_docs | CPython Docs | def worker(arg): while not arg['stop']: logging.debug('Hi from myfunc') time.sleep(0.5)
def main():
logging.basicConfig(level=logging.DEBUG, format='%(relativeCreated)6d %(threadName)s %(message)s')
info = {'stop': False}
thread = threading.Thread(target=worker, args=(info,))
thread.start()
while True:
try:
logg... | def worker(arg): while not arg['stop']: logging.debug('Hi from myfunc') time.sleep(0.5)
def main():
logging.basicConfig(level=logging.DEBUG, format='%(relativeCreated)6d %(threadName)s %(message)s')
info = {'stop': False}
thread = threading.Thread(target=worker, args=(info,))
thread.start()
while True:
try:
logg... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
920a66b9-0217-4ea8-8297-189f81e29cb2 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,952 | supabase-export-v2 | cf69191869cce521 | altogether. Or a file that was supposed to be moved remains in place, and grows in size unexpectedly despite size-based rotation being supposedly in place.
Use the techniques outlined in :ref:`multiple-processes` to circumvent such
issues. | trusted_official_docs | CPython Docs | altogether. Or a file that was supposed to be moved remains in place, and grows in size unexpectedly despite size-based rotation being supposedly in place.
Use the techniques outlined in :ref:`multiple-processes` to circumvent such
issues. | altogether. Or a file that was supposed to be moved remains in place, and grows in size unexpectedly despite size-based rotation being supposedly in place.
Use the techniques outlined in :ref:`multiple-processes` to circumvent such
issues. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
92280a42-b5ee-4f82-b9fd-da32398f9d0c | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,410 | supabase-export-v2 | bcadcd2d08af5e5b | formatter = logging.Formatter('%(threadName)-11s %(appName)s %(name)-9s %(user)-6s %(ip)s %(method)-4s %(message)s')
# Create our context variables. These will be filled at the start of request
# processing, and used in the logging that happens during that processing | trusted_official_docs | CPython Docs | formatter = logging.Formatter('%(threadName)-11s %(appName)s %(name)-9s %(user)-6s %(ip)s %(method)-4s %(message)s')
# Create our context variables. These will be filled at the start of request
# processing, and used in the logging that happens during that processing | formatter = logging.Formatter('%(threadName)-11s %(appName)s %(name)-9s %(user)-6s %(ip)s %(method)-4s %(message)s')
# Create our context variables. These will be filled at the start of request
# processing, and used in the logging that happens during that processing | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
93286982-6781-4992-b6a8-f875c9a43a03 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,471 | supabase-export-v2 | 8ef9acac8d7909f5 | Using file rotation -------------------
Sometimes you want to let a log file grow to a certain size, then open a new
file and log to that. You may want to keep a certain number of these files, and
when that many files have been created, rotate the files so that the number of
files and the size of the files both remain ... | trusted_official_docs | CPython Docs | Using file rotation -------------------
Sometimes you want to let a log file grow to a certain size, then open a new
file and log to that. You may want to keep a certain number of these files, and
when that many files have been created, rotate the files so that the number of
files and the size of the files both remain ... | Using file rotation -------------------
Sometimes you want to let a log file grow to a certain size, then open a new
file and log to that. You may want to keep a certain number of these files, and
when that many files have been created, rotate the files so that the number of
files and the size of the files both remain ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
94342b9a-30a9-45fd-a9c2-fabf9312c0d0 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,653 | supabase-export-v2 | 0cef19d2ddd5ceba | Customizing handlers with :func:`dictConfig` --------------------------------------------
There are times when you want to customize logging handlers in particular ways,
and if you use :func:`dictConfig` you may be able to do this without
subclassing. As an example, consider that you may want to set the ownership of a
... | trusted_official_docs | CPython Docs | Customizing handlers with :func:`dictConfig` --------------------------------------------
There are times when you want to customize logging handlers in particular ways,
and if you use :func:`dictConfig` you may be able to do this without
subclassing. As an example, consider that you may want to set the ownership of a
... | Customizing handlers with :func:`dictConfig` --------------------------------------------
There are times when you want to customize logging handlers in particular ways,
and if you use :func:`dictConfig` you may be able to do this without
subclassing. As an example, consider that you may want to set the ownership of a
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
947bc1d6-8326-422a-bd44-df45043a34ac | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,401 | supabase-export-v2 | d17449ceb5f7bd0f | # Just a representative event logged from the library logger.debug('Hello from webapplib!') # Just sleep for a bit so other threads get to run time.sleep(0.01)
We can simulate the multiple web applications by means of two simple classes,
``Request`` and ``WebApp``. These simulate how real threaded web applications work... | trusted_official_docs | CPython Docs | # Just a representative event logged from the library logger.debug('Hello from webapplib!') # Just sleep for a bit so other threads get to run time.sleep(0.01)
We can simulate the multiple web applications by means of two simple classes,
``Request`` and ``WebApp``. These simulate how real threaded web applications work... | # Just a representative event logged from the library logger.debug('Hello from webapplib!') # Just sleep for a bit so other threads get to run time.sleep(0.01)
We can simulate the multiple web applications by means of two simple classes,
``Request`` and ``WebApp``. These simulate how real threaded web applications work... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
95040c9a-4629-42c8-97ce-7049dabc3292 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,722 | supabase-export-v2 | 4c5676f4ce81dafa | 07:21:23|INFO|Sample message| 28/01/2015 07:21:23|ERROR|ZeroDivisionError: division by zero|'Traceback (most recent call last):\n File "logtest7.py", line 30, in main\n x = 1 / 0\nZeroDivisionError: division by zero'|
While the above treatment is simplistic, it points the way to how exception
information can be formatt... | trusted_official_docs | CPython Docs | 07:21:23|INFO|Sample message| 28/01/2015 07:21:23|ERROR|ZeroDivisionError: division by zero|'Traceback (most recent call last):\n File "logtest7.py", line 30, in main\n x = 1 / 0\nZeroDivisionError: division by zero'|
While the above treatment is simplistic, it points the way to how exception
information can be formatt... | 07:21:23|INFO|Sample message| 28/01/2015 07:21:23|ERROR|ZeroDivisionError: division by zero|'Traceback (most recent call last):\n File "logtest7.py", line 30, in main\n x = 1 / 0\nZeroDivisionError: division by zero'|
While the above treatment is simplistic, it points the way to how exception
information can be formatt... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
950b05f2-b56e-4be4-8e60-3bf4e9973656 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,458 | supabase-export-v2 | 309b94bc58ec3785 | for wp in workers: wp.join() # And now tell the logging thread to finish up, too q.put(None) lp.join()
This variant shows how you can e.g. apply configuration for particular loggers
- e.g. the ``foo`` logger has a special handler which stores all events in the
``foo`` subsystem in a file ``mplog-foo.log``. This will be... | trusted_official_docs | CPython Docs | for wp in workers: wp.join() # And now tell the logging thread to finish up, too q.put(None) lp.join()
This variant shows how you can e.g. apply configuration for particular loggers
- e.g. the ``foo`` logger has a special handler which stores all events in the
``foo`` subsystem in a file ``mplog-foo.log``. This will be... | for wp in workers: wp.join() # And now tell the logging thread to finish up, too q.put(None) lp.join()
This variant shows how you can e.g. apply configuration for particular loggers
- e.g. the ``foo`` logger has a special handler which stores all events in the
``foo`` subsystem in a file ``mplog-foo.log``. This will be... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
95da8a41-94d4-48f6-8be8-3b35fed9148b | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,313 | supabase-export-v2 | 34851b9ff803f60e | (the main thread) rather than the internal # thread which monitors the internal queue. This is what # you want to happen. root.warning('Look out!') listener.stop()
which, when run, will produce: | trusted_official_docs | CPython Docs | (the main thread) rather than the internal # thread which monitors the internal queue. This is what # you want to happen. root.warning('Look out!') listener.stop()
which, when run, will produce: | (the main thread) rather than the internal # thread which monitors the internal queue. This is what # you want to happen. root.warning('Look out!') listener.stop()
which, when run, will produce: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
962584ba-98e4-4093-be6e-d5640d91f5df | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,679 | supabase-export-v2 | 916548e1a53d53fc | specific loggers, but that approach also runs into backward compatibility problems because any existing code could be using a given logger name and using %-formatting.
For logging to work interoperably between any third-party libraries and your
code, decisions about formatting need to be made at the level of the
indivi... | trusted_official_docs | CPython Docs | specific loggers, but that approach also runs into backward compatibility problems because any existing code could be using a given logger name and using %-formatting.
For logging to work interoperably between any third-party libraries and your
code, decisions about formatting need to be made at the level of the
indivi... | specific loggers, but that approach also runs into backward compatibility problems because any existing code could be using a given logger name and using %-formatting.
For logging to work interoperably between any third-party libraries and your
code, decisions about formatting need to be made at the level of the
indivi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9646254c-3443-44dd-ba76-cb1516434c8e | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,671 | supabase-export-v2 | d7f4fe9f80e6365e | '()': 'ext://project.util.owned_file_handler',
where ``project.util`` can be replaced with the actual name of the package
where the function resides. In the above working script, using
``'ext://__main__.owned_file_handler'`` should work. Here, the actual callable
is resolved by :func:`dictConfig` from the ``ext://`` sp... | trusted_official_docs | CPython Docs | '()': 'ext://project.util.owned_file_handler',
where ``project.util`` can be replaced with the actual name of the package
where the function resides. In the above working script, using
``'ext://__main__.owned_file_handler'`` should work. Here, the actual callable
is resolved by :func:`dictConfig` from the ``ext://`` sp... | '()': 'ext://project.util.owned_file_handler',
where ``project.util`` can be replaced with the actual name of the package
where the function resides. In the above working script, using
``'ext://__main__.owned_file_handler'`` should work. Here, the actual callable
is resolved by :func:`dictConfig` from the ``ext://`` sp... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
96aa9c2c-c155-43a7-bb17-40a7cbfb917f | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,613 | supabase-export-v2 | 071a86188a3ca447 | logger used in the # parent process. This is needed on POSIX because the logger will # be there in the child following a fork().
config_listener = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'detailed': {
'class': 'logging.Formatter',
'format': '%(asctime)s %(name)-15s %(levelname)-8s %(proc... | trusted_official_docs | CPython Docs | logger used in the # parent process. This is needed on POSIX because the logger will # be there in the child following a fork().
config_listener = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'detailed': {
'class': 'logging.Formatter',
'format': '%(asctime)s %(name)-15s %(levelname)-8s %(proc... | logger used in the # parent process. This is needed on POSIX because the logger will # be there in the child following a fork().
config_listener = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'detailed': {
'class': 'logging.Formatter',
'format': '%(asctime)s %(name)-15s %(levelname)-8s %(proc... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9730a1bd-e7a7-4a4f-8d91-7ea73521c0f9 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,701 | supabase-export-v2 | 89ed15231cbad150 | class MyFilter(logging.Filter): def __init__(self, param=None): self.param = param
def filter(self, record):
if self.param is None:
allow = True
else:
allow = self.param not in record.msg
if allow:
record.msg = 'changed: ' + record.msg
return allow | trusted_official_docs | CPython Docs | class MyFilter(logging.Filter): def __init__(self, param=None): self.param = param
def filter(self, record):
if self.param is None:
allow = True
else:
allow = self.param not in record.msg
if allow:
record.msg = 'changed: ' + record.msg
return allow | class MyFilter(logging.Filter): def __init__(self, param=None): self.param = param
def filter(self, record):
if self.param is None:
allow = True
else:
allow = self.param not in record.msg
if allow:
record.msg = 'changed: ' + record.msg
return allow | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
97ea35fb-81f7-4b33-a4f8-f892fee53248 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,503 | supabase-export-v2 | 280488b86cbcccce | .. code-block:: pycon
>>> from wherever import BraceMessage as __
>>> print(__('Message with {0} {name}', 2, name='placeholders'))
Message with 2 placeholders
>>> class Point: pass
... >>> p = Point()
>>> p.x = 0.5
>>> p.y = 0.5
>>> print(__('Message with coordinates: ({point.x:.2f}, {point.y:.2f})',
... point=... | trusted_official_docs | CPython Docs | .. code-block:: pycon
>>> from wherever import BraceMessage as __
>>> print(__('Message with {0} {name}', 2, name='placeholders'))
Message with 2 placeholders
>>> class Point: pass
... >>> p = Point()
>>> p.x = 0.5
>>> p.y = 0.5
>>> print(__('Message with coordinates: ({point.x:.2f}, {point.y:.2f})',
... point=... | .. code-block:: pycon
>>> from wherever import BraceMessage as __
>>> print(__('Message with {0} {name}', 2, name='placeholders'))
Message with 2 placeholders
>>> class Point: pass
... >>> p = Point()
>>> p.x = 0.5
>>> p.y = 0.5
>>> print(__('Message with coordinates: ({point.x:.2f}, {point.y:.2f})',
... point=... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
97f9e1e5-6a2f-4a67-b605-369016b95f84 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,786 | supabase-export-v2 | 0d44fbf1851447dc | def __enter__(self): if self.level is not None: self.old_level = self.logger.level self.logger.setLevel(self.level) if self.handler: self.logger.addHandler(self.handler)
def __exit__(self, et, ev, tb):
if self.level is not None:
self.logger.setLevel(self.old_level)
if self.handler:
self.logger.removeHandler(self.ha... | trusted_official_docs | CPython Docs | def __enter__(self): if self.level is not None: self.old_level = self.logger.level self.logger.setLevel(self.level) if self.handler: self.logger.addHandler(self.handler)
def __exit__(self, et, ev, tb):
if self.level is not None:
self.logger.setLevel(self.old_level)
if self.handler:
self.logger.removeHandler(self.ha... | def __enter__(self): if self.level is not None: self.old_level = self.logger.level self.logger.setLevel(self.level) if self.handler: self.logger.addHandler(self.handler)
def __exit__(self, et, ev, tb):
if self.level is not None:
self.logger.setLevel(self.old_level)
if self.handler:
self.logger.removeHandler(self.ha... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
98df837b-a095-46d8-90a2-e4d871c4b095 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,833 | supabase-export-v2 | 7fb4a7ea1b356e0f | $ python app.py --log-level DEBUG stop foo bar DEBUG stop About to stop 'foo' and 'bar' INFO stop Stopped the 'foo' and 'bar' services.
$ python app.py --log-level DEBUG restart foo bar baz
DEBUG restart About to restart 'foo', 'bar' and 'baz'
INFO restart Restarted the 'foo', 'bar' and 'baz' services. | trusted_official_docs | CPython Docs | $ python app.py --log-level DEBUG stop foo bar DEBUG stop About to stop 'foo' and 'bar' INFO stop Stopped the 'foo' and 'bar' services.
$ python app.py --log-level DEBUG restart foo bar baz
DEBUG restart About to restart 'foo', 'bar' and 'baz'
INFO restart Restarted the 'foo', 'bar' and 'baz' services. | $ python app.py --log-level DEBUG stop foo bar DEBUG stop About to stop 'foo' and 'bar' INFO stop Stopped the 'foo' and 'bar' services.
$ python app.py --log-level DEBUG restart foo bar baz
DEBUG restart About to restart 'foo', 'bar' and 'baz'
INFO restart Restarted the 'foo', 'bar' and 'baz' services. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9a30842c-7dc5-47c5-9ab7-1746c0580a0f | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,610 | supabase-export-v2 | 246bac71b1b7684f | setup logger won't # exist in the child, so it would be created and the message # would appear - hence the "if posix" clause.
logger = logging.getLogger('setup')
logger.critical('Should not appear, because of disabled logger ...')
for i in range(100):
lvl = random.choice(levels)
logger = logging.getLogger(random.ch... | trusted_official_docs | CPython Docs | setup logger won't # exist in the child, so it would be created and the message # would appear - hence the "if posix" clause.
logger = logging.getLogger('setup')
logger.critical('Should not appear, because of disabled logger ...')
for i in range(100):
lvl = random.choice(levels)
logger = logging.getLogger(random.ch... | setup logger won't # exist in the child, so it would be created and the message # would appear - hence the "if posix" clause.
logger = logging.getLogger('setup')
logger.critical('Should not appear, because of disabled logger ...')
for i in range(100):
lvl = random.choice(levels)
logger = logging.getLogger(random.ch... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9a93ac4a-dddd-4d04-8d2e-019d5c40380d | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,356 | supabase-export-v2 | c9372ca8581ba412 | #. Run ``bash ensure_app.sh`` to ensure that Supervisor is running with the above configuration.
#. Run ``venv/bin/python client.py`` to exercise the web application,
which will lead to records being written to the log. | trusted_official_docs | CPython Docs | #. Run ``bash ensure_app.sh`` to ensure that Supervisor is running with the above configuration.
#. Run ``venv/bin/python client.py`` to exercise the web application,
which will lead to records being written to the log. | #. Run ``bash ensure_app.sh`` to ensure that Supervisor is running with the above configuration.
#. Run ``venv/bin/python client.py`` to exercise the web application,
which will lead to records being written to the log. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9b42ec67-ac28-45da-aeaf-d93511ed075b | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,832 | supabase-export-v2 | 8eb11ddd8a668df0 | $ python app.py --log-level DEBUG start foo DEBUG start About to start foo INFO start Started the 'foo' service.
$ python app.py --log-level DEBUG stop foo bar
DEBUG stop About to stop 'foo' and 'bar'
INFO stop Stopped the 'foo' and 'bar' services. | trusted_official_docs | CPython Docs | $ python app.py --log-level DEBUG start foo DEBUG start About to start foo INFO start Started the 'foo' service.
$ python app.py --log-level DEBUG stop foo bar
DEBUG stop About to stop 'foo' and 'bar'
INFO stop Stopped the 'foo' and 'bar' services. | $ python app.py --log-level DEBUG start foo DEBUG start About to start foo INFO start Started the 'foo' service.
$ python app.py --log-level DEBUG stop foo bar
DEBUG stop About to stop 'foo' and 'bar'
INFO stop Stopped the 'foo' and 'bar' services. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9bcc355c-9030-4527-8727-007fd5e8fbc3 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,958 | supabase-export-v2 | 857d916cf5ee598c | Creating a lot of loggers ^^^^^^^^^^^^^^^^^^^^^^^^^
Loggers are singletons that are never freed during a script execution, and so
creating lots of loggers will use up memory which can't then be freed. Rather
than create a logger per e.g. file processed or network connection made, use
the :ref:`existing mechanisms <cont... | trusted_official_docs | CPython Docs | Creating a lot of loggers ^^^^^^^^^^^^^^^^^^^^^^^^^
Loggers are singletons that are never freed during a script execution, and so
creating lots of loggers will use up memory which can't then be freed. Rather
than create a logger per e.g. file processed or network connection made, use
the :ref:`existing mechanisms <cont... | Creating a lot of loggers ^^^^^^^^^^^^^^^^^^^^^^^^^
Loggers are singletons that are never freed during a script execution, and so
creating lots of loggers will use up memory which can't then be freed. Rather
than create a logger per e.g. file processed or network connection made, use
the :ref:`existing mechanisms <cont... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9bcc73fd-b962-4c4b-8938-e218fc814949 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,615 | supabase-export-v2 | 4bf4c251b2d898cb | to finish their work. for wp in workers: wp.join() # Workers all done, listening can now stop. # Logging in the parent still works normally.
logger.info('Telling listener to stop ...')
stop_event.set()
lp.join()
logger.info('All done.') | trusted_official_docs | CPython Docs | to finish their work. for wp in workers: wp.join() # Workers all done, listening can now stop. # Logging in the parent still works normally.
logger.info('Telling listener to stop ...')
stop_event.set()
lp.join()
logger.info('All done.') | to finish their work. for wp in workers: wp.join() # Workers all done, listening can now stop. # Logging in the parent still works normally.
logger.info('Telling listener to stop ...')
stop_event.set()
lp.join()
logger.info('All done.') | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9bef02da-f82e-49f9-a4f1-79c3ff8af5e2 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,726 | supabase-export-v2 | 12f4dd5764a35a3a | example implementation below waits for one message to be spoken before the next is processed, and this might cause other handlers to be kept waiting.
Here is a short example showing
the approach, which assumes that the ``espeak`` TTS package is available:: | trusted_official_docs | CPython Docs | example implementation below waits for one message to be spoken before the next is processed, and this might cause other handlers to be kept waiting.
Here is a short example showing
the approach, which assumes that the ``espeak`` TTS package is available:: | example implementation below waits for one message to be spoken before the next is processed, and this might cause other handlers to be kept waiting.
Here is a short example showing
the approach, which assumes that the ``espeak`` TTS package is available:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9c9a39c5-2717-46a1-8815-d22094d7f09b | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,526 | supabase-export-v2 | 3908f2d540959c5d | and interrogate with :func:`~logging.getLogRecordFactory`. The factory is invoked with the same signature as the :class:`~logging.LogRecord` constructor, as :class:`LogRecord` is the default setting for the factory.
This approach allows a custom factory to control all aspects of LogRecord
creation. For example, you cou... | trusted_official_docs | CPython Docs | and interrogate with :func:`~logging.getLogRecordFactory`. The factory is invoked with the same signature as the :class:`~logging.LogRecord` constructor, as :class:`LogRecord` is the default setting for the factory.
This approach allows a custom factory to control all aspects of LogRecord
creation. For example, you cou... | and interrogate with :func:`~logging.getLogRecordFactory`. The factory is invoked with the same signature as the :class:`~logging.LogRecord` constructor, as :class:`LogRecord` is the default setting for the factory.
This approach allows a custom factory to control all aspects of LogRecord
creation. For example, you cou... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9d3b3abb-f56e-405f-a8e5-751f9f68b7a5 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,319 | supabase-export-v2 | afaac213e4bb5f2e | .. code-block:: python
with QueueListener(que, handler) as listener:
# The queue listener automatically starts
# when the 'with' block is entered. pass
# The queue listener automatically stops once
# the 'with' block is exited. | trusted_official_docs | CPython Docs | .. code-block:: python
with QueueListener(que, handler) as listener:
# The queue listener automatically starts
# when the 'with' block is entered. pass
# The queue listener automatically stops once
# the 'with' block is exited. | .. code-block:: python
with QueueListener(que, handler) as listener:
# The queue listener automatically starts
# when the 'with' block is entered. pass
# The queue listener automatically stops once
# the 'with' block is exited. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9d8e622e-beac-41fe-b1be-904bcada43c6 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,311 | supabase-export-v2 | c876ad61d2695280 | is more resource-friendly than, say, having threaded versions of the existing handler classes, which would eat up one thread per handler for no particular benefit.
An example of using these two classes follows (imports omitted):: | trusted_official_docs | CPython Docs | is more resource-friendly than, say, having threaded versions of the existing handler classes, which would eat up one thread per handler for no particular benefit.
An example of using these two classes follows (imports omitted):: | is more resource-friendly than, say, having threaded versions of the existing handler classes, which would eat up one thread per handler for no particular benefit.
An example of using these two classes follows (imports omitted):: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9dd0ee3a-996e-4530-b32e-207de5439fd7 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,416 | supabase-export-v2 | ea9ba5dd49f85a63 | store the context information into the context vars before doing anything else. """ ctx_request.set(request) ctx_appname.set(self.name) self.num_requests += 1 logger.debug('Request processing started') webapplib.useful() logger.debug('Request processing finished')
def main():
fn = os.path.splitext(os.path.basename(__f... | trusted_official_docs | CPython Docs | store the context information into the context vars before doing anything else. """ ctx_request.set(request) ctx_appname.set(self.name) self.num_requests += 1 logger.debug('Request processing started') webapplib.useful() logger.debug('Request processing finished')
def main():
fn = os.path.splitext(os.path.basename(__f... | store the context information into the context vars before doing anything else. """ ctx_request.set(request) ctx_appname.set(self.name) self.num_requests += 1 logger.debug('Request processing started') webapplib.useful() logger.debug('Request processing finished')
def main():
fn = os.path.splitext(os.path.basename(__f... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9de020c9-3571-4c08-90f3-65c4187cfb70 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,417 | supabase-export-v2 | c9727954e67f401d | request ' 'context can be used to ' 'populate logs') aa = ap.add_argument aa('--count', '-c', type=int, default=100, help='How many requests to simulate') options = ap.parse_args()
# Create the dummy webapps and put them in a list which we can use to select
# from randomly
app1 = WebApp('app1')
app2 = WebApp('app2')... | trusted_official_docs | CPython Docs | request ' 'context can be used to ' 'populate logs') aa = ap.add_argument aa('--count', '-c', type=int, default=100, help='How many requests to simulate') options = ap.parse_args()
# Create the dummy webapps and put them in a list which we can use to select
# from randomly
app1 = WebApp('app1')
app2 = WebApp('app2')... | request ' 'context can be used to ' 'populate logs') aa = ap.add_argument aa('--count', '-c', type=int, default=100, help='How many requests to simulate') options = ap.parse_args()
# Create the dummy webapps and put them in a list which we can use to select
# from randomly
app1 = WebApp('app1')
app2 = WebApp('app2')... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
9eabf614-8158-40f2-b760-806a8cdbe03e | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,224 | supabase-export-v2 | 1353a7a8f644f946 | - calling auxiliary_module.some_function() 2005-03-23 23:47:11,672 - spam_application.auxiliary - INFO - received a call to 'some_function' 2005-03-23 23:47:11,673 - spam_application - INFO - done with auxiliary_module.some_function()
Logging from multiple threads
----------------------------- | trusted_official_docs | CPython Docs | - calling auxiliary_module.some_function() 2005-03-23 23:47:11,672 - spam_application.auxiliary - INFO - received a call to 'some_function' 2005-03-23 23:47:11,673 - spam_application - INFO - done with auxiliary_module.some_function()
Logging from multiple threads
----------------------------- | - calling auxiliary_module.some_function() 2005-03-23 23:47:11,672 - spam_application.auxiliary - INFO - received a call to 'some_function' 2005-03-23 23:47:11,673 - spam_application - INFO - done with auxiliary_module.some_function()
Logging from multiple threads
----------------------------- | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a021b34d-511c-483a-a8d9-a2374ca7d7c4 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,764 | supabase-export-v2 | 03423c0869f045fc | if __name__ == '__main__': import argparse
ap = argparse.ArgumentParser()
aa = ap.add_argument
aa('host', metavar='HOST', help='SMTP server')
aa('--port', '-p', type=int, default=587, help='SMTP port')
aa('user', metavar='USER', help='SMTP username')
aa('password', metavar='PASSWORD', help='SMTP password')
aa('to... | trusted_official_docs | CPython Docs | if __name__ == '__main__': import argparse
ap = argparse.ArgumentParser()
aa = ap.add_argument
aa('host', metavar='HOST', help='SMTP server')
aa('--port', '-p', type=int, default=587, help='SMTP port')
aa('user', metavar='USER', help='SMTP username')
aa('password', metavar='PASSWORD', help='SMTP password')
aa('to... | if __name__ == '__main__': import argparse
ap = argparse.ArgumentParser()
aa = ap.add_argument
aa('host', metavar='HOST', help='SMTP server')
aa('--port', '-p', type=int, default=587, help='SMTP port')
aa('user', metavar='USER', help='SMTP username')
aa('password', metavar='PASSWORD', help='SMTP password')
aa('to... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a0f2fe6e-1dfd-474c-a016-8fb9eac5da38 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,345 | supabase-export-v2 | 0c75eaf3e273c341 | quickly daft jumping zebras vex. 69 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 69 myapp.area2 ERROR The five boxing wizards jump quickly.
Note that there are some security issues with pickle in some scenarios. If
these affect you, you can use an alternative serialization scheme by overriding
the :... | trusted_official_docs | CPython Docs | quickly daft jumping zebras vex. 69 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 69 myapp.area2 ERROR The five boxing wizards jump quickly.
Note that there are some security issues with pickle in some scenarios. If
these affect you, you can use an alternative serialization scheme by overriding
the :... | quickly daft jumping zebras vex. 69 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 69 myapp.area2 ERROR The five boxing wizards jump quickly.
Note that there are some security issues with pickle in some scenarios. If
these affect you, you can use an alternative serialization scheme by overriding
the :... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a1850975-3441-4101-add5-757c8c70be2e | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,829 | supabase-export-v2 | 491c4b73e55ce7df | The first word is the logging level, and the second word is the module or package name of the place where the event was logged.
If we change the logging level, then we can change the information sent to the
log. For example, if we want more information: | trusted_official_docs | CPython Docs | The first word is the logging level, and the second word is the module or package name of the place where the event was logged.
If we change the logging level, then we can change the information sent to the
log. For example, if we want more information: | The first word is the logging level, and the second word is the module or package name of the place where the event was logged.
If we change the logging level, then we can change the information sent to the
log. For example, if we want more information: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a1b63a32-d3f4-4f76-9271-6e42d2843287 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,878 | supabase-export-v2 | 4608bc7ca8696368 | def __init__(self, *args, **kwargs): self.msgid = kwargs.pop('msgid', None) self.appname = kwargs.pop('appname', None) super().__init__(*args, **kwargs)
def format(self, record):
version = 1
asctime = dt.datetime.fromtimestamp(record.created).isoformat()
m = self.tz_offset.prefixmatch(time.strftime('%z'))
has_offse... | trusted_official_docs | CPython Docs | def __init__(self, *args, **kwargs): self.msgid = kwargs.pop('msgid', None) self.appname = kwargs.pop('appname', None) super().__init__(*args, **kwargs)
def format(self, record):
version = 1
asctime = dt.datetime.fromtimestamp(record.created).isoformat()
m = self.tz_offset.prefixmatch(time.strftime('%z'))
has_offse... | def __init__(self, *args, **kwargs): self.msgid = kwargs.pop('msgid', None) self.appname = kwargs.pop('appname', None) super().__init__(*args, **kwargs)
def format(self, record):
version = 1
asctime = dt.datetime.fromtimestamp(record.created).isoformat()
m = self.tz_offset.prefixmatch(time.strftime('%z'))
has_offse... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a24cd664-ad6d-4d51-a421-8e22617bf9c9 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,657 | supabase-export-v2 | 4f7e40121cf5bf95 | level and # its formatter. '()': owned_file_handler, 'level':'DEBUG', 'formatter': 'default', # The values below are passed to the handler creator callable # as keyword arguments.
'owner': ['pulse', 'pulse'],
'filename': 'chowntest.log',
'mode': 'w',
'encoding': 'utf-8',
},
},
'root': {
'handlers': ['file'],
'l... | trusted_official_docs | CPython Docs | level and # its formatter. '()': owned_file_handler, 'level':'DEBUG', 'formatter': 'default', # The values below are passed to the handler creator callable # as keyword arguments.
'owner': ['pulse', 'pulse'],
'filename': 'chowntest.log',
'mode': 'w',
'encoding': 'utf-8',
},
},
'root': {
'handlers': ['file'],
'l... | level and # its formatter. '()': owned_file_handler, 'level':'DEBUG', 'formatter': 'default', # The values below are passed to the handler creator callable # as keyword arguments.
'owner': ['pulse', 'pulse'],
'filename': 'chowntest.log',
'mode': 'w',
'encoding': 'utf-8',
},
},
'root': {
'handlers': ['file'],
'l... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a2dc199c-a2cc-4c2e-83a1-2e17bd8a42c9 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,818 | supabase-export-v2 | 6bf3dd44e2647853 | logger = logging.getLogger(__name__)
def command(options):
n = len(options.names)
if n == 1:
plural = ''
services = '\'%s\'' % options.names[0]
else:
plural = 's'
services = ', '.join('\'%s\'' % name for name in options.names)
i = services.rfind(', ')
services = services[:i] + ' and ' + services[i + 2:]
logge... | trusted_official_docs | CPython Docs | logger = logging.getLogger(__name__)
def command(options):
n = len(options.names)
if n == 1:
plural = ''
services = '\'%s\'' % options.names[0]
else:
plural = 's'
services = ', '.join('\'%s\'' % name for name in options.names)
i = services.rfind(', ')
services = services[:i] + ' and ' + services[i + 2:]
logge... | logger = logging.getLogger(__name__)
def command(options):
n = len(options.names)
if n == 1:
plural = ''
services = '\'%s\'' % options.names[0]
else:
plural = 's'
services = ', '.join('\'%s\'' % name for name in options.names)
i = services.rfind(', ')
services = services[:i] + ' and ' + services[i + 2:]
logge... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a3ab25dd-f29f-4398-9278-ac09c19742ff | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,790 | supabase-export-v2 | 0a753d4eeb8ae8fc | This should appear twice - once on stderr and once on stdout.') logger.info('6. This should appear just once on stderr.') logger.debug('7. This should not appear.')
We initially set the logger's level to ``INFO``, so message #1 appears and
message #2 doesn't. We then change the level to ``DEBUG`` temporarily in the
fol... | trusted_official_docs | CPython Docs | This should appear twice - once on stderr and once on stdout.') logger.info('6. This should appear just once on stderr.') logger.debug('7. This should not appear.')
We initially set the logger's level to ``INFO``, so message #1 appears and
message #2 doesn't. We then change the level to ``DEBUG`` temporarily in the
fol... | This should appear twice - once on stderr and once on stdout.') logger.info('6. This should appear just once on stderr.') logger.debug('7. This should not appear.')
We initially set the logger's level to ``INFO``, so message #1 appears and
message #2 doesn't. We then change the level to ``DEBUG`` temporarily in the
fol... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a3fcb6c0-675c-4dff-9c3a-1a5f53fa4d74 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,855 | supabase-export-v2 | 33659b4f7e7222d1 | else: level = random.choice(LEVELS) logger.log(level, 'Message after delay of %3.1f: %d', delay, i, extra=extra) except ValueError as e: logger.exception('Failed: %s', e, extra=extra) i += 1
#
# Implement a simple UI for this cookbook example. This contains:
#
# * A read-only text edit window which holds formatted l... | trusted_official_docs | CPython Docs | else: level = random.choice(LEVELS) logger.log(level, 'Message after delay of %3.1f: %d', delay, i, extra=extra) except ValueError as e: logger.exception('Failed: %s', e, extra=extra) i += 1
#
# Implement a simple UI for this cookbook example. This contains:
#
# * A read-only text edit window which holds formatted l... | else: level = random.choice(LEVELS) logger.log(level, 'Message after delay of %3.1f: %d', delay, i, extra=extra) except ValueError as e: logger.exception('Failed: %s', e, extra=extra) i += 1
#
# Implement a simple UI for this cookbook example. This contains:
#
# * A read-only text edit window which holds formatted l... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a503b51b-b8e3-467e-92ef-c9c57fa00ddd | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,703 | supabase-export-v2 | 67d27d001ca23ffe | { '()': MyFilter, 'param': 'noshow', } }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'filters': ['myfilter'] } }, 'root': { 'level': 'DEBUG', 'handlers': ['console'] }, }
if __name__ == '__main__':
logging.config.dictConfig(LOGGING)
logging.debug('hello')
logging.debug('hello - noshow') | trusted_official_docs | CPython Docs | { '()': MyFilter, 'param': 'noshow', } }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'filters': ['myfilter'] } }, 'root': { 'level': 'DEBUG', 'handlers': ['console'] }, }
if __name__ == '__main__':
logging.config.dictConfig(LOGGING)
logging.debug('hello')
logging.debug('hello - noshow') | { '()': MyFilter, 'param': 'noshow', } }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'filters': ['myfilter'] } }, 'root': { 'level': 'DEBUG', 'handlers': ['console'] }, }
if __name__ == '__main__':
logging.config.dictConfig(LOGGING)
logging.debug('hello')
logging.debug('hello - noshow') | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a68ce0fc-6c8c-4495-893e-df9a6a263e41 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,865 | supabase-export-v2 | d5d1bbba1b976b6e | def force_quit(self): # For use when the window is closed if self.worker_thread.isRunning(): self.kill_thread()
# The functions below update the UI and run in the main thread because
# that's where the slots are set up | trusted_official_docs | CPython Docs | def force_quit(self): # For use when the window is closed if self.worker_thread.isRunning(): self.kill_thread()
# The functions below update the UI and run in the main thread because
# that's where the slots are set up | def force_quit(self): # For use when the window is closed if self.worker_thread.isRunning(): self.kill_thread()
# The functions below update the UI and run in the main thread because
# that's where the slots are set up | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a7c014b3-18db-4e30-bd19-cde64e85a3e9 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,794 | supabase-export-v2 | 26b2884c9d1e1706 | and once on stdout. 5. This should appear twice - once on stderr and once on stdout. 6. This should appear just once on stderr.
If we run it again, but pipe ``stderr`` to ``/dev/null``, we see the following,
which is the only message written to ``stdout``: | trusted_official_docs | CPython Docs | and once on stdout. 5. This should appear twice - once on stderr and once on stdout. 6. This should appear just once on stderr.
If we run it again, but pipe ``stderr`` to ``/dev/null``, we see the following,
which is the only message written to ``stdout``: | and once on stdout. 5. This should appear twice - once on stderr and once on stdout. 6. This should appear just once on stderr.
If we run it again, but pipe ``stderr`` to ``/dev/null``, we see the following,
which is the only message written to ``stdout``: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a8466bfb-9796-4cf1-8bd6-1b7bd4dcb95a | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,405 | supabase-export-v2 | 222abaf39f2e8b19 | logger = logging.getLogger(__name__) root = logging.getLogger() root.setLevel(logging.DEBUG)
class Request:
"""
A simple dummy request class which just holds dummy HTTP request method,
client IP address and client username
"""
def __init__(self, method, ip, user):
self.method = method
self.ip = ip
self.user = u... | trusted_official_docs | CPython Docs | logger = logging.getLogger(__name__) root = logging.getLogger() root.setLevel(logging.DEBUG)
class Request:
"""
A simple dummy request class which just holds dummy HTTP request method,
client IP address and client username
"""
def __init__(self, method, ip, user):
self.method = method
self.ip = ip
self.user = u... | logger = logging.getLogger(__name__) root = logging.getLogger() root.setLevel(logging.DEBUG)
class Request:
"""
A simple dummy request class which just holds dummy HTTP request method,
client IP address and client username
"""
def __init__(self, method, ip, user):
self.method = method
self.ip = ip
self.user = u... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a90175f8-51c7-4715-8532-d1e52e152565 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,238 | supabase-export-v2 | 0e2ffa10293daf89 | and add it to the handlers formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') ch.setFormatter(formatter) fh.setFormatter(formatter) # add the handlers to logger logger.addHandler(ch) logger.addHandler(fh)
# 'application' code
logger.debug('debug message')
logger.info('info message')... | trusted_official_docs | CPython Docs | and add it to the handlers formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') ch.setFormatter(formatter) fh.setFormatter(formatter) # add the handlers to logger logger.addHandler(ch) logger.addHandler(fh)
# 'application' code
logger.debug('debug message')
logger.info('info message')... | and add it to the handlers formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') ch.setFormatter(formatter) fh.setFormatter(formatter) # add the handlers to logger logger.addHandler(ch) logger.addHandler(fh)
# 'application' code
logger.debug('debug message')
logger.info('info message')... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
a971fb6e-898a-44fb-8426-550fd21593d8 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,494 | supabase-export-v2 | b221fcacfca5d7d0 | >>> logger.error('This is an%s %s %s', 'other,', 'ERROR,', 'message') 2010-10-28 15:19:29,833 foo.bar ERROR This is another, ERROR, message >>>
Logging calls (``logger.debug()``, ``logger.info()`` etc.) only take
positional parameters for the actual logging message itself, with keyword
parameters used only for determin... | trusted_official_docs | CPython Docs | >>> logger.error('This is an%s %s %s', 'other,', 'ERROR,', 'message') 2010-10-28 15:19:29,833 foo.bar ERROR This is another, ERROR, message >>>
Logging calls (``logger.debug()``, ``logger.info()`` etc.) only take
positional parameters for the actual logging message itself, with keyword
parameters used only for determin... | >>> logger.error('This is an%s %s %s', 'other,', 'ERROR,', 'message') 2010-10-28 15:19:29,833 foo.bar ERROR This is another, ERROR, message >>>
Logging calls (``logger.debug()``, ``logger.info()`` etc.) only take
positional parameters for the actual logging message itself, with keyword
parameters used only for determin... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
aa07ee3c-2594-4eaa-a410-bba62a523d88 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,772 | supabase-export-v2 | c70065c3ce6d18f4 | of :class:`~logging.Formatter`. If you want to do that via configuration, you can use the :func:`~logging.config.dictConfig` API with an approach illustrated by the following complete example::
import logging
import logging.config
import time | trusted_official_docs | CPython Docs | of :class:`~logging.Formatter`. If you want to do that via configuration, you can use the :func:`~logging.config.dictConfig` API with an approach illustrated by the following complete example::
import logging
import logging.config
import time | of :class:`~logging.Formatter`. If you want to do that via configuration, you can use the :func:`~logging.config.dictConfig` API with an approach illustrated by the following complete example::
import logging
import logging.config
import time | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
aa096821-77df-4a8c-a9a5-ad397a40b377 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,348 | supabase-export-v2 | ad61f7b426a85317 | .. _socket-listener-gist: https://gist.github.com/vsajip/4b227eeec43817465ca835ca66f75e2b
To run a logging listener in production, you may need to use a
process-management tool such as `Supervisor <http://supervisord.org/>`_. `Here is a Gist <socket-listener-gist_>`__
which provides the bare-bones files to run the abov... | trusted_official_docs | CPython Docs | .. _socket-listener-gist: https://gist.github.com/vsajip/4b227eeec43817465ca835ca66f75e2b
To run a logging listener in production, you may need to use a
process-management tool such as `Supervisor <http://supervisord.org/>`_. `Here is a Gist <socket-listener-gist_>`__
which provides the bare-bones files to run the abov... | .. _socket-listener-gist: https://gist.github.com/vsajip/4b227eeec43817465ca835ca66f75e2b
To run a logging listener in production, you may need to use a
process-management tool such as `Supervisor <http://supervisord.org/>`_. `Here is a Gist <socket-listener-gist_>`__
which provides the bare-bones files to run the abov... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
aa122dfe-90e6-4229-a61f-d0b41661a492 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,782 | supabase-export-v2 | 64978450f63a1c7c | Using a context manager for selective logging ---------------------------------------------
There are times when it would be useful to temporarily change the logging
configuration and revert it back after doing something. For this, a context
manager is the most obvious way of saving and restoring the logging context. H... | trusted_official_docs | CPython Docs | Using a context manager for selective logging ---------------------------------------------
There are times when it would be useful to temporarily change the logging
configuration and revert it back after doing something. For this, a context
manager is the most obvious way of saving and restoring the logging context. H... | Using a context manager for selective logging ---------------------------------------------
There are times when it would be useful to temporarily change the logging
configuration and revert it back after doing something. For this, a context
manager is the most obvious way of saving and restoring the logging context. H... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
aa386ef0-84b4-47e4-9c8b-92b20563e126 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,257 | supabase-export-v2 | 13a89f183694f9c7 | As you can see, the DEBUG message only shows up in the file. The other messages are sent to both destinations.
This example uses console and file handlers, but you can use any number and
combination of handlers you choose. | trusted_official_docs | CPython Docs | As you can see, the DEBUG message only shows up in the file. The other messages are sent to both destinations.
This example uses console and file handlers, but you can use any number and
combination of handlers you choose. | As you can see, the DEBUG message only shows up in the file. The other messages are sent to both destinations.
This example uses console and file handlers, but you can use any number and
combination of handlers you choose. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
aa3af873-a215-4b98-9c5c-80a7fdb65823 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,438 | supabase-export-v2 | 03ac86a4f346051c | .. currentmodule:: logging.handlers
Alternatively, you can use a ``Queue`` and a :class:`QueueHandler` to send
all logging events to one of the processes in your multi-process application. The following example script demonstrates how you can do this; in the example
a separate listener process listens for events sent b... | trusted_official_docs | CPython Docs | .. currentmodule:: logging.handlers
Alternatively, you can use a ``Queue`` and a :class:`QueueHandler` to send
all logging events to one of the processes in your multi-process application. The following example script demonstrates how you can do this; in the example
a separate listener process listens for events sent b... | .. currentmodule:: logging.handlers
Alternatively, you can use a ``Queue`` and a :class:`QueueHandler` to send
all logging events to one of the processes in your multi-process application. The following example script demonstrates how you can do this; in the example
a separate listener process listens for events sent b... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ab4da5e9-e461-4543-be2f-319c9de77466 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,558 | supabase-export-v2 | 5b26c4202ca060ee | class NNGSocketListener(logging.handlers.QueueListener):
def __init__(self, uri, /, *handlers, **kwargs):
# Have a timeout for interruptability, and open a
# subscriber socket
socket = pynng.Sub0(listen=uri, recv_timeout=500)
# The b'' subscription matches all topics
topics = kwargs.pop('topics', None) or b''
soc... | trusted_official_docs | CPython Docs | class NNGSocketListener(logging.handlers.QueueListener):
def __init__(self, uri, /, *handlers, **kwargs):
# Have a timeout for interruptability, and open a
# subscriber socket
socket = pynng.Sub0(listen=uri, recv_timeout=500)
# The b'' subscription matches all topics
topics = kwargs.pop('topics', None) or b''
soc... | class NNGSocketListener(logging.handlers.QueueListener):
def __init__(self, uri, /, *handlers, **kwargs):
# Have a timeout for interruptability, and open a
# subscriber socket
socket = pynng.Sub0(listen=uri, recv_timeout=500)
# The b'' subscription matches all topics
topics = kwargs.pop('topics', None) or b''
soc... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ab5b449e-fa2f-4716-8f12-296b762b8614 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,638 | supabase-export-v2 | 3862a0b38682d0ce | Note that the order of items might be different according to the version of Python used.
If you need more specialised processing, you can use a custom JSON encoder,
as in the following complete example:: | trusted_official_docs | CPython Docs | Note that the order of items might be different according to the version of Python used.
If you need more specialised processing, you can use a custom JSON encoder,
as in the following complete example:: | Note that the order of items might be different according to the version of Python used.
If you need more specialised processing, you can use a custom JSON encoder,
as in the following complete example:: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ac104c82-e6fb-4ddf-b68a-0b2e86bfb8b4 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,351 | supabase-export-v2 | 8bcd1d71fbe33f13 | setup shows how the workers can write to the same log file without conflicting with one another --- they all go through the socket listener.
To test these files, do the following in a POSIX environment: | trusted_official_docs | CPython Docs | setup shows how the workers can write to the same log file without conflicting with one another --- they all go through the socket listener.
To test these files, do the following in a POSIX environment: | setup shows how the workers can write to the same log file without conflicting with one another --- they all go through the socket listener.
To test these files, do the following in a POSIX environment: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ac853343-e2c3-43a9-93d5-4aa06fd5d54c | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,915 | supabase-export-v2 | 761f545afb8bd2b6 | self.buffer += message else: parts = message.split('\n') if self.buffer: s = self.buffer + parts.pop(0) self.logger.log(self.level, s) self.buffer = parts.pop() for part in parts: self.logger.log(self.level, part)
This just buffers up stuff until a newline is seen, and then logs complete
lines. With this approach, you ... | trusted_official_docs | CPython Docs | self.buffer += message else: parts = message.split('\n') if self.buffer: s = self.buffer + parts.pop(0) self.logger.log(self.level, s) self.buffer = parts.pop() for part in parts: self.logger.log(self.level, part)
This just buffers up stuff until a newline is seen, and then logs complete
lines. With this approach, you ... | self.buffer += message else: parts = message.split('\n') if self.buffer: s = self.buffer + parts.pop(0) self.logger.log(self.level, s) self.buffer = parts.pop() for part in parts: self.logger.log(self.level, part)
This just buffers up stuff until a newline is seen, and then logs complete
lines. With this approach, you ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ae3abf44-e8f7-4328-b4f2-10a57c62bff7 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,240 | supabase-export-v2 | a78aa8329e318215 | Notice that the 'application' code does not care about multiple handlers. All that changed was the addition and configuration of a new handler named *fh*.
The ability to create new handlers with higher- or lower-severity filters can be
very helpful when writing and testing an application. Instead of using many
``print`... | trusted_official_docs | CPython Docs | Notice that the 'application' code does not care about multiple handlers. All that changed was the addition and configuration of a new handler named *fh*.
The ability to create new handlers with higher- or lower-severity filters can be
very helpful when writing and testing an application. Instead of using many
``print`... | Notice that the 'application' code does not care about multiple handlers. All that changed was the addition and configuration of a new handler named *fh*.
The ability to create new handlers with higher- or lower-severity filters can be
very helpful when writing and testing an application. Instead of using many
``print`... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
ae789d0b-73a9-4573-aba8-061240084218 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,256 | supabase-export-v2 | d42f48fa2fe78d16 | jumping zebras vex. 10-22 22:19 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 10-22 22:19 myapp.area2 ERROR The five boxing wizards jump quickly.
As you can see, the DEBUG message only shows up in the file. The other messages
are sent to both destinations. | trusted_official_docs | CPython Docs | jumping zebras vex. 10-22 22:19 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 10-22 22:19 myapp.area2 ERROR The five boxing wizards jump quickly.
As you can see, the DEBUG message only shows up in the file. The other messages
are sent to both destinations. | jumping zebras vex. 10-22 22:19 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 10-22 22:19 myapp.area2 ERROR The five boxing wizards jump quickly.
As you can see, the DEBUG message only shows up in the file. The other messages
are sent to both destinations. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b0adfa87-7d00-4eec-97e6-568b9b87d159 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,851 | supabase-export-v2 | d4677a4417d250ee | def emit(self, record): s = self.format(record) self.signaller.signal.emit(s, record)
#
# This example uses QThreads, which means that the threads at the Python level
# are named something like "Dummy-1". The function below gets the Qt name of the
# current thread. #
def ctname():
return QtCore.QThread.currentThre... | trusted_official_docs | CPython Docs | def emit(self, record): s = self.format(record) self.signaller.signal.emit(s, record)
#
# This example uses QThreads, which means that the threads at the Python level
# are named something like "Dummy-1". The function below gets the Qt name of the
# current thread. #
def ctname():
return QtCore.QThread.currentThre... | def emit(self, record): s = self.format(record) self.signaller.signal.emit(s, record)
#
# This example uses QThreads, which means that the threads at the Python level
# are named something like "Dummy-1". The function below gets the Qt name of the
# current thread. #
def ctname():
return QtCore.QThread.currentThre... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b180901c-e684-4d56-8af8-9d64bceed5da | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,371 | supabase-export-v2 | b7c8a5b909f1deff | passed to the constructor. Of course, if you had passed an 'extra' keyword argument in the call to the adapter, it will be silently overwritten.
The advantage of using 'extra' is that the values in the dict-like object are
merged into the :class:`LogRecord` instance's __dict__, allowing you to use
customized strings wi... | trusted_official_docs | CPython Docs | passed to the constructor. Of course, if you had passed an 'extra' keyword argument in the call to the adapter, it will be silently overwritten.
The advantage of using 'extra' is that the values in the dict-like object are
merged into the :class:`LogRecord` instance's __dict__, allowing you to use
customized strings wi... | passed to the constructor. Of course, if you had passed an 'extra' keyword argument in the call to the adapter, it will be silently overwritten.
The advantage of using 'extra' is that the values in the dict-like object are
merged into the :class:`LogRecord` instance's __dict__, allowing you to use
customized strings wi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b1c37c47-f628-4919-866d-7bb71dac8d57 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,239 | supabase-export-v2 | cefe2a6243eb3100 | # 'application' code logger.debug('debug message') logger.info('info message') logger.warning('warn message') logger.error('error message') logger.critical('critical message')
Notice that the 'application' code does not care about multiple handlers. All
that changed was the addition and configuration of a new handler n... | trusted_official_docs | CPython Docs | # 'application' code logger.debug('debug message') logger.info('info message') logger.warning('warn message') logger.error('error message') logger.critical('critical message')
Notice that the 'application' code does not care about multiple handlers. All
that changed was the addition and configuration of a new handler n... | # 'application' code logger.debug('debug message') logger.info('info message') logger.warning('warn message') logger.error('error message') logger.critical('critical message')
Notice that the 'application' code does not care about multiple handlers. All
that changed was the addition and configuration of a new handler n... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b204feee-3416-4094-a21a-6241dc6f89e1 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,520 | supabase-export-v2 | a082b3f40a17398d | This has usually meant that if you need to do anything special with a :class:`LogRecord`, you've had to do one of the following.
* Create your own :class:`Logger` subclass, which overrides
:meth:`Logger.makeRecord`, and set it using :func:`~logging.setLoggerClass`
before any loggers that you care about are instantiat... | trusted_official_docs | CPython Docs | This has usually meant that if you need to do anything special with a :class:`LogRecord`, you've had to do one of the following.
* Create your own :class:`Logger` subclass, which overrides
:meth:`Logger.makeRecord`, and set it using :func:`~logging.setLoggerClass`
before any loggers that you care about are instantiat... | This has usually meant that if you need to do anything special with a :class:`LogRecord`, you've had to do one of the following.
* Create your own :class:`Logger` subclass, which overrides
:meth:`Logger.makeRecord`, and set it using :func:`~logging.setLoggerClass`
before any loggers that you care about are instantiat... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b2fa1064-a378-491a-b3c1-173c9de806be | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,659 | supabase-export-v2 | 3018bc8490b5acfa | I am setting the ownership using the ``pulse`` user and group, just for the purposes of illustration. Putting it together into a working script, ``chowntest.py``::
import logging, logging.config, os, shutil | trusted_official_docs | CPython Docs | I am setting the ownership using the ``pulse`` user and group, just for the purposes of illustration. Putting it together into a working script, ``chowntest.py``::
import logging, logging.config, os, shutil | I am setting the ownership using the ``pulse`` user and group, just for the purposes of illustration. Putting it together into a working script, ``chowntest.py``::
import logging, logging.config, os, shutil | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b3000db1-0b5a-40cd-9a42-49fc23b18072 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,344 | supabase-export-v2 | 91fdccd3a7f23ea8 | .. code-block:: none
About to start TCP server... 59 root INFO Jackdaws love my big sphinx of quartz. 59 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim. 69 myapp.area1 INFO How quickly daft jumping zebras vex. 69 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 69 myapp.area2 ERROR The five boxin... | trusted_official_docs | CPython Docs | .. code-block:: none
About to start TCP server... 59 root INFO Jackdaws love my big sphinx of quartz. 59 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim. 69 myapp.area1 INFO How quickly daft jumping zebras vex. 69 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 69 myapp.area2 ERROR The five boxin... | .. code-block:: none
About to start TCP server... 59 root INFO Jackdaws love my big sphinx of quartz. 59 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim. 69 myapp.area1 INFO How quickly daft jumping zebras vex. 69 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 69 myapp.area2 ERROR The five boxin... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b317e25b-7845-4420-86b2-f28faf6800fb | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,572 | supabase-export-v2 | 3c25e7bc27972ffc | log away level = random.choice(levels) logger = logging.getLogger(random.choice(logger_names)) logger.log(level, 'Message no. %5d' % msgno) msgno += 1 delay = random.random() * 2 + 0.5 time.sleep(delay)
You can run the above two snippets in separate command shells. If we run the
listener in one shell and run the sender... | trusted_official_docs | CPython Docs | log away level = random.choice(levels) logger = logging.getLogger(random.choice(logger_names)) logger.log(level, 'Message no. %5d' % msgno) msgno += 1 delay = random.random() * 2 + 0.5 time.sleep(delay)
You can run the above two snippets in separate command shells. If we run the
listener in one shell and run the sender... | log away level = random.choice(levels) logger = logging.getLogger(random.choice(logger_names)) logger.log(level, 'Message no. %5d' % msgno) msgno += 1 delay = random.random() * 2 + 0.5 time.sleep(delay)
You can run the above two snippets in separate command shells. If we run the
listener in one shell and run the sender... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b48c2c3c-3c97-40e3-8eb9-45c77151b69c | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,483 | supabase-export-v2 | a06594e0d9d2ae03 | logging_rotatingfile_example.out logging_rotatingfile_example.out.1 logging_rotatingfile_example.out.2 logging_rotatingfile_example.out.3 logging_rotatingfile_example.out.4 logging_rotatingfile_example.out.5
The most current file is always :file:`logging_rotatingfile_example.out`,
and each time it reaches the size limi... | trusted_official_docs | CPython Docs | logging_rotatingfile_example.out logging_rotatingfile_example.out.1 logging_rotatingfile_example.out.2 logging_rotatingfile_example.out.3 logging_rotatingfile_example.out.4 logging_rotatingfile_example.out.5
The most current file is always :file:`logging_rotatingfile_example.out`,
and each time it reaches the size limi... | logging_rotatingfile_example.out logging_rotatingfile_example.out.1 logging_rotatingfile_example.out.2 logging_rotatingfile_example.out.3 logging_rotatingfile_example.out.4 logging_rotatingfile_example.out.5
The most current file is always :file:`logging_rotatingfile_example.out`,
and each time it reaches the size limi... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b4b806bd-ea0a-4b60-9ecc-1b90d54610cc | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,678 | supabase-export-v2 | b7193b608f9b7f92 | would be no changing this while preserving backward compatibility, since all logging calls which are out there in existing code will be using %-format strings.
There have been suggestions to associate format styles with specific loggers,
but that approach also runs into backward compatibility problems because any
exist... | trusted_official_docs | CPython Docs | would be no changing this while preserving backward compatibility, since all logging calls which are out there in existing code will be using %-format strings.
There have been suggestions to associate format styles with specific loggers,
but that approach also runs into backward compatibility problems because any
exist... | would be no changing this while preserving backward compatibility, since all logging calls which are out there in existing code will be using %-format strings.
There have been suggestions to associate format styles with specific loggers,
but that approach also runs into backward compatibility problems because any
exist... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b5c2a628-595a-43f4-b491-a7c5fb91d42c | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,278 | supabase-export-v2 | 6578f828b180ecbc | will be ``__main__`` - hence the ``__main__.filter_maker`` in the filter configuration. You will need to change that if you define it in a different module.
With the filter added, we can run ``main.py``, which in full is: | trusted_official_docs | CPython Docs | will be ``__main__`` - hence the ``__main__.filter_maker`` in the filter configuration. You will need to change that if you define it in a different module.
With the filter added, we can run ``main.py``, which in full is: | will be ``__main__`` - hence the ``__main__.filter_maker`` in the filter configuration. You will need to change that if you define it in a different module.
With the filter added, we can run ``main.py``, which in full is: | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b5f25d87-a70d-4155-ab41-de6c54ec1081 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,775 | supabase-export-v2 | 7ebd9cff3f98580f | }, 'handlers': { 'console1': { 'class': 'logging.StreamHandler', 'formatter': 'utc', }, 'console2': { 'class': 'logging.StreamHandler', 'formatter': 'local', }, }, 'root': { 'handlers': ['console1', 'console2'], } }
if __name__ == '__main__':
logging.config.dictConfig(LOGGING)
logging.warning('The local time is %s', ... | trusted_official_docs | CPython Docs | }, 'handlers': { 'console1': { 'class': 'logging.StreamHandler', 'formatter': 'utc', }, 'console2': { 'class': 'logging.StreamHandler', 'formatter': 'local', }, }, 'root': { 'handlers': ['console1', 'console2'], } }
if __name__ == '__main__':
logging.config.dictConfig(LOGGING)
logging.warning('The local time is %s', ... | }, 'handlers': { 'console1': { 'class': 'logging.StreamHandler', 'formatter': 'utc', }, 'console2': { 'class': 'logging.StreamHandler', 'formatter': 'local', }, }, 'root': { 'handlers': ['console1', 'console2'], } }
if __name__ == '__main__':
logging.config.dictConfig(LOGGING)
logging.warning('The local time is %s', ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b789a1a5-1748-454d-9078-e6f6be2e69e5 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,495 | supabase-export-v2 | 014a6169dbe61375 | would be no changing this while preserving backward compatibility, since all logging calls which are out there in existing code will be using %-format strings.
There is, however, a way that you can use {}- and $- formatting to construct
your individual log messages. Recall that for a message you can use an
arbitrary ob... | trusted_official_docs | CPython Docs | would be no changing this while preserving backward compatibility, since all logging calls which are out there in existing code will be using %-format strings.
There is, however, a way that you can use {}- and $- formatting to construct
your individual log messages. Recall that for a message you can use an
arbitrary ob... | would be no changing this while preserving backward compatibility, since all logging calls which are out there in existing code will be using %-format strings.
There is, however, a way that you can use {}- and $- formatting to construct
your individual log messages. Recall that for a message you can use an
arbitrary ob... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b7d7ce6a-793a-45ae-b21e-437a87fe1669 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,793 | supabase-export-v2 | 767836a9bdb76522 | .. code-block:: shell-session
$ python logctx.py
1. This should appear just once on stderr. 3. This should appear once on stderr. 5. This should appear twice - once on stderr and once on stdout. 5. This should appear twice - once on stderr and once on stdout. 6. This should appear just once on stderr. | trusted_official_docs | CPython Docs | .. code-block:: shell-session
$ python logctx.py
1. This should appear just once on stderr. 3. This should appear once on stderr. 5. This should appear twice - once on stderr and once on stdout. 5. This should appear twice - once on stderr and once on stdout. 6. This should appear just once on stderr. | .. code-block:: shell-session
$ python logctx.py
1. This should appear just once on stderr. 3. This should appear once on stderr. 5. This should appear twice - once on stderr and once on stdout. 5. This should appear twice - once on stderr and once on stdout. 6. This should appear just once on stderr. | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b819aa61-b1f2-4305-9100-417c83328536 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,298 | supabase-export-v2 | 8a6a9abda4d4888b | logger = logging.getLogger('simpleExample')
try:
# loop through logging calls to see the difference
# new configurations make, until Ctrl+C is pressed
while True:
logger.debug('debug message')
logger.info('info message')
logger.warning('warn message')
logger.error('error message')
logger.critical('critical mess... | trusted_official_docs | CPython Docs | logger = logging.getLogger('simpleExample')
try:
# loop through logging calls to see the difference
# new configurations make, until Ctrl+C is pressed
while True:
logger.debug('debug message')
logger.info('info message')
logger.warning('warn message')
logger.error('error message')
logger.critical('critical mess... | logger = logging.getLogger('simpleExample')
try:
# loop through logging calls to see the difference
# new configurations make, until Ctrl+C is pressed
while True:
logger.debug('debug message')
logger.info('info message')
logger.warning('warn message')
logger.error('error message')
logger.critical('critical mess... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b8cf057b-293c-4ac0-9a1d-4da2a3a9b108 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,258 | supabase-export-v2 | 51e7b6fd93dfe168 | This example uses console and file handlers, but you can use any number and combination of handlers you choose.
Note that the above choice of log filename ``/tmp/myapp.log`` implies use of a
standard location for temporary files on POSIX systems. On Windows, you may need to
choose a different directory name for the log... | trusted_official_docs | CPython Docs | This example uses console and file handlers, but you can use any number and combination of handlers you choose.
Note that the above choice of log filename ``/tmp/myapp.log`` implies use of a
standard location for temporary files on POSIX systems. On Windows, you may need to
choose a different directory name for the log... | This example uses console and file handlers, but you can use any number and combination of handlers you choose.
Note that the above choice of log filename ``/tmp/myapp.log`` implies use of a
standard location for temporary files on POSIX systems. On Windows, you may need to
choose a different directory name for the log... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
b95ace69-b058-4e2a-9244-355fa22e517e | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,448 | supabase-export-v2 | ef7cac45999daec1 | MESSAGES = [ 'Random message #1', 'Random message #2', 'Random message #3', ]
# The worker configuration is done at the start of the worker process run. # Note that on Windows you can't rely on fork semantics, so each process
# will run the logging configuration code when it starts. def worker_configurer(queue):
h = ... | trusted_official_docs | CPython Docs | MESSAGES = [ 'Random message #1', 'Random message #2', 'Random message #3', ]
# The worker configuration is done at the start of the worker process run. # Note that on Windows you can't rely on fork semantics, so each process
# will run the logging configuration code when it starts. def worker_configurer(queue):
h = ... | MESSAGES = [ 'Random message #1', 'Random message #2', 'Random message #3', ]
# The worker configuration is done at the start of the worker process run. # Note that on Windows you can't rely on fork semantics, so each process
# will run the logging configuration code when it starts. def worker_configurer(queue):
h = ... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bb0cc4aa-9ab9-458c-9e13-91b0247e7674 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,867 | supabase-export-v2 | 3032892e3fa3b7dc | @Slot(str, logging.LogRecord) def update_status(self, status, record): color = self.COLORS.get(record.levelno, 'black') s = '<pre><font color="%s">%s</font></pre>' % (color, status) self.textedit.appendHtml(s)
@Slot()
def manual_update(self):
# This function uses the formatted message passed in, but also uses
# info... | trusted_official_docs | CPython Docs | @Slot(str, logging.LogRecord) def update_status(self, status, record): color = self.COLORS.get(record.levelno, 'black') s = '<pre><font color="%s">%s</font></pre>' % (color, status) self.textedit.appendHtml(s)
@Slot()
def manual_update(self):
# This function uses the formatted message passed in, but also uses
# info... | @Slot(str, logging.LogRecord) def update_status(self, status, record): color = self.COLORS.get(record.levelno, 'black') s = '<pre><font color="%s">%s</font></pre>' % (color, status) self.textedit.appendHtml(s)
@Slot()
def manual_update(self):
# This function uses the formatted message passed in, but also uses
# info... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
bda7b3f0-e8cf-4671-8d2a-d829e3f4cc97 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,673 | supabase-export-v2 | 36f45cfe5858c73a | way to how you could implement other types of file change - e.g. setting specific POSIX permission bits - in the same way, using :func:`os.chmod`.
Of course, the approach could also be extended to types of handler other than a
:class:`~logging.FileHandler` - for example, one of the rotating file handlers,
or a differen... | trusted_official_docs | CPython Docs | way to how you could implement other types of file change - e.g. setting specific POSIX permission bits - in the same way, using :func:`os.chmod`.
Of course, the approach could also be extended to types of handler other than a
:class:`~logging.FileHandler` - for example, one of the rotating file handlers,
or a differen... | way to how you could implement other types of file change - e.g. setting specific POSIX permission bits - in the same way, using :func:`os.chmod`.
Of course, the approach could also be extended to types of handler other than a
:class:`~logging.FileHandler` - for example, one of the rotating file handlers,
or a differen... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c1e400af-f463-4a92-a18e-b122c512184c | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,392 | supabase-export-v2 | 9ee8b6540c6defe8 | .. code-block:: none
2010-09-06 22:38:15,292 a.b.c DEBUG IP: 123.231.231.123 User: fred A debug message
2010-09-06 22:38:15,300 a.b.c INFO IP: 192.168.0.1 User: sheila An info message with some parameters
2010-09-06 22:38:15,300 d.e.f CRITICAL IP: 127.0.0.1 User: sheila A message at CRITICAL level with 2 parameters
... | trusted_official_docs | CPython Docs | .. code-block:: none
2010-09-06 22:38:15,292 a.b.c DEBUG IP: 123.231.231.123 User: fred A debug message
2010-09-06 22:38:15,300 a.b.c INFO IP: 192.168.0.1 User: sheila An info message with some parameters
2010-09-06 22:38:15,300 d.e.f CRITICAL IP: 127.0.0.1 User: sheila A message at CRITICAL level with 2 parameters
... | .. code-block:: none
2010-09-06 22:38:15,292 a.b.c DEBUG IP: 123.231.231.123 User: fred A debug message
2010-09-06 22:38:15,300 a.b.c INFO IP: 192.168.0.1 User: sheila An info message with some parameters
2010-09-06 22:38:15,300 d.e.f CRITICAL IP: 127.0.0.1 User: sheila A message at CRITICAL level with 2 parameters
... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c230e1b5-566d-4399-be8b-e8ba946825c2 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,262 | supabase-export-v2 | 4b5592de36c9efed | processed by a handler. To do this, you need to use filters. Let's look at a scenario where you want to arrange things as follows:
* Send messages of severity ``INFO`` and ``WARNING`` to ``sys.stdout``
* Send messages of severity ``ERROR`` and above to ``sys.stderr``
* Send messages of severity ``DEBUG`` and above to f... | trusted_official_docs | CPython Docs | processed by a handler. To do this, you need to use filters. Let's look at a scenario where you want to arrange things as follows:
* Send messages of severity ``INFO`` and ``WARNING`` to ``sys.stdout``
* Send messages of severity ``ERROR`` and above to ``sys.stderr``
* Send messages of severity ``DEBUG`` and above to f... | processed by a handler. To do this, you need to use filters. Let's look at a scenario where you want to arrange things as follows:
* Send messages of severity ``INFO`` and ``WARNING`` to ``sys.stdout``
* Send messages of severity ``ERROR`` and above to ``sys.stderr``
* Send messages of severity ``DEBUG`` and above to f... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c3b57898-adfd-42fe-8730-4829e9b75bcd | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,699 | supabase-export-v2 | baff110bbcb9d3b7 | create the filter (a class is the most obvious, but you can provide any callable which returns a :class:`~logging.Filter` instance). Here is a complete example::
import logging
import logging.config
import sys | trusted_official_docs | CPython Docs | create the filter (a class is the most obvious, but you can provide any callable which returns a :class:`~logging.Filter` instance). Here is a complete example::
import logging
import logging.config
import sys | create the filter (a class is the most obvious, but you can provide any callable which returns a :class:`~logging.Filter` instance). Here is a complete example::
import logging
import logging.config
import sys | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c43cb989-d289-4d0c-abc7-2f9bc10365ff | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,918 | supabase-export-v2 | 9aae15c8c6547772 | recent call last): WARNING:demo: File "/home/runner/cookbook-loggerwriter/main.py", line 55, in <module> WARNING:demo: main() WARNING:demo: File "/home/runner/cookbook-loggerwriter/main.py", line 52, in main WARNING:demo: 1/0 WARNING:demo:ZeroDivisionError: division by zero
How to uniformly handle newlines in logging o... | trusted_official_docs | CPython Docs | recent call last): WARNING:demo: File "/home/runner/cookbook-loggerwriter/main.py", line 55, in <module> WARNING:demo: main() WARNING:demo: File "/home/runner/cookbook-loggerwriter/main.py", line 52, in main WARNING:demo: 1/0 WARNING:demo:ZeroDivisionError: division by zero
How to uniformly handle newlines in logging o... | recent call last): WARNING:demo: File "/home/runner/cookbook-loggerwriter/main.py", line 55, in <module> WARNING:demo: main() WARNING:demo: File "/home/runner/cookbook-loggerwriter/main.py", line 52, in main WARNING:demo: 1/0 WARNING:demo:ZeroDivisionError: division by zero
How to uniformly handle newlines in logging o... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c456fa49-0f63-405d-a056-2d7e006293b7 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,749 | supabase-export-v2 | 51b721160bb67aa1 | decorated_foo = log_if_errors(logger)(foo)
if __name__ == '__main__':
logger.setLevel(logging.DEBUG)
write_line('Calling undecorated foo with False')
assert not foo(False)
write_line('Calling undecorated foo with True')
assert foo(True)
write_line('Calling decorated foo with False')
assert not decorated_foo(Fals... | trusted_official_docs | CPython Docs | decorated_foo = log_if_errors(logger)(foo)
if __name__ == '__main__':
logger.setLevel(logging.DEBUG)
write_line('Calling undecorated foo with False')
assert not foo(False)
write_line('Calling undecorated foo with True')
assert foo(True)
write_line('Calling decorated foo with False')
assert not decorated_foo(Fals... | decorated_foo = log_if_errors(logger)(foo)
if __name__ == '__main__':
logger.setLevel(logging.DEBUG)
write_line('Calling undecorated foo with False')
assert not foo(False)
write_line('Calling undecorated foo with True')
assert foo(True)
write_line('Calling decorated foo with False')
assert not decorated_foo(Fals... | python, official-docs, cpython, P0 | Local_Trusted_Corpus | |
c459b618-cc5c-4ebd-a73b-3de98d358520 | CPython Docs | file://datasets/cpython/Doc/howto/logging-cookbook.rst | unknown | 5070c1c1-62f1-4f2f-bb22-ac9ebc36a263 | 56,519 | supabase-export-v2 | 854b6ac8b00824f1 | invoked when a suitable dictionary has been received over the network (e.g. in pickle form via a :class:`~handlers.SocketHandler`, or in JSON form via an :class:`~handlers.HTTPHandler`).
This has usually meant that if you need to do anything special with a
:class:`LogRecord`, you've had to do one of the following. | trusted_official_docs | CPython Docs | invoked when a suitable dictionary has been received over the network (e.g. in pickle form via a :class:`~handlers.SocketHandler`, or in JSON form via an :class:`~handlers.HTTPHandler`).
This has usually meant that if you need to do anything special with a
:class:`LogRecord`, you've had to do one of the following. | invoked when a suitable dictionary has been received over the network (e.g. in pickle form via a :class:`~handlers.SocketHandler`, or in JSON form via an :class:`~handlers.HTTPHandler`).
This has usually meant that if you need to do anything special with a
:class:`LogRecord`, you've had to do one of the following. | python, official-docs, cpython, P0 | Local_Trusted_Corpus |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.