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
4a66c754-2fcf-43f5-b808-bb871693f9cc
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,322
supabase-export-v2
b5a21d1fa69e9839
Sending and receiving logging events across a network ----------------------------------------------------- Let's say you want to send logging events across a network, and handle them at the receiving end. A simple way of doing this is attaching a :class:`SocketHandler` instance to the root logger at the sending end::
trusted_official_docs
CPython Docs
Sending and receiving logging events across a network ----------------------------------------------------- Let's say you want to send logging events across a network, and handle them at the receiving end. A simple way of doing this is attaching a :class:`SocketHandler` instance to the root logger at the sending end::
Sending and receiving logging events across a network ----------------------------------------------------- Let's say you want to send logging events across a network, and handle them at the receiving end. A simple way of doing this is attaching a :class:`SocketHandler` instance to the root logger at the sending end::
python, official-docs, cpython, P0
Local_Trusted_Corpus
4a78940e-3fb6-4fae-9a45-582929baffc9
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,500
supabase-export-v2
f8c5a174002e79eb
def __str__(self): from string import Template return Template(self.fmt).substitute(**self.kwargs) Either of these can be used in place of a format string, to allow {}- or $-formatting to be used to build the actual "message" part which appears in the formatted log output in place of "%(message)s" or "{message}" or "$m...
trusted_official_docs
CPython Docs
def __str__(self): from string import Template return Template(self.fmt).substitute(**self.kwargs) Either of these can be used in place of a format string, to allow {}- or $-formatting to be used to build the actual "message" part which appears in the formatted log output in place of "%(message)s" or "{message}" or "$m...
def __str__(self): from string import Template return Template(self.fmt).substitute(**self.kwargs) Either of these can be used in place of a format string, to allow {}- or $-formatting to be used to build the actual "message" part which appears in the formatted log output in place of "%(message)s" or "{message}" or "$m...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4b30ad8c-be62-4a20-b4bb-e1a84ed6946b
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,641
supabase-export-v2
83e45ed1fb798b0d
class Encoder(json.JSONEncoder): def default(self, o): if isinstance(o, set): return tuple(o) elif isinstance(o, str): return o.encode('unicode_escape').decode('ascii') return super().default(o) class StructuredMessage: def __init__(self, message, /, **kwargs): self.message = message self.kwargs = kwargs
trusted_official_docs
CPython Docs
class Encoder(json.JSONEncoder): def default(self, o): if isinstance(o, set): return tuple(o) elif isinstance(o, str): return o.encode('unicode_escape').decode('ascii') return super().default(o) class StructuredMessage: def __init__(self, message, /, **kwargs): self.message = message self.kwargs = kwargs
class Encoder(json.JSONEncoder): def default(self, o): if isinstance(o, set): return tuple(o) elif isinstance(o, str): return o.encode('unicode_escape').decode('ascii') return super().default(o) class StructuredMessage: def __init__(self, message, /, **kwargs): self.message = message self.kwargs = kwargs
python, official-docs, cpython, P0
Local_Trusted_Corpus
4ba37e6a-54ae-4f4b-97c4-0157f0694921
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,255
supabase-export-v2
5ec57724be17cd30
.. code-block:: none 10-22 22:19 root INFO Jackdaws love my big sphinx of quartz. 10-22 22:19 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim. 10-22 22:19 myapp.area1 INFO How quickly daft jumping zebras vex. 10-22 22:19 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 10-22 22:19 myapp.area2 ERRO...
trusted_official_docs
CPython Docs
.. code-block:: none 10-22 22:19 root INFO Jackdaws love my big sphinx of quartz. 10-22 22:19 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim. 10-22 22:19 myapp.area1 INFO How quickly daft jumping zebras vex. 10-22 22:19 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 10-22 22:19 myapp.area2 ERRO...
.. code-block:: none 10-22 22:19 root INFO Jackdaws love my big sphinx of quartz. 10-22 22:19 myapp.area1 DEBUG Quick zephyrs blow, vexing daft Jim. 10-22 22:19 myapp.area1 INFO How quickly daft jumping zebras vex. 10-22 22:19 myapp.area2 WARNING Jail zesty vixen who grabbed pay from quack. 10-22 22:19 myapp.area2 ERRO...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4bc60992-f185-4f07-895a-e4f75ccfc58c
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,856
supabase-export-v2
6a680d949b96ca1b
separate thread # * A button to log something from the main thread # * A button to clear the log window # class Window(QtWidgets.QWidget): COLORS = { logging.DEBUG: 'black', logging.INFO: 'blue', logging.WARNING: 'orange', logging.ERROR: 'red', logging.CRITICAL: 'purple', }
trusted_official_docs
CPython Docs
separate thread # * A button to log something from the main thread # * A button to clear the log window # class Window(QtWidgets.QWidget): COLORS = { logging.DEBUG: 'black', logging.INFO: 'blue', logging.WARNING: 'orange', logging.ERROR: 'red', logging.CRITICAL: 'purple', }
separate thread # * A button to log something from the main thread # * A button to clear the log window # class Window(QtWidgets.QWidget): COLORS = { logging.DEBUG: 'black', logging.INFO: 'blue', logging.WARNING: 'orange', logging.ERROR: 'red', logging.CRITICAL: 'purple', }
python, official-docs, cpython, P0
Local_Trusted_Corpus
4c8bf2a8-3b8e-4076-a2a4-5aebb503c511
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,390
supabase-export-v2
e01440c9f702ebc3
%s', 'some parameters') for x in range(10): lvl = choice(levels) lvlname = logging.getLevelName(lvl) a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, 'parameters') which, when run, produces something like:
trusted_official_docs
CPython Docs
%s', 'some parameters') for x in range(10): lvl = choice(levels) lvlname = logging.getLevelName(lvl) a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, 'parameters') which, when run, produces something like:
%s', 'some parameters') for x in range(10): lvl = choice(levels) lvlname = logging.getLevelName(lvl) a2.log(lvl, 'A message at %s level with %d %s', lvlname, 2, 'parameters') which, when run, produces something like:
python, official-docs, cpython, P0
Local_Trusted_Corpus
4d6045b2-ac35-400a-928b-f18f1c165e76
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,550
supabase-export-v2
8f14d29623f3b2be
Subclassing QueueHandler and QueueListener- a ``pynng`` example --------------------------------------------------------------- In a similar way to the above section, we can implement a listener and handler using :pypi:`pynng`, which is a Python binding to `NNG <https://nng.nanomsg.org/>`_, billed as a spiritual succes...
trusted_official_docs
CPython Docs
Subclassing QueueHandler and QueueListener- a ``pynng`` example --------------------------------------------------------------- In a similar way to the above section, we can implement a listener and handler using :pypi:`pynng`, which is a Python binding to `NNG <https://nng.nanomsg.org/>`_, billed as a spiritual succes...
Subclassing QueueHandler and QueueListener- a ``pynng`` example --------------------------------------------------------------- In a similar way to the above section, we can implement a listener and handler using :pypi:`pynng`, which is a Python binding to `NNG <https://nng.nanomsg.org/>`_, billed as a spiritual succes...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4e5ec687-c046-4396-90c9-6b6203eb9bd5
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,469
supabase-export-v2
aa3c8325525f232a
Deploying web applications using Gunicorn and uWSGI ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ When deploying web applications using `Gunicorn <https://gunicorn.org/>`_ or `uWSGI <https://uwsgi-docs.readthedocs.io/en/latest/>`_ (or similar), multiple worker processes are created to handle client requests. In s...
trusted_official_docs
CPython Docs
Deploying web applications using Gunicorn and uWSGI ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ When deploying web applications using `Gunicorn <https://gunicorn.org/>`_ or `uWSGI <https://uwsgi-docs.readthedocs.io/en/latest/>`_ (or similar), multiple worker processes are created to handle client requests. In s...
Deploying web applications using Gunicorn and uWSGI ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ When deploying web applications using `Gunicorn <https://gunicorn.org/>`_ or `uWSGI <https://uwsgi-docs.readthedocs.io/en/latest/>`_ (or similar), multiple worker processes are created to handle client requests. In s...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4e9fc5df-24a7-492a-8b0c-0eefb8c4d390
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,828
supabase-export-v2
fe8e2c03adf1c5bf
$ python app.py restart foo bar baz INFO restart Restarted the 'foo', 'bar' and 'baz' services. 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.
trusted_official_docs
CPython Docs
$ python app.py restart foo bar baz INFO restart Restarted the 'foo', 'bar' and 'baz' services. 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.
$ python app.py restart foo bar baz INFO restart Restarted the 'foo', 'bar' and 'baz' services. 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.
python, official-docs, cpython, P0
Local_Trusted_Corpus
4f9c353e-41a1-44f3-8ed7-ced4fac5ea1c
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,715
supabase-export-v2
dec80d165014ac57
exception so that it prints on a single line. """ result = super().formatException(exc_info) return repr(result) # or format into one line however you want to def format(self, record): s = super().format(record) if record.exc_text: s = s.replace('\n', '') + '|' return s
trusted_official_docs
CPython Docs
exception so that it prints on a single line. """ result = super().formatException(exc_info) return repr(result) # or format into one line however you want to def format(self, record): s = super().format(record) if record.exc_text: s = s.replace('\n', '') + '|' return s
exception so that it prints on a single line. """ result = super().formatException(exc_info) return repr(result) # or format into one line however you want to def format(self, record): s = super().format(record) if record.exc_text: s = s.replace('\n', '') + '|' return s
python, official-docs, cpython, P0
Local_Trusted_Corpus
4fc114d3-3577-444b-a38a-e13ca5d06170
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,492
supabase-export-v2
f15c0a5595d27874
2010-10-28 15:13:06,924 foo.bar DEBUG This is a DEBUG message >>> logger.critical('This is a CRITICAL message') 2010-10-28 15:13:11,494 foo.bar CRITICAL This is a CRITICAL message >>> Note that the formatting of logging messages for final output to logs is completely independent of how an individual logging message is ...
trusted_official_docs
CPython Docs
2010-10-28 15:13:06,924 foo.bar DEBUG This is a DEBUG message >>> logger.critical('This is a CRITICAL message') 2010-10-28 15:13:11,494 foo.bar CRITICAL This is a CRITICAL message >>> Note that the formatting of logging messages for final output to logs is completely independent of how an individual logging message is ...
2010-10-28 15:13:06,924 foo.bar DEBUG This is a DEBUG message >>> logger.critical('This is a CRITICAL message') 2010-10-28 15:13:11,494 foo.bar CRITICAL This is a CRITICAL message >>> Note that the formatting of logging messages for final output to logs is completely independent of how an individual logging message is ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4fd6d81a-eaf9-4963-8d7e-3895c7a097e1
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,712
supabase-export-v2
84511e7c2cb6785c
Customized exception formatting ------------------------------- There might be times when you want to do customized exception formatting - for argument's sake, let's say you want exactly one line per logged event, even when exception information is present. You can do this with a custom formatter class, as shown in the...
trusted_official_docs
CPython Docs
Customized exception formatting ------------------------------- There might be times when you want to do customized exception formatting - for argument's sake, let's say you want exactly one line per logged event, even when exception information is present. You can do this with a custom formatter class, as shown in the...
Customized exception formatting ------------------------------- There might be times when you want to do customized exception formatting - for argument's sake, let's say you want exactly one line per logged event, even when exception information is present. You can do this with a custom formatter class, as shown in the...
python, official-docs, cpython, P0
Local_Trusted_Corpus
4fdf1f45-5b8a-4a49-9f6d-a7b4927c3df3
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,750
supabase-export-v2
e3f95621e4c5180f
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(False) write_line('Calling decorated foo with True') assert decorated_foo(True) When this script is run, the following output should be observed:
trusted_official_docs
CPython Docs
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(False) write_line('Calling decorated foo with True') assert decorated_foo(True) When this script is run, the following output should be observed:
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(False) write_line('Calling decorated foo with True') assert decorated_foo(True) When this script is run, the following output should be observed:
python, official-docs, cpython, P0
Local_Trusted_Corpus
4fed43f3-9d5c-4a58-a1a5-0a0381856504
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,414
supabase-export-v2
289a6c33af6fd23c
def filter(self, record): request = ctx_request.get() record.method = request.method record.ip = request.ip record.user = request.user record.appName = appName = ctx_appname.get() return appName == self.app.name class WebApp: """ A dummy web application class which has its own handler and filter for a webapp-specifi...
trusted_official_docs
CPython Docs
def filter(self, record): request = ctx_request.get() record.method = request.method record.ip = request.ip record.user = request.user record.appName = appName = ctx_appname.get() return appName == self.app.name class WebApp: """ A dummy web application class which has its own handler and filter for a webapp-specifi...
def filter(self, record): request = ctx_request.get() record.method = request.method record.ip = request.ip record.user = request.user record.appName = appName = ctx_appname.get() return appName == self.app.name class WebApp: """ A dummy web application class which has its own handler and filter for a webapp-specifi...
python, official-docs, cpython, P0
Local_Trusted_Corpus
51079e87-8a40-4b35-9730-463ef17fedb4
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,698
supabase-export-v2
7de52d67a5af5bcd
Configuring filters with :func:`dictConfig` ------------------------------------------- You *can* configure filters using :func:`~logging.config.dictConfig`, though it might not be obvious at first glance how to do it (hence this recipe). Since :class:`~logging.Filter` is the only filter class included in the standard ...
trusted_official_docs
CPython Docs
Configuring filters with :func:`dictConfig` ------------------------------------------- You *can* configure filters using :func:`~logging.config.dictConfig`, though it might not be obvious at first glance how to do it (hence this recipe). Since :class:`~logging.Filter` is the only filter class included in the standard ...
Configuring filters with :func:`dictConfig` ------------------------------------------- You *can* configure filters using :func:`~logging.config.dictConfig`, though it might not be obvious at first glance how to do it (hence this recipe). Since :class:`~logging.Filter` is the only filter class included in the standard ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5228220b-544c-4952-8321-53d20bc9597d
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,389
supabase-export-v2
a73cb2960c13033d
__name__ == '__main__': levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL) logging.basicConfig(level=logging.DEBUG, format='%(asctime)-15s %(name)-5s %(levelname)-8s IP: %(ip)-15s User: %(user)-8s %(message)s') a1 = logging.getLogger('a.b.c') a2 = logging.getLogger('d.e.f') f = Con...
trusted_official_docs
CPython Docs
__name__ == '__main__': levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL) logging.basicConfig(level=logging.DEBUG, format='%(asctime)-15s %(name)-5s %(levelname)-8s IP: %(ip)-15s User: %(user)-8s %(message)s') a1 = logging.getLogger('a.b.c') a2 = logging.getLogger('d.e.f') f = Con...
__name__ == '__main__': levels = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL) logging.basicConfig(level=logging.DEBUG, format='%(asctime)-15s %(name)-5s %(levelname)-8s IP: %(ip)-15s User: %(user)-8s %(message)s') a1 = logging.getLogger('a.b.c') a2 = logging.getLogger('d.e.f') f = Con...
python, official-docs, cpython, P0
Local_Trusted_Corpus
52efd1c1-f606-4255-a8ec-0f3da40f5556
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,223
supabase-export-v2
0873b423e770a9c0
.. code-block:: none 2005-03-23 23:47:11,663 - spam_application - INFO - creating an instance of auxiliary_module.Auxiliary 2005-03-23 23:47:11,665 - spam_application.auxiliary.Auxiliary - INFO - creating an instance of Auxiliary 2005-03-23 23:47:11,665 - spam_application - INFO - created an instance of auxiliary_...
trusted_official_docs
CPython Docs
.. code-block:: none 2005-03-23 23:47:11,663 - spam_application - INFO - creating an instance of auxiliary_module.Auxiliary 2005-03-23 23:47:11,665 - spam_application.auxiliary.Auxiliary - INFO - creating an instance of Auxiliary 2005-03-23 23:47:11,665 - spam_application - INFO - created an instance of auxiliary_...
.. code-block:: none 2005-03-23 23:47:11,663 - spam_application - INFO - creating an instance of auxiliary_module.Auxiliary 2005-03-23 23:47:11,665 - spam_application.auxiliary.Auxiliary - INFO - creating an instance of Auxiliary 2005-03-23 23:47:11,665 - spam_application - INFO - created an instance of auxiliary_...
python, official-docs, cpython, P0
Local_Trusted_Corpus
53b0fc4b-1a9a-4b83-a8ad-762ef6bd573f
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,535
supabase-export-v2
3f3058f29a244bee
Subclass ``QueueHandler`` ^^^^^^^^^^^^^^^^^^^^^^^^^ You can use a :class:`QueueHandler` subclass to send messages to other kinds of queues, for example a ZeroMQ 'publish' socket. In the example below,the socket is created separately and passed to the handler (as its 'queue')::
trusted_official_docs
CPython Docs
Subclass ``QueueHandler`` ^^^^^^^^^^^^^^^^^^^^^^^^^ You can use a :class:`QueueHandler` subclass to send messages to other kinds of queues, for example a ZeroMQ 'publish' socket. In the example below,the socket is created separately and passed to the handler (as its 'queue')::
Subclass ``QueueHandler`` ^^^^^^^^^^^^^^^^^^^^^^^^^ You can use a :class:`QueueHandler` subclass to send messages to other kinds of queues, for example a ZeroMQ 'publish' socket. In the example below,the socket is created separately and passed to the handler (as its 'queue')::
python, official-docs, cpython, P0
Local_Trusted_Corpus
53d6c69f-f0c2-4045-a6d6-eed1ff95dbdd
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,884
supabase-export-v2
26adc4a8fecc648f
How to treat a logger like an output stream ------------------------------------------- Sometimes, you need to interface to a third-party API which expects a file-like object to write to, but you want to direct the API's output to a logger. You can do this using a class which wraps a logger with a file-like API. Here's...
trusted_official_docs
CPython Docs
How to treat a logger like an output stream ------------------------------------------- Sometimes, you need to interface to a third-party API which expects a file-like object to write to, but you want to direct the API's output to a logger. You can do this using a class which wraps a logger with a file-like API. Here's...
How to treat a logger like an output stream ------------------------------------------- Sometimes, you need to interface to a third-party API which expects a file-like object to write to, but you want to direct the API's output to a logger. You can do this using a class which wraps a logger with a file-like API. Here's...
python, official-docs, cpython, P0
Local_Trusted_Corpus
548d60ea-95e4-4470-a20e-5cde8c97ad18
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,888
supabase-export-v2
0456f02db25b50b8
def write(self, message): if message != '\n': # avoid printing bare newlines, if you like self.logger.log(self.level, message) def flush(self): # doesn't actually do anything, but might be expected of a file-like # object - so optional depending on your situation pass
trusted_official_docs
CPython Docs
def write(self, message): if message != '\n': # avoid printing bare newlines, if you like self.logger.log(self.level, message) def flush(self): # doesn't actually do anything, but might be expected of a file-like # object - so optional depending on your situation pass
def write(self, message): if message != '\n': # avoid printing bare newlines, if you like self.logger.log(self.level, message) def flush(self): # doesn't actually do anything, but might be expected of a file-like # object - so optional depending on your situation pass
python, official-docs, cpython, P0
Local_Trusted_Corpus
54e41a76-7768-42c7-8c19-18708d1145c2
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,291
supabase-export-v2
606e48c0f9ad61e8
.. code-block:: shell $ more *.log :::::::::::::: app.log :::::::::::::: DEBUG - A DEBUG message INFO - An INFO message WARNING - A WARNING message ERROR - An ERROR message CRITICAL - A CRITICAL message :::::::::::::: stderr.log :::::::::::::: ERROR - An ERROR message CRITICAL - A CRITICAL message :::::::...
trusted_official_docs
CPython Docs
.. code-block:: shell $ more *.log :::::::::::::: app.log :::::::::::::: DEBUG - A DEBUG message INFO - An INFO message WARNING - A WARNING message ERROR - An ERROR message CRITICAL - A CRITICAL message :::::::::::::: stderr.log :::::::::::::: ERROR - An ERROR message CRITICAL - A CRITICAL message :::::::...
.. code-block:: shell $ more *.log :::::::::::::: app.log :::::::::::::: DEBUG - A DEBUG message INFO - An INFO message WARNING - A WARNING message ERROR - An ERROR message CRITICAL - A CRITICAL message :::::::::::::: stderr.log :::::::::::::: ERROR - An ERROR message CRITICAL - A CRITICAL message :::::::...
python, official-docs, cpython, P0
Local_Trusted_Corpus
54fee79c-586e-4b01-bb84-7e93de215439
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,931
supabase-export-v2
fbfab8846885a96b
.. code-block:: text 2025-07-02 13:54:47,234 DEBUG Single line 2025-07-02 13:54:47,234 DEBUG Multiple lines: 2025-07-02 13:54:47,234 DEBUG fool me once ... 2025-07-02 13:54:47,234 DEBUG Another single line 2025-07-02 13:54:47,234 DEBUG Multiple lines: 2025-07-02 13:54:47,234 DEBUG fool me ... 2025-07-02 13:54:47,23...
trusted_official_docs
CPython Docs
.. code-block:: text 2025-07-02 13:54:47,234 DEBUG Single line 2025-07-02 13:54:47,234 DEBUG Multiple lines: 2025-07-02 13:54:47,234 DEBUG fool me once ... 2025-07-02 13:54:47,234 DEBUG Another single line 2025-07-02 13:54:47,234 DEBUG Multiple lines: 2025-07-02 13:54:47,234 DEBUG fool me ... 2025-07-02 13:54:47,23...
.. code-block:: text 2025-07-02 13:54:47,234 DEBUG Single line 2025-07-02 13:54:47,234 DEBUG Multiple lines: 2025-07-02 13:54:47,234 DEBUG fool me once ... 2025-07-02 13:54:47,234 DEBUG Another single line 2025-07-02 13:54:47,234 DEBUG Multiple lines: 2025-07-02 13:54:47,234 DEBUG fool me ... 2025-07-02 13:54:47,23...
python, official-docs, cpython, P0
Local_Trusted_Corpus
56f649f0-069d-4cd1-8997-0551320f2215
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,789
supabase-export-v2
a5ed9a7fe5b81acd
To illustrate how it works, we can add the following block of code to the above:: if __name__ == '__main__': logger = logging.getLogger('foo') logger.addHandler(logging.StreamHandler()) logger.setLevel(logging.INFO) logger.info('1. This should appear just once on stderr.') logger.debug('2. This should not appear.'...
trusted_official_docs
CPython Docs
To illustrate how it works, we can add the following block of code to the above:: if __name__ == '__main__': logger = logging.getLogger('foo') logger.addHandler(logging.StreamHandler()) logger.setLevel(logging.INFO) logger.info('1. This should appear just once on stderr.') logger.debug('2. This should not appear.'...
To illustrate how it works, we can add the following block of code to the above:: if __name__ == '__main__': logger = logging.getLogger('foo') logger.addHandler(logging.StreamHandler()) logger.setLevel(logging.INFO) logger.info('1. This should appear just once on stderr.') logger.debug('2. This should not appear.'...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5772222d-da48-4547-b6d5-524006ef3cbd
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,592
supabase-export-v2
8adce0abb46c5213
rh = logging.handlers.RotatingFileHandler('rotated.log', maxBytes=128, backupCount=5) rh.rotator = rotator rh.namer = namer root = logging.getLogger() root.setLevel(logging.INFO) root.addHandler(rh) f = logging.Formatter('%(asctime)s %(message)s') rh.setFormatter(f) for i in range(1000): root.info(f'Message no. {...
trusted_official_docs
CPython Docs
rh = logging.handlers.RotatingFileHandler('rotated.log', maxBytes=128, backupCount=5) rh.rotator = rotator rh.namer = namer root = logging.getLogger() root.setLevel(logging.INFO) root.addHandler(rh) f = logging.Formatter('%(asctime)s %(message)s') rh.setFormatter(f) for i in range(1000): root.info(f'Message no. {...
rh = logging.handlers.RotatingFileHandler('rotated.log', maxBytes=128, backupCount=5) rh.rotator = rotator rh.namer = namer root = logging.getLogger() root.setLevel(logging.INFO) root.addHandler(rh) f = logging.Formatter('%(asctime)s %(message)s') rh.setFormatter(f) for i in range(1000): root.info(f'Message no. {...
python, official-docs, cpython, P0
Local_Trusted_Corpus
57e5b648-ae01-40a8-b18f-cb0c35546d57
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,252
supabase-export-v2
643135db5ec065ea
.. code-block:: none root : INFO Jackdaws love my big sphinx of quartz. myapp.area1 : INFO How quickly daft jumping zebras vex. myapp.area2 : WARNING Jail zesty vixen who grabbed pay from quack. myapp.area2 : ERROR The five boxing wizards jump quickly.
trusted_official_docs
CPython Docs
.. code-block:: none root : INFO Jackdaws love my big sphinx of quartz. myapp.area1 : INFO How quickly daft jumping zebras vex. myapp.area2 : WARNING Jail zesty vixen who grabbed pay from quack. myapp.area2 : ERROR The five boxing wizards jump quickly.
.. code-block:: none root : INFO Jackdaws love my big sphinx of quartz. myapp.area1 : INFO How quickly daft jumping zebras vex. myapp.area2 : WARNING Jail zesty vixen who grabbed pay from quack. myapp.area2 : ERROR The five boxing wizards jump quickly.
python, official-docs, cpython, P0
Local_Trusted_Corpus
5895e800-e3da-4cae-8e86-02246389bf6b
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,316
supabase-export-v2
b0563b451672f701
async code is used in an application, to use the above approach for logging, so that any blocking code runs only in the ``QueueListener`` thread. .. versionchanged:: 3.5 Prior to Python 3.5, the :class:`QueueListener` always passed every message received from the queue to every handler it was initialized with. (This ...
trusted_official_docs
CPython Docs
async code is used in an application, to use the above approach for logging, so that any blocking code runs only in the ``QueueListener`` thread. .. versionchanged:: 3.5 Prior to Python 3.5, the :class:`QueueListener` always passed every message received from the queue to every handler it was initialized with. (This ...
async code is used in an application, to use the above approach for logging, so that any blocking code runs only in the ``QueueListener`` thread. .. versionchanged:: 3.5 Prior to Python 3.5, the :class:`QueueListener` always passed every message received from the queue to every handler it was initialized with. (This ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
596f27c3-0b4a-4880-9ad2-5d306406da98
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,872
supabase-export-v2
88a8b110067fe9da
Logging to syslog with RFC5424 support -------------------------------------- Although :rfc:`5424` dates from 2009, most syslog servers are configured by default to use the older :rfc:`3164`, which hails from 2001. When ``logging`` was added to Python in 2003, it supported the earlier (and only existing) protocol at th...
trusted_official_docs
CPython Docs
Logging to syslog with RFC5424 support -------------------------------------- Although :rfc:`5424` dates from 2009, most syslog servers are configured by default to use the older :rfc:`3164`, which hails from 2001. When ``logging`` was added to Python in 2003, it supported the earlier (and only existing) protocol at th...
Logging to syslog with RFC5424 support -------------------------------------- Although :rfc:`5424` dates from 2009, most syslog servers are configured by default to use the older :rfc:`3164`, which hails from 2001. When ``logging`` was added to Python in 2003, it supported the earlier (and only existing) protocol at th...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5a3981b0-f177-43aa-b7a8-36b37e95384f
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,862
supabase-export-v2
b34a89f5928f7bf7
Start a new worker thread and connect the slots for the worker self.start_thread() self.work_button.clicked.connect(self.worker.start) # Once started, the button should be disabled self.work_button.clicked.connect(lambda : self.work_button.setEnabled(False)) def start_thread(self): self.worker = Worker() self.worker_...
trusted_official_docs
CPython Docs
Start a new worker thread and connect the slots for the worker self.start_thread() self.work_button.clicked.connect(self.worker.start) # Once started, the button should be disabled self.work_button.clicked.connect(lambda : self.work_button.setEnabled(False)) def start_thread(self): self.worker = Worker() self.worker_...
Start a new worker thread and connect the slots for the worker self.start_thread() self.work_button.clicked.connect(self.worker.start) # Once started, the button should be disabled self.work_button.clicked.connect(lambda : self.work_button.setEnabled(False)) def start_thread(self): self.worker = Worker() self.worker_...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5b836912-07d8-480f-aecf-7399aff5260a
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,359
supabase-export-v2
aab180a95f89ff57
#. You can shut down the listener and the web application by running ``venv/bin/supervisorctl -c supervisor.conf shutdown``. You may need to tweak the configuration files in the unlikely event that the configured ports clash with something else in your test environment.
trusted_official_docs
CPython Docs
#. You can shut down the listener and the web application by running ``venv/bin/supervisorctl -c supervisor.conf shutdown``. You may need to tweak the configuration files in the unlikely event that the configured ports clash with something else in your test environment.
#. You can shut down the listener and the web application by running ``venv/bin/supervisorctl -c supervisor.conf shutdown``. You may need to tweak the configuration files in the unlikely event that the configured ports clash with something else in your test environment.
python, official-docs, cpython, P0
Local_Trusted_Corpus
5bb8cac4-f8b9-4223-b83f-d90ebe03a2b7
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,853
supabase-export-v2
7db6e740690c5ddf
# # Used to generate random levels for logging. # LEVELS = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL) # # This worker class represents work that is done in a thread separate to the # main thread. The way the thread is kicked off to do work is via a button press # that connects to...
trusted_official_docs
CPython Docs
# # Used to generate random levels for logging. # LEVELS = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL) # # This worker class represents work that is done in a thread separate to the # main thread. The way the thread is kicked off to do work is via a button press # that connects to...
# # Used to generate random levels for logging. # LEVELS = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL) # # This worker class represents work that is done in a thread separate to the # main thread. The way the thread is kicked off to do work is via a button press # that connects to...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5c027327-82ae-4c50-80e6-1441ade78639
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,380
supabase-export-v2
bea5715604f31ae7
Using Filters to impart contextual information ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You can also add contextual information to log output using a user-defined :class:`Filter`. ``Filter`` instances are allowed to modify the ``LogRecords`` passed to them, including adding additional attributes which can then be...
trusted_official_docs
CPython Docs
Using Filters to impart contextual information ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You can also add contextual information to log output using a user-defined :class:`Filter`. ``Filter`` instances are allowed to modify the ``LogRecords`` passed to them, including adding additional attributes which can then be...
Using Filters to impart contextual information ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You can also add contextual information to log output using a user-defined :class:`Filter`. ``Filter`` instances are allowed to modify the ``LogRecords`` passed to them, including adding additional attributes which can then be...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5ccdb4e3-7c4a-422c-80e3-daed590a6455
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,396
supabase-export-v2
e1caf60d968e4d9d
directed to the appropriate application's log file, while including in the log additional contextual information such as client IP, HTTP request method and client username? Let's assume that the library can be simulated by the following code:
trusted_official_docs
CPython Docs
directed to the appropriate application's log file, while including in the log additional contextual information such as client IP, HTTP request method and client username? Let's assume that the library can be simulated by the following code:
directed to the appropriate application's log file, while including in the log additional contextual information such as client IP, HTTP request method and client username? Let's assume that the library can be simulated by the following code:
python, official-docs, cpython, P0
Local_Trusted_Corpus
5de7e4f6-a26a-431b-915d-2d1297dd521a
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,709
supabase-export-v2
5f1e2c8193a0249b
can use the form ``ext://...`` as described in :ref:`logging-config-dict-externalobj`. For example, you could have used the text ``'ext://__main__.MyFilter'`` instead of ``MyFilter`` in the above example. * As well as for filters, this technique can also be used to configure custom handlers and formatters. See :ref:`l...
trusted_official_docs
CPython Docs
can use the form ``ext://...`` as described in :ref:`logging-config-dict-externalobj`. For example, you could have used the text ``'ext://__main__.MyFilter'`` instead of ``MyFilter`` in the above example. * As well as for filters, this technique can also be used to configure custom handlers and formatters. See :ref:`l...
can use the form ``ext://...`` as described in :ref:`logging-config-dict-externalobj`. For example, you could have used the text ``'ext://__main__.MyFilter'`` instead of ``MyFilter`` in the above example. * As well as for filters, this technique can also be used to configure custom handlers and formatters. See :ref:`l...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5e0bad94-4016-4e04-a201-1070cf96f9c2
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,250
supabase-export-v2
91ec5b0496d5e16d
zephyrs blow, vexing daft Jim.') logger1.info('How quickly daft jumping zebras vex.') logger2.warning('Jail zesty vixen who grabbed pay from quack.') logger2.error('The five boxing wizards jump quickly.') When you run this, on the console you will see
trusted_official_docs
CPython Docs
zephyrs blow, vexing daft Jim.') logger1.info('How quickly daft jumping zebras vex.') logger2.warning('Jail zesty vixen who grabbed pay from quack.') logger2.error('The five boxing wizards jump quickly.') When you run this, on the console you will see
zephyrs blow, vexing daft Jim.') logger1.info('How quickly daft jumping zebras vex.') logger2.warning('Jail zesty vixen who grabbed pay from quack.') logger2.error('The five boxing wizards jump quickly.') When you run this, on the console you will see
python, official-docs, cpython, P0
Local_Trusted_Corpus
5e966abd-5cf2-4f4b-9923-9d54e3f56637
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,901
supabase-export-v2
ec0563174599fc35
>>> print('Foo') INFO:demo:Foo >>> print('Bar', file=sys.stderr) WARNING:demo:Bar >>> Of course, the examples above show output according to the format used by :func:`~logging.basicConfig`, but you can use a different formatter when you configure logging.
trusted_official_docs
CPython Docs
>>> print('Foo') INFO:demo:Foo >>> print('Bar', file=sys.stderr) WARNING:demo:Bar >>> Of course, the examples above show output according to the format used by :func:`~logging.basicConfig`, but you can use a different formatter when you configure logging.
>>> print('Foo') INFO:demo:Foo >>> print('Bar', file=sys.stderr) WARNING:demo:Bar >>> Of course, the examples above show output according to the format used by :func:`~logging.basicConfig`, but you can use a different formatter when you configure logging.
python, official-docs, cpython, P0
Local_Trusted_Corpus
5ef8b601-7f73-48c9-addc-f3794387e855
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,945
supabase-export-v2
ad46d14ca6c4125b
Opening the same log file multiple times ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ On Windows, you will generally not be able to open the same file multiple times as this will lead to a "file is in use by another process" error. However, on POSIX platforms you'll not get any errors if you open the same file multiple tim...
trusted_official_docs
CPython Docs
Opening the same log file multiple times ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ On Windows, you will generally not be able to open the same file multiple times as this will lead to a "file is in use by another process" error. However, on POSIX platforms you'll not get any errors if you open the same file multiple tim...
Opening the same log file multiple times ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ On Windows, you will generally not be able to open the same file multiple times as this will lead to a "file is in use by another process" error. However, on POSIX platforms you'll not get any errors if you open the same file multiple tim...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5f16c48c-2275-474a-a0d2-33ae9a03fcfb
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,762
supabase-export-v2
0729606cee4f4ab1
port self.username = username self.password = password self.fromaddr = fromaddr if isinstance(toaddrs, str): toaddrs = [toaddrs] self.toaddrs = toaddrs self.subject = subject self.setFormatter(logging.Formatter("%(asctime)s %(levelname)-5s %(message)s")) def flush(self): if len(self.buffer) > 0: try: smtp = smtplib....
trusted_official_docs
CPython Docs
port self.username = username self.password = password self.fromaddr = fromaddr if isinstance(toaddrs, str): toaddrs = [toaddrs] self.toaddrs = toaddrs self.subject = subject self.setFormatter(logging.Formatter("%(asctime)s %(levelname)-5s %(message)s")) def flush(self): if len(self.buffer) > 0: try: smtp = smtplib....
port self.username = username self.password = password self.fromaddr = fromaddr if isinstance(toaddrs, str): toaddrs = [toaddrs] self.toaddrs = toaddrs self.subject = subject self.setFormatter(logging.Formatter("%(asctime)s %(levelname)-5s %(message)s")) def flush(self): if len(self.buffer) > 0: try: smtp = smtplib....
python, official-docs, cpython, P0
Local_Trusted_Corpus
5f19c9f6-ed43-4fc2-a61e-1d32810e6929
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,879
supabase-export-v2
71ec3b30def061bf
There's no error checking here - it's purely for illustration, and you # can adapt this code for use in production environments parts = [] def replacer(m): g = m.groups() return '\\' + g[0]
trusted_official_docs
CPython Docs
There's no error checking here - it's purely for illustration, and you # can adapt this code for use in production environments parts = [] def replacer(m): g = m.groups() return '\\' + g[0]
There's no error checking here - it's purely for illustration, and you # can adapt this code for use in production environments parts = [] def replacer(m): g = m.groups() return '\\' + g[0]
python, official-docs, cpython, P0
Local_Trusted_Corpus
5f2a4b8d-9ab5-4c2e-beab-c072b8ceef23
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,684
supabase-export-v2
8718e84780af4044
Using custom message objects ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ There is another, perhaps simpler way that you can use {}- and $- formatting to construct your individual log messages. You may recall (from :ref:`arbitrary-object-messages`) that when logging you can use an arbitrary object as a message format string, and that ...
trusted_official_docs
CPython Docs
Using custom message objects ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ There is another, perhaps simpler way that you can use {}- and $- formatting to construct your individual log messages. You may recall (from :ref:`arbitrary-object-messages`) that when logging you can use an arbitrary object as a message format string, and that ...
Using custom message objects ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ There is another, perhaps simpler way that you can use {}- and $- formatting to construct your individual log messages. You may recall (from :ref:`arbitrary-object-messages`) that when logging you can use an arbitrary object as a message format string, and that ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
5fc3d35b-cb1a-48f7-98f3-e8b24f634c37
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,444
supabase-export-v2
ba1783aab50efe58
break logger = logging.getLogger(record.name) logger.handle(record) # No level or filter logic applied - just do it! except Exception: import sys, traceback print('Whoops! Problem:', file=sys.stderr) traceback.print_exc(file=sys.stderr) # Arrays used for random selections in this demo
trusted_official_docs
CPython Docs
break logger = logging.getLogger(record.name) logger.handle(record) # No level or filter logic applied - just do it! except Exception: import sys, traceback print('Whoops! Problem:', file=sys.stderr) traceback.print_exc(file=sys.stderr) # Arrays used for random selections in this demo
break logger = logging.getLogger(record.name) logger.handle(record) # No level or filter logic applied - just do it! except Exception: import sys, traceback print('Whoops! Problem:', file=sys.stderr) traceback.print_exc(file=sys.stderr) # Arrays used for random selections in this demo
python, official-docs, cpython, P0
Local_Trusted_Corpus
614c9110-643c-4064-aac8-87af6444e296
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,472
supabase-export-v2
3791b2098d4e57ef
so that the number of files and the size of the files both remain bounded. For this usage pattern, the logging package provides a :class:`RotatingFileHandler`:: import glob import logging import logging.handlers
trusted_official_docs
CPython Docs
so that the number of files and the size of the files both remain bounded. For this usage pattern, the logging package provides a :class:`RotatingFileHandler`:: import glob import logging import logging.handlers
so that the number of files and the size of the files both remain bounded. For this usage pattern, the logging package provides a :class:`RotatingFileHandler`:: import glob import logging import logging.handlers
python, official-docs, cpython, P0
Local_Trusted_Corpus
621aa107-9e71-4479-8e3b-9b4795b12747
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,237
supabase-export-v2
641b8ade92541001
import logging logger = logging.getLogger('simple_example') logger.setLevel(logging.DEBUG) # create file handler which logs even debug messages fh = logging.FileHandler('spam.log') fh.setLevel(logging.DEBUG) # create console handler with a higher log level ch = logging.StreamHandler() ch.setLevel(logging.ERROR) ...
trusted_official_docs
CPython Docs
import logging logger = logging.getLogger('simple_example') logger.setLevel(logging.DEBUG) # create file handler which logs even debug messages fh = logging.FileHandler('spam.log') fh.setLevel(logging.DEBUG) # create console handler with a higher log level ch = logging.StreamHandler() ch.setLevel(logging.ERROR) ...
import logging logger = logging.getLogger('simple_example') logger.setLevel(logging.DEBUG) # create file handler which logs even debug messages fh = logging.FileHandler('spam.log') fh.setLevel(logging.DEBUG) # create console handler with a higher log level ch = logging.StreamHandler() ch.setLevel(logging.ERROR) ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
62356bdc-256b-42d7-966a-242491dbb7ae
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,521
supabase-export-v2
c7fcc51fdd1f61c2
are instantiated. * Add a :class:`Filter` to a logger or handler, which does the necessary special manipulation you need when its :meth:`~Filter.filter` method is called. The first approach would be a little unwieldy in the scenario where (say) several different libraries wanted to do different things. Each would attem...
trusted_official_docs
CPython Docs
are instantiated. * Add a :class:`Filter` to a logger or handler, which does the necessary special manipulation you need when its :meth:`~Filter.filter` method is called. The first approach would be a little unwieldy in the scenario where (say) several different libraries wanted to do different things. Each would attem...
are instantiated. * Add a :class:`Filter` to a logger or handler, which does the necessary special manipulation you need when its :meth:`~Filter.filter` method is called. The first approach would be a little unwieldy in the scenario where (say) several different libraries wanted to do different things. Each would attem...
python, official-docs, cpython, P0
Local_Trusted_Corpus
62652115-77d5-4a1e-ac07-f31131e07a3f
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,407
supabase-export-v2
0dc350465b19c2f0
that all GET requests are from 192.168.2.XXX # addresses, whereas POST requests are from 192.16.3.XXX addresses. Three users # are represented in the sample requests. REQUESTS = [ Request('GET', '192.168.2.20', 'jim'), Request('POST', '192.168.3.20', 'fred'), Request('GET', '192.168.2.21', 'sheila'), Request('POST'...
trusted_official_docs
CPython Docs
that all GET requests are from 192.168.2.XXX # addresses, whereas POST requests are from 192.16.3.XXX addresses. Three users # are represented in the sample requests. REQUESTS = [ Request('GET', '192.168.2.20', 'jim'), Request('POST', '192.168.3.20', 'fred'), Request('GET', '192.168.2.21', 'sheila'), Request('POST'...
that all GET requests are from 192.168.2.XXX # addresses, whereas POST requests are from 192.16.3.XXX addresses. Three users # are represented in the sample requests. REQUESTS = [ Request('GET', '192.168.2.20', 'jim'), Request('POST', '192.168.3.20', 'fred'), Request('GET', '192.168.2.21', 'sheila'), Request('POST'...
python, official-docs, cpython, P0
Local_Trusted_Corpus
62675715-7488-4f26-8a93-1ff4b952a027
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,685
supabase-export-v2
e0c578235fcb9973
message format string, and that the logging package will call :func:`str` on that object to get the actual format string. Consider the following two classes:: class BraceMessage: def __init__(self, fmt, /, *args, **kwargs): self.fmt = fmt self.args = args self.kwargs = kwargs
trusted_official_docs
CPython Docs
message format string, and that the logging package will call :func:`str` on that object to get the actual format string. Consider the following two classes:: class BraceMessage: def __init__(self, fmt, /, *args, **kwargs): self.fmt = fmt self.args = args self.kwargs = kwargs
message format string, and that the logging package will call :func:`str` on that object to get the actual format string. Consider the following two classes:: class BraceMessage: def __init__(self, fmt, /, *args, **kwargs): self.fmt = fmt self.args = args self.kwargs = kwargs
python, official-docs, cpython, P0
Local_Trusted_Corpus
63ddca86-7a2b-4a78-8945-d0b6b95a6bdf
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,658
supabase-export-v2
9b6c3ba449340a8b
'owner': ['pulse', 'pulse'], 'filename': 'chowntest.log', 'mode': 'w', 'encoding': 'utf-8', }, }, 'root': { 'handlers': ['file'], 'level': 'DEBUG', }, } In this example I am setting the ownership using the ``pulse`` user and group, just for the purposes of illustration. Putting it together into a working script, ``chow...
trusted_official_docs
CPython Docs
'owner': ['pulse', 'pulse'], 'filename': 'chowntest.log', 'mode': 'w', 'encoding': 'utf-8', }, }, 'root': { 'handlers': ['file'], 'level': 'DEBUG', }, } In this example I am setting the ownership using the ``pulse`` user and group, just for the purposes of illustration. Putting it together into a working script, ``chow...
'owner': ['pulse', 'pulse'], 'filename': 'chowntest.log', 'mode': 'w', 'encoding': 'utf-8', }, }, 'root': { 'handlers': ['file'], 'level': 'DEBUG', }, } In this example I am setting the ownership using the ``pulse`` user and group, just for the purposes of illustration. Putting it together into a working script, ``chow...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6445a72c-6d27-4c4a-85e8-d0ac5bd340de
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,524
supabase-export-v2
40d2184ffb1886ec
logger = logging.getLogger(__name__) at module level). It's probably one too many things to think about. Developers could also add the filter to a :class:`~logging.NullHandler` attached to their top-level logger, but this would not be invoked if an application developer attached a handler to a lower-level library logge...
trusted_official_docs
CPython Docs
logger = logging.getLogger(__name__) at module level). It's probably one too many things to think about. Developers could also add the filter to a :class:`~logging.NullHandler` attached to their top-level logger, but this would not be invoked if an application developer attached a handler to a lower-level library logge...
logger = logging.getLogger(__name__) at module level). It's probably one too many things to think about. Developers could also add the filter to a :class:`~logging.NullHandler` attached to their top-level logger, but this would not be invoked if an application developer attached a handler to a lower-level library logge...
python, official-docs, cpython, P0
Local_Trusted_Corpus
65448116-1324-43da-82d8-be26f1d3ce7a
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,400
supabase-export-v2
70662dd62be00640
logger = logging.getLogger(__name__) def useful(): # 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)
trusted_official_docs
CPython Docs
logger = logging.getLogger(__name__) def useful(): # 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)
logger = logging.getLogger(__name__) def useful(): # 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)
python, official-docs, cpython, P0
Local_Trusted_Corpus
656cf6d3-7d2e-41ed-b5ea-68d04d806d4d
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,490
supabase-export-v2
06cf010d929e15e9
.. code-block:: pycon >>> import logging >>> root = logging.getLogger() >>> root.setLevel(logging.DEBUG) >>> handler = logging.StreamHandler() >>> bf = logging.Formatter('{asctime} {name} {levelname:8s} {message}', ... style='{') >>> handler.setFormatter(bf) >>> root.addHandler(handler) >>> logger = logging.get...
trusted_official_docs
CPython Docs
.. code-block:: pycon >>> import logging >>> root = logging.getLogger() >>> root.setLevel(logging.DEBUG) >>> handler = logging.StreamHandler() >>> bf = logging.Formatter('{asctime} {name} {levelname:8s} {message}', ... style='{') >>> handler.setFormatter(bf) >>> root.addHandler(handler) >>> logger = logging.get...
.. code-block:: pycon >>> import logging >>> root = logging.getLogger() >>> root.setLevel(logging.DEBUG) >>> handler = logging.StreamHandler() >>> bf = logging.Formatter('{asctime} {name} {levelname:8s} {message}', ... style='{') >>> handler.setFormatter(bf) >>> root.addHandler(handler) >>> logger = logging.get...
python, official-docs, cpython, P0
Local_Trusted_Corpus
65981c8c-0816-4859-9c36-4cb416cffb0b
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,841
supabase-export-v2
c9ea07ce2e0f8b88
how to log to a GUI application. The `Qt <https://www.qt.io/>`_ framework is a popular cross-platform UI framework with Python bindings using :pypi:`PySide2` or :pypi:`PyQt5` libraries. The following example shows how to log to a Qt GUI. This introduces a simple ``QtHandler`` class which takes a callable, which should ...
trusted_official_docs
CPython Docs
how to log to a GUI application. The `Qt <https://www.qt.io/>`_ framework is a popular cross-platform UI framework with Python bindings using :pypi:`PySide2` or :pypi:`PyQt5` libraries. The following example shows how to log to a Qt GUI. This introduces a simple ``QtHandler`` class which takes a callable, which should ...
how to log to a GUI application. The `Qt <https://www.qt.io/>`_ framework is a popular cross-platform UI framework with Python bindings using :pypi:`PySide2` or :pypi:`PyQt5` libraries. The following example shows how to log to a Qt GUI. This introduces a simple ``QtHandler`` class which takes a callable, which should ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
65cc8f66-a983-4ecc-a751-a8f8d70a1704
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,807
supabase-export-v2
fe3e2b0e81f824ab
that we want to control the verbosity of the application via a command-line argument, defaulting to ``logging.INFO``. Here's one way that ``app.py`` could be written:: import argparse import importlib import logging import os import sys
trusted_official_docs
CPython Docs
that we want to control the verbosity of the application via a command-line argument, defaulting to ``logging.INFO``. Here's one way that ``app.py`` could be written:: import argparse import importlib import logging import os import sys
that we want to control the verbosity of the application via a command-line argument, defaulting to ``logging.INFO``. Here's one way that ``app.py`` could be written:: import argparse import importlib import logging import os import sys
python, official-docs, cpython, P0
Local_Trusted_Corpus
66072838-ee43-4bd1-9b53-b2ff1b3eb1b1
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,409
supabase-export-v2
d9d87c50f243263e
# Note that the format string includes references to request context information # such as HTTP method, client IP and username formatter = logging.Formatter('%(threadName)-11s %(appName)s %(name)-9s %(user)-6s %(ip)s %(method)-4s %(message)s')
trusted_official_docs
CPython Docs
# Note that the format string includes references to request context information # such as HTTP method, client IP and username formatter = logging.Formatter('%(threadName)-11s %(appName)s %(name)-9s %(user)-6s %(ip)s %(method)-4s %(message)s')
# Note that the format string includes references to request context information # such as HTTP method, client IP and username formatter = logging.Formatter('%(threadName)-11s %(appName)s %(name)-9s %(user)-6s %(ip)s %(method)-4s %(message)s')
python, official-docs, cpython, P0
Local_Trusted_Corpus
667d5617-d40c-49cf-b801-545a9609b6c9
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,863
supabase-export-v2
75553b9862c058ce
start_thread(self): self.worker = Worker() self.worker_thread = QtCore.QThread() self.worker.setObjectName('Worker') self.worker_thread.setObjectName('WorkerThread') # for qThreadName self.worker.moveToThread(self.worker_thread) # This will start an event loop in the worker thread self.worker_thread.start() def kill_th...
trusted_official_docs
CPython Docs
start_thread(self): self.worker = Worker() self.worker_thread = QtCore.QThread() self.worker.setObjectName('Worker') self.worker_thread.setObjectName('WorkerThread') # for qThreadName self.worker.moveToThread(self.worker_thread) # This will start an event loop in the worker thread self.worker_thread.start() def kill_th...
start_thread(self): self.worker = Worker() self.worker_thread = QtCore.QThread() self.worker.setObjectName('Worker') self.worker_thread.setObjectName('WorkerThread') # for qThreadName self.worker.moveToThread(self.worker_thread) # This will start an event loop in the worker thread self.worker_thread.start() def kill_th...
python, official-docs, cpython, P0
Local_Trusted_Corpus
669a4cca-94f1-487f-a5b5-43338b7e480b
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,774
supabase-export-v2
bf2887c68e7cc9bd
class UTCFormatter(logging.Formatter): converter = time.gmtime LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'utc': { '()': UTCFormatter, 'format': '%(asctime)s %(message)s', }, 'local': { 'format': '%(asctime)s %(message)s', } }, 'handlers': { 'console1': { 'class': 'loggin...
trusted_official_docs
CPython Docs
class UTCFormatter(logging.Formatter): converter = time.gmtime LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'utc': { '()': UTCFormatter, 'format': '%(asctime)s %(message)s', }, 'local': { 'format': '%(asctime)s %(message)s', } }, 'handlers': { 'console1': { 'class': 'loggin...
class UTCFormatter(logging.Formatter): converter = time.gmtime LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'utc': { '()': UTCFormatter, 'format': '%(asctime)s %(message)s', }, 'local': { 'format': '%(asctime)s %(message)s', } }, 'handlers': { 'console1': { 'class': 'loggin...
python, official-docs, cpython, P0
Local_Trusted_Corpus
66ad80e7-dbc0-440a-8468-9c1d8a8bf725
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,668
supabase-export-v2
edbd91e4304c47db
that supports :func:`dictConfig` - namely, Python 2.7, 3.2 or later. With pre-3.3 versions, you would need to implement the actual ownership change using e.g. :func:`os.chown`. In practice, the handler-creating function may be in a utility module somewhere in your project. Instead of the line in the configuration::
trusted_official_docs
CPython Docs
that supports :func:`dictConfig` - namely, Python 2.7, 3.2 or later. With pre-3.3 versions, you would need to implement the actual ownership change using e.g. :func:`os.chown`. In practice, the handler-creating function may be in a utility module somewhere in your project. Instead of the line in the configuration::
that supports :func:`dictConfig` - namely, Python 2.7, 3.2 or later. With pre-3.3 versions, you would need to implement the actual ownership change using e.g. :func:`os.chown`. In practice, the handler-creating function may be in a utility module somewhere in your project. Instead of the line in the configuration::
python, official-docs, cpython, P0
Local_Trusted_Corpus
66c2dcae-1729-437b-bd93-0db31c4d9d02
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,785
supabase-export-v2
542b4f0300db2200
class LoggingContext: def __init__(self, logger, level=None, handler=None, close=True): self.logger = logger self.level = level self.handler = handler self.close = close 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....
trusted_official_docs
CPython Docs
class LoggingContext: def __init__(self, logger, level=None, handler=None, close=True): self.logger = logger self.level = level self.handler = handler self.close = close 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....
class LoggingContext: def __init__(self, logger, level=None, handler=None, close=True): self.logger = logger self.level = level self.handler = handler self.close = close 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....
python, official-docs, cpython, P0
Local_Trusted_Corpus
66deafdd-cb38-4ee0-b3cb-cc71550b0179
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,593
supabase-export-v2
24fc3adb7ed6a48d
root = logging.getLogger() root.setLevel(logging.INFO) root.addHandler(rh) f = logging.Formatter('%(asctime)s %(message)s') rh.setFormatter(f) for i in range(1000): root.info(f'Message no. {i + 1}') After running this, you will see six new files, five of which are compressed:
trusted_official_docs
CPython Docs
root = logging.getLogger() root.setLevel(logging.INFO) root.addHandler(rh) f = logging.Formatter('%(asctime)s %(message)s') rh.setFormatter(f) for i in range(1000): root.info(f'Message no. {i + 1}') After running this, you will see six new files, five of which are compressed:
root = logging.getLogger() root.setLevel(logging.INFO) root.addHandler(rh) f = logging.Formatter('%(asctime)s %(message)s') rh.setFormatter(f) for i in range(1000): root.info(f'Message no. {i + 1}') After running this, you will see six new files, five of which are compressed:
python, official-docs, cpython, P0
Local_Trusted_Corpus
67178cc8-eb99-463a-a821-25f7a0b632bb
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,249
supabase-export-v2
e05814988e993fc3
logger1 = logging.getLogger('myapp.area1') logger2 = logging.getLogger('myapp.area2') logger1.debug('Quick zephyrs blow, vexing daft Jim.') logger1.info('How quickly daft jumping zebras vex.') logger2.warning('Jail zesty vixen who grabbed pay from quack.') logger2.error('The five boxing wizards jump quickly.')
trusted_official_docs
CPython Docs
logger1 = logging.getLogger('myapp.area1') logger2 = logging.getLogger('myapp.area2') logger1.debug('Quick zephyrs blow, vexing daft Jim.') logger1.info('How quickly daft jumping zebras vex.') logger2.warning('Jail zesty vixen who grabbed pay from quack.') logger2.error('The five boxing wizards jump quickly.')
logger1 = logging.getLogger('myapp.area1') logger2 = logging.getLogger('myapp.area2') logger1.debug('Quick zephyrs blow, vexing daft Jim.') logger1.info('How quickly daft jumping zebras vex.') logger2.warning('Jail zesty vixen who grabbed pay from quack.') logger2.error('The five boxing wizards jump quickly.')
python, official-docs, cpython, P0
Local_Trusted_Corpus
681db98a-fff2-4a84-92d9-372ada188eec
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,261
supabase-export-v2
b1493ed508c2c2ab
Custom handling of levels ------------------------- Sometimes, you might want to do something slightly different from the standard handling of levels in handlers, where all levels above a threshold get processed by a handler. To do this, you need to use filters. Let's look at a scenario where you want to arrange things...
trusted_official_docs
CPython Docs
Custom handling of levels ------------------------- Sometimes, you might want to do something slightly different from the standard handling of levels in handlers, where all levels above a threshold get processed by a handler. To do this, you need to use filters. Let's look at a scenario where you want to arrange things...
Custom handling of levels ------------------------- Sometimes, you might want to do something slightly different from the standard handling of levels in handlers, where all levels above a threshold get processed by a handler. To do this, you need to use filters. Let's look at a scenario where you want to arrange things...
python, official-docs, cpython, P0
Local_Trusted_Corpus
688aebbe-8a6f-41cc-9f36-791583cff140
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,621
supabase-export-v2
4d19ef70b836d158
which include a BOM, an optional pure-ASCII sequence before it and arbitrary Unicode after it, encoded using UTF-8, then you need to do the following: #. Attach a :class:`~logging.Formatter` instance to your :class:`~logging.handlers.SysLogHandler` instance, with a format string such as::
trusted_official_docs
CPython Docs
which include a BOM, an optional pure-ASCII sequence before it and arbitrary Unicode after it, encoded using UTF-8, then you need to do the following: #. Attach a :class:`~logging.Formatter` instance to your :class:`~logging.handlers.SysLogHandler` instance, with a format string such as::
which include a BOM, an optional pure-ASCII sequence before it and arbitrary Unicode after it, encoded using UTF-8, then you need to do the following: #. Attach a :class:`~logging.Formatter` instance to your :class:`~logging.handlers.SysLogHandler` instance, with a format string such as::
python, official-docs, cpython, P0
Local_Trusted_Corpus
6901cef8-7b78-4288-9988-96ef509e0df1
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,694
supabase-export-v2
3c9f0b128d53052c
>>> __ = DollarMessage >>> print(__('Message with $num $what', num=2, what='placeholders')) Message with 2 placeholders >>> One thing to note is that you pay no significant performance penalty with this approach: the actual formatting happens not when you make the logging call, but when (and if) the logged message is a...
trusted_official_docs
CPython Docs
>>> __ = DollarMessage >>> print(__('Message with $num $what', num=2, what='placeholders')) Message with 2 placeholders >>> One thing to note is that you pay no significant performance penalty with this approach: the actual formatting happens not when you make the logging call, but when (and if) the logged message is a...
>>> __ = DollarMessage >>> print(__('Message with $num $what', num=2, what='placeholders')) Message with 2 placeholders >>> One thing to note is that you pay no significant performance penalty with this approach: the actual formatting happens not when you make the logging call, but when (and if) the logged message is a...
python, official-docs, cpython, P0
Local_Trusted_Corpus
69079799-751a-4a35-8e1c-02889bbbeb7a
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,443
supabase-export-v2
64b25787f00608a3
def listener_configurer(): root = logging.getLogger() h = logging.handlers.RotatingFileHandler('mptest.log', 'a', 300, 10) f = logging.Formatter('%(asctime)s %(processName)-10s %(name)s %(levelname)-8s %(message)s') h.setFormatter(f) root.addHandler(h) # This is the listener process top-level loop: wait for logging eve...
trusted_official_docs
CPython Docs
def listener_configurer(): root = logging.getLogger() h = logging.handlers.RotatingFileHandler('mptest.log', 'a', 300, 10) f = logging.Formatter('%(asctime)s %(processName)-10s %(name)s %(levelname)-8s %(message)s') h.setFormatter(f) root.addHandler(h) # This is the listener process top-level loop: wait for logging eve...
def listener_configurer(): root = logging.getLogger() h = logging.handlers.RotatingFileHandler('mptest.log', 'a', 300, 10) f = logging.Formatter('%(asctime)s %(processName)-10s %(name)s %(levelname)-8s %(message)s') h.setFormatter(f) root.addHandler(h) # This is the listener process top-level loop: wait for logging eve...
python, official-docs, cpython, P0
Local_Trusted_Corpus
691fde1b-5dec-4ed1-95b0-4f7741f7d372
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,932
supabase-export-v2
a1542e8637929093
... 2025-07-02 13:54:47,234 DEBUG Another single line 2025-07-02 13:54:47,234 DEBUG Multiple lines: 2025-07-02 13:54:47,234 DEBUG fool me ... 2025-07-02 13:54:47,234 DEBUG can't get fooled again If, on the other hand, you are concerned about `log injection <https://owasp.org/www-community/attacks/Log_Injection>`_, you ...
trusted_official_docs
CPython Docs
... 2025-07-02 13:54:47,234 DEBUG Another single line 2025-07-02 13:54:47,234 DEBUG Multiple lines: 2025-07-02 13:54:47,234 DEBUG fool me ... 2025-07-02 13:54:47,234 DEBUG can't get fooled again If, on the other hand, you are concerned about `log injection <https://owasp.org/www-community/attacks/Log_Injection>`_, you ...
... 2025-07-02 13:54:47,234 DEBUG Another single line 2025-07-02 13:54:47,234 DEBUG Multiple lines: 2025-07-02 13:54:47,234 DEBUG fool me ... 2025-07-02 13:54:47,234 DEBUG can't get fooled again If, on the other hand, you are concerned about `log injection <https://owasp.org/www-community/attacks/Log_Injection>`_, you ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
69369f4b-6052-44c7-bd82-e2da3f32e8b0
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,588
supabase-export-v2
132378bd0131374c
example of how you can define a namer and rotator is given in the following runnable script, which shows gzip compression of the log file:: import gzip import logging import logging.handlers import os import shutil
trusted_official_docs
CPython Docs
example of how you can define a namer and rotator is given in the following runnable script, which shows gzip compression of the log file:: import gzip import logging import logging.handlers import os import shutil
example of how you can define a namer and rotator is given in the following runnable script, which shows gzip compression of the log file:: import gzip import logging import logging.handlers import os import shutil
python, official-docs, cpython, P0
Local_Trusted_Corpus
69a65100-99de-401a-ba1d-22e210347b3a
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,753
supabase-export-v2
b220a88137d84512
logged at DEBUG Actually logged at INFO Actually logged at WARNING Actually logged at ERROR about to log at CRITICAL ... Actually logged at CRITICAL As you can see, actual logging output only occurs when an event is logged whose severity is ERROR or greater, but in that case, any previous events at lower severities are...
trusted_official_docs
CPython Docs
logged at DEBUG Actually logged at INFO Actually logged at WARNING Actually logged at ERROR about to log at CRITICAL ... Actually logged at CRITICAL As you can see, actual logging output only occurs when an event is logged whose severity is ERROR or greater, but in that case, any previous events at lower severities are...
logged at DEBUG Actually logged at INFO Actually logged at WARNING Actually logged at ERROR about to log at CRITICAL ... Actually logged at CRITICAL As you can see, actual logging output only occurs when an event is logged whose severity is ERROR or greater, but in that case, any previous events at lower severities are...
python, official-docs, cpython, P0
Local_Trusted_Corpus
69b181bd-2341-4d89-abeb-2eb76d5ccf26
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,940
supabase-export-v2
0c69ea87a873c723
line 2025-07-09 06:47:33,783 DEBUG Multiple lines:\nfool me once ... 2025-07-09 06:47:33,783 DEBUG Another single line 2025-07-09 06:47:33,783 DEBUG Multiple lines:\nfool me ...\ncan't get fooled again Escaping behaviour can't be the stdlib default , as it would break backwards compatibility.
trusted_official_docs
CPython Docs
line 2025-07-09 06:47:33,783 DEBUG Multiple lines:\nfool me once ... 2025-07-09 06:47:33,783 DEBUG Another single line 2025-07-09 06:47:33,783 DEBUG Multiple lines:\nfool me ...\ncan't get fooled again Escaping behaviour can't be the stdlib default , as it would break backwards compatibility.
line 2025-07-09 06:47:33,783 DEBUG Multiple lines:\nfool me once ... 2025-07-09 06:47:33,783 DEBUG Another single line 2025-07-09 06:47:33,783 DEBUG Multiple lines:\nfool me ...\ncan't get fooled again Escaping behaviour can't be the stdlib default , as it would break backwards compatibility.
python, official-docs, cpython, P0
Local_Trusted_Corpus
6a48b241-d53c-49cf-b3c3-d64b5ffe8757
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,943
supabase-export-v2
b420c580608070ff
Patterns to avoid ----------------- Although the preceding sections have described ways of doing things you might need to do or deal with, it is worth mentioning some usage patterns which are *unhelpful*, and which should therefore be avoided in most cases. The following sections are in no particular order.
trusted_official_docs
CPython Docs
Patterns to avoid ----------------- Although the preceding sections have described ways of doing things you might need to do or deal with, it is worth mentioning some usage patterns which are *unhelpful*, and which should therefore be avoided in most cases. The following sections are in no particular order.
Patterns to avoid ----------------- Although the preceding sections have described ways of doing things you might need to do or deal with, it is worth mentioning some usage patterns which are *unhelpful*, and which should therefore be avoided in most cases. The following sections are in no particular order.
python, official-docs, cpython, P0
Local_Trusted_Corpus
6b6de953-9af3-42b0-bb88-c9e8b29325c6
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,600
supabase-export-v2
3d9be35050b6d72d
Here's the script - the docstrings and the comments hopefully explain how it works:: import logging import logging.config import logging.handlers from multiprocessing import Process, Queue, Event, current_process import os import random import time
trusted_official_docs
CPython Docs
Here's the script - the docstrings and the comments hopefully explain how it works:: import logging import logging.config import logging.handlers from multiprocessing import Process, Queue, Event, current_process import os import random import time
Here's the script - the docstrings and the comments hopefully explain how it works:: import logging import logging.config import logging.handlers from multiprocessing import Process, Queue, Event, current_process import os import random import time
python, official-docs, cpython, P0
Local_Trusted_Corpus
6c1d7c75-10ea-4a9a-a816-9b4e179c47e6
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,626
supabase-export-v2
5b093c066ae6e02a
you like; if the data which appears there after substitution contains characters outside the ASCII range, that's fine -- it will be encoded using UTF-8. The formatted message *will* be encoded using UTF-8 encoding by ``SysLogHandler``. If you follow the above rules, you should be able to produce :rfc:`5424`-compliant m...
trusted_official_docs
CPython Docs
you like; if the data which appears there after substitution contains characters outside the ASCII range, that's fine -- it will be encoded using UTF-8. The formatted message *will* be encoded using UTF-8 encoding by ``SysLogHandler``. If you follow the above rules, you should be able to produce :rfc:`5424`-compliant m...
you like; if the data which appears there after substitution contains characters outside the ASCII range, that's fine -- it will be encoded using UTF-8. The formatted message *will* be encoded using UTF-8 encoding by ``SysLogHandler``. If you follow the above rules, you should be able to produce :rfc:`5424`-compliant m...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6ce34b88-265c-464a-a098-ed0f3c1393b3
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,333
supabase-export-v2
dde380ba5a1af742
This basically logs the record using whatever logging policy is configured locally. """ def handle(self): """ Handle multiple requests - each expected to be a 4-byte length, followed by the LogRecord in pickle format. Logs the record according to whatever policy is configured locally. """ while True: chunk = self...
trusted_official_docs
CPython Docs
This basically logs the record using whatever logging policy is configured locally. """ def handle(self): """ Handle multiple requests - each expected to be a 4-byte length, followed by the LogRecord in pickle format. Logs the record according to whatever policy is configured locally. """ while True: chunk = self...
This basically logs the record using whatever logging policy is configured locally. """ def handle(self): """ Handle multiple requests - each expected to be a 4-byte length, followed by the LogRecord in pickle format. Logs the record according to whatever policy is configured locally. """ while True: chunk = self...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6e719690-3705-4f52-b3ec-8a12d2b80c3f
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,506
supabase-export-v2
3e5194bafd990474
arguments, not just the format string. That's because the __ notation is just syntax sugar for a constructor call to one of the :samp:`{XXX}Message` classes. If you prefer, you can use a :class:`LoggerAdapter` to achieve a similar effect to the above, as in the following example::
trusted_official_docs
CPython Docs
arguments, not just the format string. That's because the __ notation is just syntax sugar for a constructor call to one of the :samp:`{XXX}Message` classes. If you prefer, you can use a :class:`LoggerAdapter` to achieve a similar effect to the above, as in the following example::
arguments, not just the format string. That's because the __ notation is just syntax sugar for a constructor call to one of the :samp:`{XXX}Message` classes. If you prefer, you can use a :class:`LoggerAdapter` to achieve a similar effect to the above, as in the following example::
python, official-docs, cpython, P0
Local_Trusted_Corpus
6ffbf347-e867-4597-a613-f64d77797688
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,424
supabase-export-v2
09c106b91699d795
.. code-block:: shell ~/logging-contextual-webapp$ python main.py app1 processed 51 requests app2 processed 49 requests ~/logging-contextual-webapp$ wc -l *.log 153 app1.log 147 app2.log 300 app.log 600 total ~/logging-contextual-webapp$ head -3 app1.log Thread-3 (process_request) app1 __main__ jim 192.168.3.2...
trusted_official_docs
CPython Docs
.. code-block:: shell ~/logging-contextual-webapp$ python main.py app1 processed 51 requests app2 processed 49 requests ~/logging-contextual-webapp$ wc -l *.log 153 app1.log 147 app2.log 300 app.log 600 total ~/logging-contextual-webapp$ head -3 app1.log Thread-3 (process_request) app1 __main__ jim 192.168.3.2...
.. code-block:: shell ~/logging-contextual-webapp$ python main.py app1 processed 51 requests app2 processed 49 requests ~/logging-contextual-webapp$ wc -l *.log 153 app1.log 147 app2.log 300 app.log 600 total ~/logging-contextual-webapp$ head -3 app1.log Thread-3 (process_request) app1 __main__ jim 192.168.3.2...
python, official-docs, cpython, P0
Local_Trusted_Corpus
706b5a29-f531-4d02-b3d1-0435adb82631
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,307
supabase-export-v2
78a545c3c1bcf827
do their work without blocking the thread you're logging from. This is common in web applications, though of course it also occurs in other scenarios. A common culprit which demonstrates sluggish behaviour is the :class:`SMTPHandler`: sending emails can take a long time, for a number of reasons outside the developer's ...
trusted_official_docs
CPython Docs
do their work without blocking the thread you're logging from. This is common in web applications, though of course it also occurs in other scenarios. A common culprit which demonstrates sluggish behaviour is the :class:`SMTPHandler`: sending emails can take a long time, for a number of reasons outside the developer's ...
do their work without blocking the thread you're logging from. This is common in web applications, though of course it also occurs in other scenarios. A common culprit which demonstrates sluggish behaviour is the :class:`SMTPHandler`: sending emails can take a long time, for a number of reasons outside the developer's ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
71808e99-b5aa-4f42-87eb-64a00830fcff
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,530
supabase-export-v2
909dcaff590e7ab0
logging.setLogRecordFactory(record_factory) This pattern allows different libraries to chain factories together, and as long as they don't overwrite each other's attributes or unintentionally overwrite the attributes provided as standard, there should be no surprises. However, it should be borne in mind that each link ...
trusted_official_docs
CPython Docs
logging.setLogRecordFactory(record_factory) This pattern allows different libraries to chain factories together, and as long as they don't overwrite each other's attributes or unintentionally overwrite the attributes provided as standard, there should be no surprises. However, it should be borne in mind that each link ...
logging.setLogRecordFactory(record_factory) This pattern allows different libraries to chain factories together, and as long as they don't overwrite each other's attributes or unintentionally overwrite the attributes provided as standard, there should be no surprises. However, it should be borne in mind that each link ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
71c481d7-f476-4bd1-8a3d-688be0ccc0c2
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,583
supabase-export-v2
8ef9082b93d7a598
configuration dictionary - it's taken from the `documentation on the Django project <https://docs.djangoproject.com/en/stable/topics/logging/#configuring-logging>`_. This dictionary is passed to :func:`~config.dictConfig` to put the configuration into effect:: LOGGING = { 'version': 1, 'disable_existing_loggers': Fal...
trusted_official_docs
CPython Docs
configuration dictionary - it's taken from the `documentation on the Django project <https://docs.djangoproject.com/en/stable/topics/logging/#configuring-logging>`_. This dictionary is passed to :func:`~config.dictConfig` to put the configuration into effect:: LOGGING = { 'version': 1, 'disable_existing_loggers': Fal...
configuration dictionary - it's taken from the `documentation on the Django project <https://docs.djangoproject.com/en/stable/topics/logging/#configuring-logging>`_. This dictionary is passed to :func:`~config.dictConfig` to put the configuration into effect:: LOGGING = { 'version': 1, 'disable_existing_loggers': Fal...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7324f44c-f3bf-4a4d-bb9c-b3202f956749
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,799
supabase-export-v2
506f1d72db93360e
.. code-block:: shell-session $ python logctx.py >/dev/null 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. 6. This should appear just once on stderr.
trusted_official_docs
CPython Docs
.. code-block:: shell-session $ python logctx.py >/dev/null 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. 6. This should appear just once on stderr.
.. code-block:: shell-session $ python logctx.py >/dev/null 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. 6. This should appear just once on stderr.
python, official-docs, cpython, P0
Local_Trusted_Corpus
73362603-6970-4752-bff5-ca2e9d268aee
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,330
supabase-export-v2
397756d2476d4da9
At the receiving end, you can set up a receiver using the :mod:`socketserver` module. Here is a basic working example:: import pickle import logging import logging.handlers import socketserver import struct
trusted_official_docs
CPython Docs
At the receiving end, you can set up a receiver using the :mod:`socketserver` module. Here is a basic working example:: import pickle import logging import logging.handlers import socketserver import struct
At the receiving end, you can set up a receiver using the :mod:`socketserver` module. Here is a basic working example:: import pickle import logging import logging.handlers import socketserver import struct
python, official-docs, cpython, P0
Local_Trusted_Corpus
733e1447-9f59-40e3-9bcb-26c96a8ebd3b
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,654
supabase-export-v2
fb2271386e67e585
done using :func:`shutil.chown`, but the file handlers in the stdlib don't offer built-in support. You can customize handler creation using a plain function such as:: def owned_file_handler(filename, mode='a', encoding=None, owner=None): if owner: if not os.path.exists(filename): open(filename, 'a').close() shutil....
trusted_official_docs
CPython Docs
done using :func:`shutil.chown`, but the file handlers in the stdlib don't offer built-in support. You can customize handler creation using a plain function such as:: def owned_file_handler(filename, mode='a', encoding=None, owner=None): if owner: if not os.path.exists(filename): open(filename, 'a').close() shutil....
done using :func:`shutil.chown`, but the file handlers in the stdlib don't offer built-in support. You can customize handler creation using a plain function such as:: def owned_file_handler(filename, mode='a', encoding=None, owner=None): if owner: if not os.path.exists(filename): open(filename, 'a').close() shutil....
python, official-docs, cpython, P0
Local_Trusted_Corpus
74b3d0ef-5c54-47cb-9213-654ccb97c906
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,619
supabase-export-v2
e42cb3d9f9a3f4bf
optional pure-ASCII component, followed by a UTF-8 Byte Order Mark (BOM), followed by Unicode encoded using UTF-8. (See the :rfc:`relevant section of the specification <5424#section-6>`.) In Python 3.1, code was added to :class:`~logging.handlers.SysLogHandler` to insert a BOM into the message, but unfortunately, it wa...
trusted_official_docs
CPython Docs
optional pure-ASCII component, followed by a UTF-8 Byte Order Mark (BOM), followed by Unicode encoded using UTF-8. (See the :rfc:`relevant section of the specification <5424#section-6>`.) In Python 3.1, code was added to :class:`~logging.handlers.SysLogHandler` to insert a BOM into the message, but unfortunately, it wa...
optional pure-ASCII component, followed by a UTF-8 Byte Order Mark (BOM), followed by Unicode encoded using UTF-8. (See the :rfc:`relevant section of the specification <5424#section-6>`.) In Python 3.1, code was added to :class:`~logging.handlers.SysLogHandler` to insert a BOM into the message, but unfortunately, it wa...
python, official-docs, cpython, P0
Local_Trusted_Corpus
74eb7281-fcf8-4e4c-bfeb-6a62b4ab13d5
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,329
supabase-export-v2
f30d4210fc966f35
zephyrs blow, vexing daft Jim.') logger1.info('How quickly daft jumping zebras vex.') logger2.warning('Jail zesty vixen who grabbed pay from quack.') logger2.error('The five boxing wizards jump quickly.') At the receiving end, you can set up a receiver using the :mod:`socketserver` module. Here is a basic working examp...
trusted_official_docs
CPython Docs
zephyrs blow, vexing daft Jim.') logger1.info('How quickly daft jumping zebras vex.') logger2.warning('Jail zesty vixen who grabbed pay from quack.') logger2.error('The five boxing wizards jump quickly.') At the receiving end, you can set up a receiver using the :mod:`socketserver` module. Here is a basic working examp...
zephyrs blow, vexing daft Jim.') logger1.info('How quickly daft jumping zebras vex.') logger2.warning('Jail zesty vixen who grabbed pay from quack.') logger2.error('The five boxing wizards jump quickly.') At the receiving end, you can set up a receiver using the :mod:`socketserver` module. Here is a basic working examp...
python, official-docs, cpython, P0
Local_Trusted_Corpus
759927c4-c48c-4d24-a57c-cca77418257d
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,602
supabase-export-v2
9b061ef7c43cbbbd
loggers based on the name in the received record, which then get dispatched, by the logging system, to the handlers configured for those loggers. """ def handle(self, record): if record.name == "root": logger = logging.getLogger() else: logger = logging.getLogger(record.name)
trusted_official_docs
CPython Docs
loggers based on the name in the received record, which then get dispatched, by the logging system, to the handlers configured for those loggers. """ def handle(self, record): if record.name == "root": logger = logging.getLogger() else: logger = logging.getLogger(record.name)
loggers based on the name in the received record, which then get dispatched, by the logging system, to the handlers configured for those loggers. """ def handle(self, record): if record.name == "root": logger = logging.getLogger() else: logger = logging.getLogger(record.name)
python, official-docs, cpython, P0
Local_Trusted_Corpus
765ae5ba-bddb-4f26-a5a5-31dced39d6e3
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,394
supabase-export-v2
145e362fa603614f
Use of ``contextvars`` ---------------------- Since Python 3.7, the :mod:`contextvars` module has provided context-local storage which works for both :mod:`threading` and :mod:`asyncio` processing needs. This type of storage may thus be generally preferable to thread-locals. The following example shows how, in a multi-...
trusted_official_docs
CPython Docs
Use of ``contextvars`` ---------------------- Since Python 3.7, the :mod:`contextvars` module has provided context-local storage which works for both :mod:`threading` and :mod:`asyncio` processing needs. This type of storage may thus be generally preferable to thread-locals. The following example shows how, in a multi-...
Use of ``contextvars`` ---------------------- Since Python 3.7, the :mod:`contextvars` module has provided context-local storage which works for both :mod:`threading` and :mod:`asyncio` processing needs. This type of storage may thus be generally preferable to thread-locals. The following example shows how, in a multi-...
python, official-docs, cpython, P0
Local_Trusted_Corpus
765f4753-c4f9-4910-83cc-11a3fdbe83a6
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,874
supabase-export-v2
5235500e03458f7f
be able to log to a syslog server with support for it, you can do so with a subclassed handler which looks something like this:: import datetime as dt import logging.handlers import re import socket import time
trusted_official_docs
CPython Docs
be able to log to a syslog server with support for it, you can do so with a subclassed handler which looks something like this:: import datetime as dt import logging.handlers import re import socket import time
be able to log to a syslog server with support for it, you can do so with a subclassed handler which looks something like this:: import datetime as dt import logging.handlers import re import socket import time
python, official-docs, cpython, P0
Local_Trusted_Corpus
779894ce-c7db-477c-8eae-83883c57162c
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,418
supabase-export-v2
cb15cc890b02dbee
= WebApp('app2') apps = [app1, app2] threads = [] # Add a common handler which will capture all events handler = logging.FileHandler('app.log', 'w') handler.setFormatter(formatter) root.addHandler(handler) # Generate calls to process requests for i in range(options.count): try: # Pick an app at random and a request ...
trusted_official_docs
CPython Docs
= WebApp('app2') apps = [app1, app2] threads = [] # Add a common handler which will capture all events handler = logging.FileHandler('app.log', 'w') handler.setFormatter(formatter) root.addHandler(handler) # Generate calls to process requests for i in range(options.count): try: # Pick an app at random and a request ...
= WebApp('app2') apps = [app1, app2] threads = [] # Add a common handler which will capture all events handler = logging.FileHandler('app.log', 'w') handler.setFormatter(formatter) root.addHandler(handler) # Generate calls to process requests for i in range(options.count): try: # Pick an app at random and a request ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
788cb518-7642-4724-ab4c-f4723c1d5150
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,559
supabase-export-v2
2447af7785943bd6
# The b'' subscription matches all topics topics = kwargs.pop('topics', None) or b'' socket.subscribe(topics) # We treat the socket as a queue super().__init__(socket, *handlers, **kwargs) def dequeue(self, block): data = None # Keep looping while not interrupted and no data received over the # socket while not int...
trusted_official_docs
CPython Docs
# The b'' subscription matches all topics topics = kwargs.pop('topics', None) or b'' socket.subscribe(topics) # We treat the socket as a queue super().__init__(socket, *handlers, **kwargs) def dequeue(self, block): data = None # Keep looping while not interrupted and no data received over the # socket while not int...
# The b'' subscription matches all topics topics = kwargs.pop('topics', None) or b'' socket.subscribe(topics) # We treat the socket as a queue super().__init__(socket, *handlers, **kwargs) def dequeue(self, block): data = None # Keep looping while not interrupted and no data received over the # socket while not int...
python, official-docs, cpython, P0
Local_Trusted_Corpus
78e2773b-56e4-485f-aefa-8c436371a6b5
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,324
supabase-export-v2
24b58104d13c302a
import logging, logging.handlers rootLogger = logging.getLogger() rootLogger.setLevel(logging.DEBUG) socketHandler = logging.handlers.SocketHandler('localhost', logging.handlers.DEFAULT_TCP_LOGGING_PORT) # don't bother with a formatter, since a socket handler sends the event as # an unformatted pickle rootLogger....
trusted_official_docs
CPython Docs
import logging, logging.handlers rootLogger = logging.getLogger() rootLogger.setLevel(logging.DEBUG) socketHandler = logging.handlers.SocketHandler('localhost', logging.handlers.DEFAULT_TCP_LOGGING_PORT) # don't bother with a formatter, since a socket handler sends the event as # an unformatted pickle rootLogger....
import logging, logging.handlers rootLogger = logging.getLogger() rootLogger.setLevel(logging.DEBUG) socketHandler = logging.handlers.SocketHandler('localhost', logging.handlers.DEFAULT_TCP_LOGGING_PORT) # don't bother with a formatter, since a socket handler sends the event as # an unformatted pickle rootLogger....
python, official-docs, cpython, P0
Local_Trusted_Corpus
790a921e-0b83-415f-a5fd-ec24fb74285d
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,582
supabase-export-v2
a442b31fffd1d570
An example dictionary-based configuration ----------------------------------------- Below is an example of a logging configuration dictionary - it's taken from the `documentation on the Django project <https://docs.djangoproject.com/en/stable/topics/logging/#configuring-logging>`_. This dictionary is passed to :func:`~...
trusted_official_docs
CPython Docs
An example dictionary-based configuration ----------------------------------------- Below is an example of a logging configuration dictionary - it's taken from the `documentation on the Django project <https://docs.djangoproject.com/en/stable/topics/logging/#configuring-logging>`_. This dictionary is passed to :func:`~...
An example dictionary-based configuration ----------------------------------------- Below is an example of a logging configuration dictionary - it's taken from the `documentation on the Django project <https://docs.djangoproject.com/en/stable/topics/logging/#configuring-logging>`_. This dictionary is passed to :func:`~...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7929e2c2-a30c-4da3-acfd-06c3970c5dbe
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,491
supabase-export-v2
fe2e58d9b5551127
DEBUG message >>> logger.critical('This is a CRITICAL message') 2010-10-28 15:12:11,526 foo.bar CRITICAL This is a CRITICAL message >>> df = logging.Formatter('$asctime $name ${levelname} $message', ... style='$') >>> handler.setFormatter(df) >>> logger.debug('This is a DEBUG message') 2010-10-28 15:13:06,924 foo.ba...
trusted_official_docs
CPython Docs
DEBUG message >>> logger.critical('This is a CRITICAL message') 2010-10-28 15:12:11,526 foo.bar CRITICAL This is a CRITICAL message >>> df = logging.Formatter('$asctime $name ${levelname} $message', ... style='$') >>> handler.setFormatter(df) >>> logger.debug('This is a DEBUG message') 2010-10-28 15:13:06,924 foo.ba...
DEBUG message >>> logger.critical('This is a CRITICAL message') 2010-10-28 15:12:11,526 foo.bar CRITICAL This is a CRITICAL message >>> df = logging.Formatter('$asctime $name ${levelname} $message', ... style='$') >>> handler.setFormatter(df) >>> logger.debug('This is a DEBUG message') 2010-10-28 15:13:06,924 foo.ba...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7a860944-f08d-45e5-b57e-38622078cb6e
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,837
supabase-export-v2
009d8a58086ca995
$ python app.py --log-level WARNING start foo $ python app.py --log-level WARNING stop foo bar $ python app.py --log-level WARNING restart foo bar baz In this case, the commands don't print anything to the console, since nothing at ``WARNING`` level or above is logged by them.
trusted_official_docs
CPython Docs
$ python app.py --log-level WARNING start foo $ python app.py --log-level WARNING stop foo bar $ python app.py --log-level WARNING restart foo bar baz In this case, the commands don't print anything to the console, since nothing at ``WARNING`` level or above is logged by them.
$ python app.py --log-level WARNING start foo $ python app.py --log-level WARNING stop foo bar $ python app.py --log-level WARNING restart foo bar baz In this case, the commands don't print anything to the console, since nothing at ``WARNING`` level or above is logged by them.
python, official-docs, cpython, P0
Local_Trusted_Corpus
7aa7cca1-7881-4348-975e-ea6bc7aa31b0
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,944
supabase-export-v2
f1543fe6fd9850f8
worth mentioning some usage patterns which are *unhelpful*, and which should therefore be avoided in most cases. The following sections are in no particular order. Opening the same log file multiple times ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
trusted_official_docs
CPython Docs
worth mentioning some usage patterns which are *unhelpful*, and which should therefore be avoided in most cases. The following sections are in no particular order. Opening the same log file multiple times ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
worth mentioning some usage patterns which are *unhelpful*, and which should therefore be avoided in most cases. The following sections are in no particular order. Opening the same log file multiple times ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
python, official-docs, cpython, P0
Local_Trusted_Corpus
7afbdfc3-4496-4bf2-8b3b-6f884e966177
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,346
supabase-export-v2
58efeb4194aab068
alternative serialization scheme by overriding the :meth:`~SocketHandler.makePickle` method and implementing your alternative there, as well as adapting the above script to use your alternative serialization. Running a logging socket listener in production ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
trusted_official_docs
CPython Docs
alternative serialization scheme by overriding the :meth:`~SocketHandler.makePickle` method and implementing your alternative there, as well as adapting the above script to use your alternative serialization. Running a logging socket listener in production ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
alternative serialization scheme by overriding the :meth:`~SocketHandler.makePickle` method and implementing your alternative there, as well as adapting the above script to use your alternative serialization. Running a logging socket listener in production ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
python, official-docs, cpython, P0
Local_Trusted_Corpus
7bb4d59d-0b09-474f-af5a-8c4cc24c82eb
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,253
supabase-export-v2
496cc225a66711ff
quickly daft jumping zebras vex. myapp.area2 : WARNING Jail zesty vixen who grabbed pay from quack. myapp.area2 : ERROR The five boxing wizards jump quickly. and in the file you will see something like
trusted_official_docs
CPython Docs
quickly daft jumping zebras vex. myapp.area2 : WARNING Jail zesty vixen who grabbed pay from quack. myapp.area2 : ERROR The five boxing wizards jump quickly. and in the file you will see something like
quickly daft jumping zebras vex. myapp.area2 : WARNING Jail zesty vixen who grabbed pay from quack. myapp.area2 : ERROR The five boxing wizards jump quickly. and in the file you will see something like
python, official-docs, cpython, P0
Local_Trusted_Corpus
7ccbb179-cd5f-40ef-85c6-0dd3f00c050e
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,579
supabase-export-v2
eeb0524dae5ce447
.. code-block:: console $ python listener.py Press Ctrl-C to stop. DEBUG myapp 613 Message no. 1 WARNING myapp.lib2 613 Message no. 2 INFO myapp.lib2 657 Message no. 1 CRITICAL myapp.lib2 613 Message no. 3 CRITICAL myapp.lib2 657 Message no. 2 CRITICAL myapp 657 Message no. 3 WARNING myapp.lib2 613 Message no. 4...
trusted_official_docs
CPython Docs
.. code-block:: console $ python listener.py Press Ctrl-C to stop. DEBUG myapp 613 Message no. 1 WARNING myapp.lib2 613 Message no. 2 INFO myapp.lib2 657 Message no. 1 CRITICAL myapp.lib2 613 Message no. 3 CRITICAL myapp.lib2 657 Message no. 2 CRITICAL myapp 657 Message no. 3 WARNING myapp.lib2 613 Message no. 4...
.. code-block:: console $ python listener.py Press Ctrl-C to stop. DEBUG myapp 613 Message no. 1 WARNING myapp.lib2 613 Message no. 2 INFO myapp.lib2 657 Message no. 1 CRITICAL myapp.lib2 613 Message no. 3 CRITICAL myapp.lib2 657 Message no. 2 CRITICAL myapp 657 Message no. 3 WARNING myapp.lib2 613 Message no. 4...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7d258a66-e207-4abd-b7af-2b1a96d4ac72
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,880
supabase-export-v2
a7d285e98f6ec2dc
def replacer(m): g = m.groups() return '\\' + g[0] for sdid, dv in sd.items(): part = f'[{sdid}' for k, v in dv.items(): s = str(v) s = self.escaped.sub(replacer, s) part += f' {k}="{s}"' part += ']' parts.append(part) sdata = ''.join(parts) return f'{version} {asctime} {hostname} {appname} {procid} {msgid} {s...
trusted_official_docs
CPython Docs
def replacer(m): g = m.groups() return '\\' + g[0] for sdid, dv in sd.items(): part = f'[{sdid}' for k, v in dv.items(): s = str(v) s = self.escaped.sub(replacer, s) part += f' {k}="{s}"' part += ']' parts.append(part) sdata = ''.join(parts) return f'{version} {asctime} {hostname} {appname} {procid} {msgid} {s...
def replacer(m): g = m.groups() return '\\' + g[0] for sdid, dv in sd.items(): part = f'[{sdid}' for k, v in dv.items(): s = str(v) s = self.escaped.sub(replacer, s) part += f' {k}="{s}"' part += ']' parts.append(part) sdata = ''.join(parts) return f'{version} {asctime} {hostname} {appname} {procid} {msgid} {s...
python, official-docs, cpython, P0
Local_Trusted_Corpus
7dcea429-3584-4219-8234-1d3cb72ddb5f
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,422
supabase-export-v2
5147f36fdd5c1de0
if __name__ == '__main__': main() If you run the above, you should find that roughly half the requests go into :file:`app1.log` and the rest into :file:`app2.log`, and the all the requests are logged to :file:`app.log`. Each webapp-specific log will contain only log entries for only that webapp, and the request informa...
trusted_official_docs
CPython Docs
if __name__ == '__main__': main() If you run the above, you should find that roughly half the requests go into :file:`app1.log` and the rest into :file:`app2.log`, and the all the requests are logged to :file:`app.log`. Each webapp-specific log will contain only log entries for only that webapp, and the request informa...
if __name__ == '__main__': main() If you run the above, you should find that roughly half the requests go into :file:`app1.log` and the rest into :file:`app2.log`, and the all the requests are logged to :file:`app.log`. Each webapp-specific log will contain only log entries for only that webapp, and the request informa...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8040505c-0ad3-4122-88c7-5e499503b915
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,382
supabase-export-v2
0ddcdb644abb149e
``LoggerAdapter`` example above. In that case, the same format string can be used to get similar output to that shown above. Here's an example script:: import logging from random import choice
trusted_official_docs
CPython Docs
``LoggerAdapter`` example above. In that case, the same format string can be used to get similar output to that shown above. Here's an example script:: import logging from random import choice
``LoggerAdapter`` example above. In that case, the same format string can be used to get similar output to that shown above. Here's an example script:: import logging from random import choice
python, official-docs, cpython, P0
Local_Trusted_Corpus
807438f7-6e45-4630-85df-9ffe6c3325c4
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,611
supabase-export-v2
51f1e862f4097b41
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.choice(loggers)) logger.log(lvl, 'Message no. %d', i) time.sleep(0.01) def main(): q = Queue() # The main process gets a simple configurati...
trusted_official_docs
CPython Docs
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.choice(loggers)) logger.log(lvl, 'Message no. %d', i) time.sleep(0.01) def main(): q = Queue() # The main process gets a simple configurati...
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.choice(loggers)) logger.log(lvl, 'Message no. %d', i) time.sleep(0.01) def main(): q = Queue() # The main process gets a simple configurati...
python, official-docs, cpython, P0
Local_Trusted_Corpus
8216e912-1fff-4a9a-b5ac-91ddd112d461
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,655
supabase-export-v2
b7f404e27873a7b2
def owned_file_handler(filename, mode='a', encoding=None, owner=None): if owner: if not os.path.exists(filename): open(filename, 'a').close() shutil.chown(filename, *owner) return logging.FileHandler(filename, mode, encoding) You can then specify, in a logging configuration passed to :func:`dictConfig`, that a logging ...
trusted_official_docs
CPython Docs
def owned_file_handler(filename, mode='a', encoding=None, owner=None): if owner: if not os.path.exists(filename): open(filename, 'a').close() shutil.chown(filename, *owner) return logging.FileHandler(filename, mode, encoding) You can then specify, in a logging configuration passed to :func:`dictConfig`, that a logging ...
def owned_file_handler(filename, mode='a', encoding=None, owner=None): if owner: if not os.path.exists(filename): open(filename, 'a').close() shutil.chown(filename, *owner) return logging.FileHandler(filename, mode, encoding) You can then specify, in a logging configuration passed to :func:`dictConfig`, that a logging ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
82283e19-b2ef-4a21-8ea5-478bcd16028c
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,488
supabase-export-v2
9b6863a17350bd67
to use the %-formatting method. Since then, Python has gained two new formatting approaches: :class:`string.Template` (added in Python 2.4) and :meth:`str.format` (added in Python 2.6). Logging (as of 3.2) provides improved support for these two additional formatting styles. The :class:`Formatter` class been enhanced t...
trusted_official_docs
CPython Docs
to use the %-formatting method. Since then, Python has gained two new formatting approaches: :class:`string.Template` (added in Python 2.4) and :meth:`str.format` (added in Python 2.6). Logging (as of 3.2) provides improved support for these two additional formatting styles. The :class:`Formatter` class been enhanced t...
to use the %-formatting method. Since then, Python has gained two new formatting approaches: :class:`string.Template` (added in Python 2.4) and :meth:`str.format` (added in Python 2.6). Logging (as of 3.2) provides improved support for these two additional formatting styles. The :class:`Formatter` class been enhanced t...
python, official-docs, cpython, P0
Local_Trusted_Corpus
822cce2f-b026-4a90-bf31-ad692fa3f8bb
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,763
supabase-export-v2
cc6c35f30a25b875
record in self.buffer: s = self.format(record) msg = msg + s + "\r\n" smtp.sendmail(self.fromaddr, self.toaddrs, msg) smtp.quit() except Exception: if logging.raiseExceptions: raise self.buffer = [] if __name__ == '__main__': import argparse
trusted_official_docs
CPython Docs
record in self.buffer: s = self.format(record) msg = msg + s + "\r\n" smtp.sendmail(self.fromaddr, self.toaddrs, msg) smtp.quit() except Exception: if logging.raiseExceptions: raise self.buffer = [] if __name__ == '__main__': import argparse
record in self.buffer: s = self.format(record) msg = msg + s + "\r\n" smtp.sendmail(self.fromaddr, self.toaddrs, msg) smtp.quit() except Exception: if logging.raiseExceptions: raise self.buffer = [] if __name__ == '__main__': import argparse
python, official-docs, cpython, P0
Local_Trusted_Corpus