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
c4968359-ca86-4df5-9f00-5f5af97bc9d8
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,936
supabase-export-v2
0fa72cf279c8b14d
class EscapingFormatter(logging.Formatter): def format(self, record): s = super().format(record) return s.replace('\n', r'\n') if __name__ == '__main__': h = logging.StreamHandler() h.setFormatter(EscapingFormatter('%(asctime)s %(levelname)-9s %(message)s')) logging.basicConfig(level=logging.DEBUG, handlers = [h]) ...
trusted_official_docs
CPython Docs
class EscapingFormatter(logging.Formatter): def format(self, record): s = super().format(record) return s.replace('\n', r'\n') if __name__ == '__main__': h = logging.StreamHandler() h.setFormatter(EscapingFormatter('%(asctime)s %(levelname)-9s %(message)s')) logging.basicConfig(level=logging.DEBUG, handlers = [h]) ...
class EscapingFormatter(logging.Formatter): def format(self, record): s = super().format(record) return s.replace('\n', r'\n') if __name__ == '__main__': h = logging.StreamHandler() h.setFormatter(EscapingFormatter('%(asctime)s %(levelname)-9s %(message)s')) logging.basicConfig(level=logging.DEBUG, handlers = [h]) ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c6b548e6-ad94-4f0a-89ff-a613ed765324
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,355
supabase-export-v2
9e11526ef95dc82b
:file:`run` subdirectory to contain Supervisor-related and log files, and a :file:`venv` subdirectory to contain a virtual environment into which ``bottle``, ``gunicorn`` and ``supervisor`` are installed. #. Run ``bash ensure_app.sh`` to ensure that Supervisor is running with the above configuration.
trusted_official_docs
CPython Docs
:file:`run` subdirectory to contain Supervisor-related and log files, and a :file:`venv` subdirectory to contain a virtual environment into which ``bottle``, ``gunicorn`` and ``supervisor`` are installed. #. Run ``bash ensure_app.sh`` to ensure that Supervisor is running with the above configuration.
:file:`run` subdirectory to contain Supervisor-related and log files, and a :file:`venv` subdirectory to contain a virtual environment into which ``bottle``, ``gunicorn`` and ``supervisor`` are installed. #. Run ``bash ensure_app.sh`` to ensure that Supervisor is running with the above configuration.
python, official-docs, cpython, P0
Local_Trusted_Corpus
c6d9942d-8665-494c-b06d-c80312bcf777
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,791
supabase-export-v2
8fca3f3362df26a6
``with`` statement's completion, the status is as it was before so message #6 appears (like message #1) whereas message #7 doesn't (just like message #2). If we run the resulting script, the result is as follows:
trusted_official_docs
CPython Docs
``with`` statement's completion, the status is as it was before so message #6 appears (like message #1) whereas message #7 doesn't (just like message #2). If we run the resulting script, the result is as follows:
``with`` statement's completion, the status is as it was before so message #6 appears (like message #1) whereas message #7 doesn't (just like message #2). If we run the resulting script, the result is as follows:
python, official-docs, cpython, P0
Local_Trusted_Corpus
c723f903-5c2e-41b2-a49f-4a6f07b2d5d4
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,306
supabase-export-v2
30e6f68ded9e5743
.. currentmodule:: logging.handlers Sometimes you have to get your logging handlers to 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.
trusted_official_docs
CPython Docs
.. currentmodule:: logging.handlers Sometimes you have to get your logging handlers to 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.
.. currentmodule:: logging.handlers Sometimes you have to get your logging handlers to 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.
python, official-docs, cpython, P0
Local_Trusted_Corpus
c792bc32-1bbb-4698-bfce-8ad758352733
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,487
supabase-export-v2
6a090107ff47c8ed
Use of alternative formatting styles ------------------------------------ When logging was added to the Python standard library, the only way of formatting messages with variable content was to use the %-formatting method. Since then, Python has gained two new formatting approaches: :class:`string.Template` (added in P...
trusted_official_docs
CPython Docs
Use of alternative formatting styles ------------------------------------ When logging was added to the Python standard library, the only way of formatting messages with variable content was to use the %-formatting method. Since then, Python has gained two new formatting approaches: :class:`string.Template` (added in P...
Use of alternative formatting styles ------------------------------------ When logging was added to the Python standard library, the only way of formatting messages with variable content was to use the %-formatting method. Since then, Python has gained two new formatting approaches: :class:`string.Template` (added in P...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c7e51a14-2952-43a5-9d97-51ed9265792d
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,801
supabase-export-v2
f40b4fd56074f33c
In this case, the message #5 printed to ``stdout`` doesn't appear, as expected. Of course, the approach described here can be generalised, for example to attach logging filters temporarily. Note that the above code works in Python 2 as well as Python 3.
trusted_official_docs
CPython Docs
In this case, the message #5 printed to ``stdout`` doesn't appear, as expected. Of course, the approach described here can be generalised, for example to attach logging filters temporarily. Note that the above code works in Python 2 as well as Python 3.
In this case, the message #5 printed to ``stdout`` doesn't appear, as expected. Of course, the approach described here can be generalised, for example to attach logging filters temporarily. Note that the above code works in Python 2 as well as Python 3.
python, official-docs, cpython, P0
Local_Trusted_Corpus
c84da836-d440-41f7-8c8d-72558ee0704a
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,690
supabase-export-v2
81673919eb6bc890
more palatable if you use an alias such as ``M`` or ``_`` for the message (or perhaps ``__``, if you are using ``_`` for localization). Examples of this approach are given below. Firstly, formatting with :meth:`str.format`::
trusted_official_docs
CPython Docs
more palatable if you use an alias such as ``M`` or ``_`` for the message (or perhaps ``__``, if you are using ``_`` for localization). Examples of this approach are given below. Firstly, formatting with :meth:`str.format`::
more palatable if you use an alias such as ``M`` or ``_`` for the message (or perhaps ``__``, if you are using ``_`` for localization). Examples of this approach are given below. Firstly, formatting with :meth:`str.format`::
python, official-docs, cpython, P0
Local_Trusted_Corpus
c8dbbff2-f6ec-4ea7-885b-3614c4069811
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,263
supabase-export-v2
072218716b00bf2a
and ``WARNING`` to ``sys.stdout`` * Send messages of severity ``ERROR`` and above to ``sys.stderr`` * Send messages of severity ``DEBUG`` and above to file ``app.log`` Suppose you configure logging with the following JSON:
trusted_official_docs
CPython Docs
and ``WARNING`` to ``sys.stdout`` * Send messages of severity ``ERROR`` and above to ``sys.stderr`` * Send messages of severity ``DEBUG`` and above to file ``app.log`` Suppose you configure logging with the following JSON:
and ``WARNING`` to ``sys.stdout`` * Send messages of severity ``ERROR`` and above to ``sys.stderr`` * Send messages of severity ``DEBUG`` and above to file ``app.log`` Suppose you configure logging with the following JSON:
python, official-docs, cpython, P0
Local_Trusted_Corpus
c9180cad-ec25-4462-9672-387e36239c6c
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,300
supabase-export-v2
744a518f08da0fca
is a script that takes a filename and sends that file to the server, properly preceded with the binary-encoded length, as the new logging configuration:: #!/usr/bin/env python import socket, sys, struct
trusted_official_docs
CPython Docs
is a script that takes a filename and sends that file to the server, properly preceded with the binary-encoded length, as the new logging configuration:: #!/usr/bin/env python import socket, sys, struct
is a script that takes a filename and sends that file to the server, properly preceded with the binary-encoded length, as the new logging configuration:: #!/usr/bin/env python import socket, sys, struct
python, official-docs, cpython, P0
Local_Trusted_Corpus
c9d586f7-44e7-4039-9970-d74bd7726f34
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,388
supabase-export-v2
0c043b1aa6e1b1ec
record.ip = choice(ContextFilter.IPS) record.user = choice(ContextFilter.USERS) return True if __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...
trusted_official_docs
CPython Docs
record.ip = choice(ContextFilter.IPS) record.user = choice(ContextFilter.USERS) return True if __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...
record.ip = choice(ContextFilter.IPS) record.user = choice(ContextFilter.USERS) return True if __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...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cb623afe-49a9-4b0c-87e0-0892f08855ba
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,501
supabase-export-v2
98256e90d25f27ed
alias such as __ (double underscore --- not to be confused with _, the single underscore used as a synonym/alias for :func:`gettext.gettext` or its brethren). The above classes are not included in Python, though they're easy enough to copy and paste into your own code. They can be used as follows (assuming that they're...
trusted_official_docs
CPython Docs
alias such as __ (double underscore --- not to be confused with _, the single underscore used as a synonym/alias for :func:`gettext.gettext` or its brethren). The above classes are not included in Python, though they're easy enough to copy and paste into your own code. They can be used as follows (assuming that they're...
alias such as __ (double underscore --- not to be confused with _, the single underscore used as a synonym/alias for :func:`gettext.gettext` or its brethren). The above classes are not included in Python, though they're easy enough to copy and paste into your own code. They can be used as follows (assuming that they're...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cb7a3a3d-19a0-4358-9a8a-7ec67d531f68
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,765
supabase-export-v2
884cf62279e056f7
= logging.getLogger() logger.setLevel(logging.DEBUG) h = BufferingSMTPHandler(options.host, options.port, options.user, options.password, options.sender, options.to, options.subject, 10) logger.addHandler(h) for i in range(102): logger.info("Info index = %d", i) h.flush() h.close() If you run this script and your SMTP ...
trusted_official_docs
CPython Docs
= logging.getLogger() logger.setLevel(logging.DEBUG) h = BufferingSMTPHandler(options.host, options.port, options.user, options.password, options.sender, options.to, options.subject, 10) logger.addHandler(h) for i in range(102): logger.info("Info index = %d", i) h.flush() h.close() If you run this script and your SMTP ...
= logging.getLogger() logger.setLevel(logging.DEBUG) h = BufferingSMTPHandler(options.host, options.port, options.user, options.password, options.sender, options.to, options.subject, 10) logger.addHandler(h) for i in range(102): logger.info("Info index = %d", i) h.flush() h.close() If you run this script and your SMTP ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cbf37eda-3079-4e70-a232-75607fd3cb0c
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,822
supabase-export-v2
b862f2b77420528c
logger = logging.getLogger(__name__) def command(options): n = len(options.names) if n == 1: plural = '' services = '\'%s\'' % options.names[0] else: plural = 's' services = ', '.join('\'%s\'' % name for name in options.names) i = services.rfind(', ') services = services[:i] + ' and ' + services[i + 2:] logge...
trusted_official_docs
CPython Docs
logger = logging.getLogger(__name__) def command(options): n = len(options.names) if n == 1: plural = '' services = '\'%s\'' % options.names[0] else: plural = 's' services = ', '.join('\'%s\'' % name for name in options.names) i = services.rfind(', ') services = services[:i] + ' and ' + services[i + 2:] logge...
logger = logging.getLogger(__name__) def command(options): n = len(options.names) if n == 1: plural = '' services = '\'%s\'' % options.names[0] else: plural = 's' services = ', '.join('\'%s\'' % name for name in options.names) i = services.rfind(', ') services = services[:i] + ' and ' + services[i + 2:] logge...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cbf6e160-e321-40ad-a387-99c370dc5e53
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,376
supabase-export-v2
70d1f9c2b62c3a0c
Then any events that you log to the adapter will have the value of ``some_conn_id`` prepended to the log messages. Using objects other than dicts to pass contextual information ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
trusted_official_docs
CPython Docs
Then any events that you log to the adapter will have the value of ``some_conn_id`` prepended to the log messages. Using objects other than dicts to pass contextual information ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Then any events that you log to the adapter will have the value of ``some_conn_id`` prepended to the log messages. Using objects other than dicts to pass contextual information ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
python, official-docs, cpython, P0
Local_Trusted_Corpus
cc30e504-e11b-48ad-b51b-a1f8a1c5d27e
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,308
supabase-export-v2
8920177abc328b12
the hood which is too slow (and this query can be deep in the socket library code, below the Python layer, and outside your control). One solution is to use a two-part approach. For the first part, attach only a :class:`QueueHandler` to those loggers which are accessed from performance-critical threads. They simply wri...
trusted_official_docs
CPython Docs
the hood which is too slow (and this query can be deep in the socket library code, below the Python layer, and outside your control). One solution is to use a two-part approach. For the first part, attach only a :class:`QueueHandler` to those loggers which are accessed from performance-critical threads. They simply wri...
the hood which is too slow (and this query can be deep in the socket library code, below the Python layer, and outside your control). One solution is to use a two-part approach. For the first part, attach only a :class:`QueueHandler` to those loggers which are accessed from performance-critical threads. They simply wri...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cc3d4ab8-06f0-497c-a4ba-9de3fb0779df
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,805
supabase-export-v2
94391b15c0e6193f
Here's an example which shows how you can: * Use a logging level based on command-line arguments * Dispatch to multiple subcommands in separate files, all logging at the same level in a consistent way * Make use of simple, minimal configuration
trusted_official_docs
CPython Docs
Here's an example which shows how you can: * Use a logging level based on command-line arguments * Dispatch to multiple subcommands in separate files, all logging at the same level in a consistent way * Make use of simple, minimal configuration
Here's an example which shows how you can: * Use a logging level based on command-line arguments * Dispatch to multiple subcommands in separate files, all logging at the same level in a consistent way * Make use of simple, minimal configuration
python, official-docs, cpython, P0
Local_Trusted_Corpus
ce4f52d4-0c29-4ac9-a35b-912a76ca41e5
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,890
supabase-export-v2
2df41ccca1d92503
- so optional depending on your situation. You might want # to set a flag so that later calls to write raise an exception pass def main(): logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger('demo') info_fp = LoggerWriter(logger, logging.INFO) debug_fp = LoggerWriter(logger, logging.DEBUG) print('A...
trusted_official_docs
CPython Docs
- so optional depending on your situation. You might want # to set a flag so that later calls to write raise an exception pass def main(): logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger('demo') info_fp = LoggerWriter(logger, logging.INFO) debug_fp = LoggerWriter(logger, logging.DEBUG) print('A...
- so optional depending on your situation. You might want # to set a flag so that later calls to write raise an exception pass def main(): logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger('demo') info_fp = LoggerWriter(logger, logging.INFO) debug_fp = LoggerWriter(logger, logging.DEBUG) print('A...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cec0b397-8457-4e7b-8e35-8af448daddc1
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,737
supabase-export-v2
b1b98d063569cd1e
with the collected debug information, but if there is an error, you want all the debug information to be output as well as the error. Here is an example which shows how you could do this using a decorator for your functions where you want logging to behave this way. It makes use of the :class:`logging.handlers.MemoryHa...
trusted_official_docs
CPython Docs
with the collected debug information, but if there is an error, you want all the debug information to be output as well as the error. Here is an example which shows how you could do this using a decorator for your functions where you want logging to behave this way. It makes use of the :class:`logging.handlers.MemoryHa...
with the collected debug information, but if there is an error, you want all the debug information to be output as well as the error. Here is an example which shows how you could do this using a decorator for your functions where you want logging to behave this way. It makes use of the :class:`logging.handlers.MemoryHa...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cef20b39-4759-4f0b-b225-0de035efe9a3
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,504
supabase-export-v2
41b54e32d454777c
point=p)) Message with coordinates: (0.50, 0.50) >>> from wherever import DollarMessage as __ >>> print(__('Message with $num $what', num=2, what='placeholders')) Message with 2 placeholders >>> While the above examples use ``print()`` to show how the formatting works, you would of course use ``logger.debug()`` or simi...
trusted_official_docs
CPython Docs
point=p)) Message with coordinates: (0.50, 0.50) >>> from wherever import DollarMessage as __ >>> print(__('Message with $num $what', num=2, what='placeholders')) Message with 2 placeholders >>> While the above examples use ``print()`` to show how the formatting works, you would of course use ``logger.debug()`` or simi...
point=p)) Message with coordinates: (0.50, 0.50) >>> from wherever import DollarMessage as __ >>> print(__('Message with $num $what', num=2, what='placeholders')) Message with 2 placeholders >>> While the above examples use ``print()`` to show how the formatting works, you would of course use ``logger.debug()`` or simi...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cf8b7c84-016c-4ef9-9b52-ad9ac0ee8fa2
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,607
supabase-export-v2
c2bf2b1f6d3c1db4
logger = logging.getLogger('setup') logger.critical('Should not appear, because of disabled logger ...') stop_event.wait() listener.stop() def worker_process(config): """ A number of these are spawned for the purpose of illustration. In practice, they could be a heterogeneous bunch of processes rather than ones whi...
trusted_official_docs
CPython Docs
logger = logging.getLogger('setup') logger.critical('Should not appear, because of disabled logger ...') stop_event.wait() listener.stop() def worker_process(config): """ A number of these are spawned for the purpose of illustration. In practice, they could be a heterogeneous bunch of processes rather than ones whi...
logger = logging.getLogger('setup') logger.critical('Should not appear, because of disabled logger ...') stop_event.wait() listener.stop() def worker_process(config): """ A number of these are spawned for the purpose of illustration. In practice, they could be a heterogeneous bunch of processes rather than ones whi...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cf967ab2-b3cb-46b3-8cd6-61efb13dc4ee
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,412
supabase-export-v2
6cd0702c37d8f804
ctx_request = ContextVar('request') ctx_appname = ContextVar('appname') class InjectingFilter(logging.Filter): """ A filter which injects context-specific information into logs and ensures that only information for a specific webapp is included in its log """ def __init__(self, app): self.app = app
trusted_official_docs
CPython Docs
ctx_request = ContextVar('request') ctx_appname = ContextVar('appname') class InjectingFilter(logging.Filter): """ A filter which injects context-specific information into logs and ensures that only information for a specific webapp is included in its log """ def __init__(self, app): self.app = app
ctx_request = ContextVar('request') ctx_appname = ContextVar('appname') class InjectingFilter(logging.Filter): """ A filter which injects context-specific information into logs and ensures that only information for a specific webapp is included in its log """ def __init__(self, app): self.app = app
python, official-docs, cpython, P0
Local_Trusted_Corpus
d04447ec-efa3-4010-86b8-2430ad5be868
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,245
supabase-export-v2
3752f66c49ddc22a
import logging # set up logging to file - see previous section for more details logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', datefmt='%m-%d %H:%M', filename='/tmp/myapp.log', filemode='w') # define a Handler which writes INFO messages or higher to the sys....
trusted_official_docs
CPython Docs
import logging # set up logging to file - see previous section for more details logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', datefmt='%m-%d %H:%M', filename='/tmp/myapp.log', filemode='w') # define a Handler which writes INFO messages or higher to the sys....
import logging # set up logging to file - see previous section for more details logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', datefmt='%m-%d %H:%M', filename='/tmp/myapp.log', filemode='w') # define a Handler which writes INFO messages or higher to the sys....
python, official-docs, cpython, P0
Local_Trusted_Corpus
d097fa4d-6552-4a15-9cca-cc57846c3ddc
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,738
supabase-export-v2
187e6726b1723dae
equal to a specified threshold is seen. You can use this recipe with a more specialised subclass of ``MemoryHandler`` if you want custom flushing behavior. The example script has a simple function, ``foo``, which just cycles through all the logging levels, writing to ``sys.stderr`` to say what level it's about to log a...
trusted_official_docs
CPython Docs
equal to a specified threshold is seen. You can use this recipe with a more specialised subclass of ``MemoryHandler`` if you want custom flushing behavior. The example script has a simple function, ``foo``, which just cycles through all the logging levels, writing to ``sys.stderr`` to say what level it's about to log a...
equal to a specified threshold is seen. You can use this recipe with a more specialised subclass of ``MemoryHandler`` if you want custom flushing behavior. The example script has a simple function, ``foo``, which just cycles through all the logging levels, writing to ``sys.stderr`` to say what level it's about to log a...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d0b9536d-c5ca-4112-9bc6-75b6929e293e
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,440
supabase-export-v2
5c3e681e332a119b
# You'll need these imports in your own code import logging import logging.handlers import multiprocessing # Next two import lines for this demo only from random import choice, random import time
trusted_official_docs
CPython Docs
# You'll need these imports in your own code import logging import logging.handlers import multiprocessing # Next two import lines for this demo only from random import choice, random import time
# You'll need these imports in your own code import logging import logging.handlers import multiprocessing # Next two import lines for this demo only from random import choice, random import time
python, official-docs, cpython, P0
Local_Trusted_Corpus
d0d33512-39d4-4d7a-bede-3030eb59c088
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,854
supabase-export-v2
6d6c55b5bb3d7014
seconds. # class Worker(QtCore.QObject): @Slot() def start(self): extra = {'qThreadName': ctname() } logger.debug('Started work', extra=extra) i = 1 # Let the thread run until interrupted. This allows reasonably clean # thread termination. while not QtCore.QThread.currentThread().isInterruptionRequested(): delay = 0....
trusted_official_docs
CPython Docs
seconds. # class Worker(QtCore.QObject): @Slot() def start(self): extra = {'qThreadName': ctname() } logger.debug('Started work', extra=extra) i = 1 # Let the thread run until interrupted. This allows reasonably clean # thread termination. while not QtCore.QThread.currentThread().isInterruptionRequested(): delay = 0....
seconds. # class Worker(QtCore.QObject): @Slot() def start(self): extra = {'qThreadName': ctname() } logger.debug('Started work', extra=extra) i = 1 # Let the thread run until interrupted. This allows reasonably clean # thread termination. while not QtCore.QThread.currentThread().isInterruptionRequested(): delay = 0....
python, official-docs, cpython, P0
Local_Trusted_Corpus
d20c1fa4-4e5a-49ff-87c8-1d06e36e56fb
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,787
supabase-export-v2
a406dd258a177792
ev, tb): if self.level is not None: self.logger.setLevel(self.old_level) if self.handler: self.logger.removeHandler(self.handler) if self.handler and self.close: self.handler.close() # implicit return of None => don't swallow exceptions If you specify a level value, the logger's level is set to that value in the scope ...
trusted_official_docs
CPython Docs
ev, tb): if self.level is not None: self.logger.setLevel(self.old_level) if self.handler: self.logger.removeHandler(self.handler) if self.handler and self.close: self.handler.close() # implicit return of None => don't swallow exceptions If you specify a level value, the logger's level is set to that value in the scope ...
ev, tb): if self.level is not None: self.logger.setLevel(self.old_level) if self.handler: self.logger.removeHandler(self.handler) if self.handler and self.close: self.handler.close() # implicit return of None => don't swallow exceptions If you specify a level value, the logger's level is set to that value in the scope ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d2aab360-ecfd-4280-8212-18f33dc97a0b
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,525
supabase-export-v2
e4f4bce1accae549
application developer attached a handler to a lower-level library logger --- so output from that handler would not reflect the intentions of the library developer. In Python 3.2 and later, :class:`~logging.LogRecord` creation is done through a factory, which you can specify. The factory is just a callable you can set w...
trusted_official_docs
CPython Docs
application developer attached a handler to a lower-level library logger --- so output from that handler would not reflect the intentions of the library developer. In Python 3.2 and later, :class:`~logging.LogRecord` creation is done through a factory, which you can specify. The factory is just a callable you can set w...
application developer attached a handler to a lower-level library logger --- so output from that handler would not reflect the intentions of the library developer. In Python 3.2 and later, :class:`~logging.LogRecord` creation is done through a factory, which you can specify. The factory is just a callable you can set w...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d312a856-82d8-49cd-82ee-8351e9ee32b1
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,902
supabase-export-v2
68a633d8927cc590
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. Note that with the above scheme, you are somewhat at the mercy of buffering and the sequence of write calls which you are intercepting. For example, w...
trusted_official_docs
CPython Docs
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. Note that with the above scheme, you are somewhat at the mercy of buffering and the sequence of write calls which you are intercepting. For example, w...
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. Note that with the above scheme, you are somewhat at the mercy of buffering and the sequence of write calls which you are intercepting. For example, w...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d4afbc74-d02c-47f8-9564-2d752b539b85
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,372
supabase-export-v2
4285c788b64274ba
contextual information to the message string, you just need to subclass :class:`LoggerAdapter` and override :meth:`~LoggerAdapter.process` to do what you need. Here is a simple example:: class CustomAdapter(logging.LoggerAdapter): """ This example adapter expects the passed in dict-like object to have a 'connid' key...
trusted_official_docs
CPython Docs
contextual information to the message string, you just need to subclass :class:`LoggerAdapter` and override :meth:`~LoggerAdapter.process` to do what you need. Here is a simple example:: class CustomAdapter(logging.LoggerAdapter): """ This example adapter expects the passed in dict-like object to have a 'connid' key...
contextual information to the message string, you just need to subclass :class:`LoggerAdapter` and override :meth:`~LoggerAdapter.process` to do what you need. Here is a simple example:: class CustomAdapter(logging.LoggerAdapter): """ This example adapter expects the passed in dict-like object to have a 'connid' key...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d504aae2-d72b-48ba-8657-28431a55a18f
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,864
supabase-export-v2
fee612550aecce67
worker to stop, then tell it to quit and wait for that # to happen self.worker_thread.requestInterruption() if self.worker_thread.isRunning(): self.worker_thread.quit() self.worker_thread.wait() else: print('worker has already exited.') def force_quit(self): # For use when the window is closed if self.worker_thread.i...
trusted_official_docs
CPython Docs
worker to stop, then tell it to quit and wait for that # to happen self.worker_thread.requestInterruption() if self.worker_thread.isRunning(): self.worker_thread.quit() self.worker_thread.wait() else: print('worker has already exited.') def force_quit(self): # For use when the window is closed if self.worker_thread.i...
worker to stop, then tell it to quit and wait for that # to happen self.worker_thread.requestInterruption() if self.worker_thread.isRunning(): self.worker_thread.quit() self.worker_thread.wait() else: print('worker has already exited.') def force_quit(self): # For use when the window is closed if self.worker_thread.i...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d5a26d22-13c0-4337-8b1a-92c0a2ba1509
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,546
supabase-export-v2
56b300ee8a91fdeb
You can also subclass :class:`QueueListener` to get messages from other kinds of queues, for example a ZeroMQ 'subscribe' socket. Here's an example:: class ZeroMQSocketListener(QueueListener): def __init__(self, uri, /, *handlers, **kwargs): self.ctx = kwargs.get('ctx') or zmq.Context() socket = zmq.Socket(self.ctx,...
trusted_official_docs
CPython Docs
You can also subclass :class:`QueueListener` to get messages from other kinds of queues, for example a ZeroMQ 'subscribe' socket. Here's an example:: class ZeroMQSocketListener(QueueListener): def __init__(self, uri, /, *handlers, **kwargs): self.ctx = kwargs.get('ctx') or zmq.Context() socket = zmq.Socket(self.ctx,...
You can also subclass :class:`QueueListener` to get messages from other kinds of queues, for example a ZeroMQ 'subscribe' socket. Here's an example:: class ZeroMQSocketListener(QueueListener): def __init__(self, uri, /, *handlers, **kwargs): self.ctx = kwargs.get('ctx') or zmq.Context() socket = zmq.Socket(self.ctx,...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d811a7eb-b453-48a9-b243-a9fd8022bcf2
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,428
supabase-export-v2
c8572d452de44906
Imparting contextual information in handlers -------------------------------------------- Each :class:`~Handler` has its own chain of filters. If you want to add contextual information to a :class:`LogRecord` without leaking it to other handlers, you can use a filter that returns a new :class:`~LogRecord` instead of mo...
trusted_official_docs
CPython Docs
Imparting contextual information in handlers -------------------------------------------- Each :class:`~Handler` has its own chain of filters. If you want to add contextual information to a :class:`LogRecord` without leaking it to other handlers, you can use a filter that returns a new :class:`~LogRecord` instead of mo...
Imparting contextual information in handlers -------------------------------------------- Each :class:`~Handler` has its own chain of filters. If you want to add contextual information to a :class:`LogRecord` without leaking it to other handlers, you can use a filter that returns a new :class:`~LogRecord` instead of mo...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d82ec3ba-a48e-4ddf-abde-6762facab86f
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,547
supabase-export-v2
c55830d04a8f97ab
def __init__(self, uri, /, *handlers, **kwargs): self.ctx = kwargs.get('ctx') or zmq.Context() socket = zmq.Socket(self.ctx, zmq.SUB) socket.setsockopt_string(zmq.SUBSCRIBE, '') # subscribe to everything socket.connect(uri) super().__init__(socket, *handlers, **kwargs) def dequeue(self): msg = self.queue.recv_json() ...
trusted_official_docs
CPython Docs
def __init__(self, uri, /, *handlers, **kwargs): self.ctx = kwargs.get('ctx') or zmq.Context() socket = zmq.Socket(self.ctx, zmq.SUB) socket.setsockopt_string(zmq.SUBSCRIBE, '') # subscribe to everything socket.connect(uri) super().__init__(socket, *handlers, **kwargs) def dequeue(self): msg = self.queue.recv_json() ...
def __init__(self, uri, /, *handlers, **kwargs): self.ctx = kwargs.get('ctx') or zmq.Context() socket = zmq.Socket(self.ctx, zmq.SUB) socket.setsockopt_string(zmq.SUBSCRIBE, '') # subscribe to everything socket.connect(uri) super().__init__(socket, *handlers, **kwargs) def dequeue(self): msg = self.queue.recv_json() ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d8d56d74-1975-45d3-bd5f-978ee863f7ba
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,810
supabase-export-v2
63c91343aea76ac8
code for command \'%s\'' % options.command) return 1 # Could get fancy here and load configuration from file or dictionary logging.basicConfig(level=options.log_level, format='%(levelname)s %(name)s %(message)s') cmd(options) if __name__ == '__main__': sys.exit(main())
trusted_official_docs
CPython Docs
code for command \'%s\'' % options.command) return 1 # Could get fancy here and load configuration from file or dictionary logging.basicConfig(level=options.log_level, format='%(levelname)s %(name)s %(message)s') cmd(options) if __name__ == '__main__': sys.exit(main())
code for command \'%s\'' % options.command) return 1 # Could get fancy here and load configuration from file or dictionary logging.basicConfig(level=options.log_level, format='%(levelname)s %(name)s %(message)s') cmd(options) if __name__ == '__main__': sys.exit(main())
python, official-docs, cpython, P0
Local_Trusted_Corpus
daf4d089-5a05-40b1-88c5-b2df8eb97799
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,950
supabase-export-v2
1ff4bcbfb3272ea1
Opening a file multiple times might *appear* to work most of the time, but can lead to a number of problems in practice: * Logging output can be garbled because multiple threads or processes try to write to the same file. Although logging guards against concurrent use of the same handler instance by multiple threads,...
trusted_official_docs
CPython Docs
Opening a file multiple times might *appear* to work most of the time, but can lead to a number of problems in practice: * Logging output can be garbled because multiple threads or processes try to write to the same file. Although logging guards against concurrent use of the same handler instance by multiple threads,...
Opening a file multiple times might *appear* to work most of the time, but can lead to a number of problems in practice: * Logging output can be garbled because multiple threads or processes try to write to the same file. Although logging guards against concurrent use of the same handler instance by multiple threads,...
python, official-docs, cpython, P0
Local_Trusted_Corpus
dafdcd2f-7200-4bd0-8bdd-8ec5667186df
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,677
supabase-export-v2
e4d120b5a54d11bf
that this governs the formatting of logging messages for final output to logs, and is completely orthogonal to how an individual logging message is constructed. Logging calls (:meth:`~Logger.debug`, :meth:`~Logger.info` etc.) only take positional parameters for the actual logging message itself, with keyword parameters...
trusted_official_docs
CPython Docs
that this governs the formatting of logging messages for final output to logs, and is completely orthogonal to how an individual logging message is constructed. Logging calls (:meth:`~Logger.debug`, :meth:`~Logger.info` etc.) only take positional parameters for the actual logging message itself, with keyword parameters...
that this governs the formatting of logging messages for final output to logs, and is completely orthogonal to how an individual logging message is constructed. Logging calls (:meth:`~Logger.debug`, :meth:`~Logger.info` etc.) only take positional parameters for the actual logging message itself, with keyword parameters...
python, official-docs, cpython, P0
Local_Trusted_Corpus
dbac1ce7-33a6-4fde-9c26-43fa299476d8
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,917
supabase-export-v2
8b2fe9963607149f
.. code-block:: text WARNING:demo:Traceback (most recent call last): WARNING:demo: File "/home/runner/cookbook-loggerwriter/main.py", line 55, in <module> WARNING:demo: main() WARNING:demo: File "/home/runner/cookbook-loggerwriter/main.py", line 52, in main WARNING:demo: 1/0 WARNING:demo:ZeroDivisionError: divisio...
trusted_official_docs
CPython Docs
.. code-block:: text WARNING:demo:Traceback (most recent call last): WARNING:demo: File "/home/runner/cookbook-loggerwriter/main.py", line 55, in <module> WARNING:demo: main() WARNING:demo: File "/home/runner/cookbook-loggerwriter/main.py", line 52, in main WARNING:demo: 1/0 WARNING:demo:ZeroDivisionError: divisio...
.. code-block:: text WARNING:demo:Traceback (most recent call last): WARNING:demo: File "/home/runner/cookbook-loggerwriter/main.py", line 55, in <module> WARNING:demo: main() WARNING:demo: File "/home/runner/cookbook-loggerwriter/main.py", line 52, in main WARNING:demo: 1/0 WARNING:demo:ZeroDivisionError: divisio...
python, official-docs, cpython, P0
Local_Trusted_Corpus
dc041d00-8d7b-4774-adf8-c023e9a30e8a
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,714
supabase-export-v2
4380aaebc9a6bb8c
import logging class OneLineExceptionFormatter(logging.Formatter): def formatException(self, exc_info): """ Format an 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
trusted_official_docs
CPython Docs
import logging class OneLineExceptionFormatter(logging.Formatter): def formatException(self, exc_info): """ Format an 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
import logging class OneLineExceptionFormatter(logging.Formatter): def formatException(self, exc_info): """ Format an 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
python, official-docs, cpython, P0
Local_Trusted_Corpus
dc445a98-8961-4ac3-a889-0a548c062411
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,281
supabase-export-v2
dbe4bd13b0b195cb
import json import logging import logging.config CONFIG = ''' { "version": 1, "disable_existing_loggers": false, "formatters": { "simple": { "format": "%(levelname)-8s - %(message)s" } }, "filters": { "warnings_and_below": { "()" : "__main__.filter_maker", "level": "WARNING" } }, "handlers": { "stdout":...
trusted_official_docs
CPython Docs
import json import logging import logging.config CONFIG = ''' { "version": 1, "disable_existing_loggers": false, "formatters": { "simple": { "format": "%(levelname)-8s - %(message)s" } }, "filters": { "warnings_and_below": { "()" : "__main__.filter_maker", "level": "WARNING" } }, "handlers": { "stdout":...
import json import logging import logging.config CONFIG = ''' { "version": 1, "disable_existing_loggers": false, "formatters": { "simple": { "format": "%(levelname)-8s - %(message)s" } }, "filters": { "warnings_and_below": { "()" : "__main__.filter_maker", "level": "WARNING" } }, "handlers": { "stdout":...
python, official-docs, cpython, P0
Local_Trusted_Corpus
dc4a5626-9ee3-4772-bdeb-e300f71ad0be
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,882
supabase-export-v2
039990cf1de7b4fe
to the log). Nevertheless, the above should be adaptable to your speciric needs. With the above handler, you'd pass structured data using something like this:: sd = { 'foo@12345': {'bar': 'baz', 'baz': 'bozz', 'fizz': r'buzz'}, 'foo@54321': {'rab': 'baz', 'zab': 'bozz', 'zzif': r'buzz'} } extra = {'structured_data'...
trusted_official_docs
CPython Docs
to the log). Nevertheless, the above should be adaptable to your speciric needs. With the above handler, you'd pass structured data using something like this:: sd = { 'foo@12345': {'bar': 'baz', 'baz': 'bozz', 'fizz': r'buzz'}, 'foo@54321': {'rab': 'baz', 'zab': 'bozz', 'zzif': r'buzz'} } extra = {'structured_data'...
to the log). Nevertheless, the above should be adaptable to your speciric needs. With the above handler, you'd pass structured data using something like this:: sd = { 'foo@12345': {'bar': 'baz', 'baz': 'bozz', 'fizz': r'buzz'}, 'foo@54321': {'rab': 'baz', 'zab': 'bozz', 'zzif': r'buzz'} } extra = {'structured_data'...
python, official-docs, cpython, P0
Local_Trusted_Corpus
dc859fe2-27b1-4c8b-9a6e-be390694426d
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,834
supabase-export-v2
469541e37e51d373
app.py --log-level DEBUG restart foo bar baz DEBUG restart About to restart 'foo', 'bar' and 'baz' INFO restart Restarted the 'foo', 'bar' and 'baz' services. And if we want less:
trusted_official_docs
CPython Docs
app.py --log-level DEBUG restart foo bar baz DEBUG restart About to restart 'foo', 'bar' and 'baz' INFO restart Restarted the 'foo', 'bar' and 'baz' services. And if we want less:
app.py --log-level DEBUG restart foo bar baz DEBUG restart About to restart 'foo', 'bar' and 'baz' INFO restart Restarted the 'foo', 'bar' and 'baz' services. And if we want less:
python, official-docs, cpython, P0
Local_Trusted_Corpus
dcccc0dd-265e-4f27-9eaf-3e8ec4b1c501
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,717
supabase-export-v2
6061f3f672b09030
def configure_logging(): fh = logging.FileHandler('output.txt', 'w') f = OneLineExceptionFormatter('%(asctime)s|%(levelname)s|%(message)s|', '%d/%m/%Y %H:%M:%S') fh.setFormatter(f) root = logging.getLogger() root.setLevel(logging.DEBUG) root.addHandler(fh) def main(): configure_logging() logging.info('Sample message'...
trusted_official_docs
CPython Docs
def configure_logging(): fh = logging.FileHandler('output.txt', 'w') f = OneLineExceptionFormatter('%(asctime)s|%(levelname)s|%(message)s|', '%d/%m/%Y %H:%M:%S') fh.setFormatter(f) root = logging.getLogger() root.setLevel(logging.DEBUG) root.addHandler(fh) def main(): configure_logging() logging.info('Sample message'...
def configure_logging(): fh = logging.FileHandler('output.txt', 'w') f = OneLineExceptionFormatter('%(asctime)s|%(levelname)s|%(message)s|', '%d/%m/%Y %H:%M:%S') fh.setFormatter(f) root = logging.getLogger() root.setLevel(logging.DEBUG) root.addHandler(fh) def main(): configure_logging() logging.info('Sample message'...
python, official-docs, cpython, P0
Local_Trusted_Corpus
dd74dbd9-dd35-41be-b38e-1eea15257358
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,857
supabase-export-v2
acefc8d6174c9b70
COLORS = { logging.DEBUG: 'black', logging.INFO: 'blue', logging.WARNING: 'orange', logging.ERROR: 'red', logging.CRITICAL: 'purple', } def __init__(self, app): super().__init__() self.app = app self.textedit = te = QtWidgets.QPlainTextEdit(self) # Set whatever the default monospace font is for the platform f = Qt...
trusted_official_docs
CPython Docs
COLORS = { logging.DEBUG: 'black', logging.INFO: 'blue', logging.WARNING: 'orange', logging.ERROR: 'red', logging.CRITICAL: 'purple', } def __init__(self, app): super().__init__() self.app = app self.textedit = te = QtWidgets.QPlainTextEdit(self) # Set whatever the default monospace font is for the platform f = Qt...
COLORS = { logging.DEBUG: 'black', logging.INFO: 'blue', logging.WARNING: 'orange', logging.ERROR: 'red', logging.CRITICAL: 'purple', } def __init__(self, app): super().__init__() self.app = app self.textedit = te = QtWidgets.QPlainTextEdit(self) # Set whatever the default monospace font is for the platform f = Qt...
python, official-docs, cpython, P0
Local_Trusted_Corpus
dd7b2699-1f28-4e38-b639-cdfef73e1ea8
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,455
supabase-export-v2
5164f82229656752
def logger_thread(q): while True: record = q.get() if record is None: break logger = logging.getLogger(record.name) logger.handle(record) def worker_process(q): qh = logging.handlers.QueueHandler(q) root = logging.getLogger() root.setLevel(logging.DEBUG) root.addHandler(qh) levels = [logging.DEBUG, logging.INFO, l...
trusted_official_docs
CPython Docs
def logger_thread(q): while True: record = q.get() if record is None: break logger = logging.getLogger(record.name) logger.handle(record) def worker_process(q): qh = logging.handlers.QueueHandler(q) root = logging.getLogger() root.setLevel(logging.DEBUG) root.addHandler(qh) levels = [logging.DEBUG, logging.INFO, l...
def logger_thread(q): while True: record = q.get() if record is None: break logger = logging.getLogger(record.name) logger.handle(record) def worker_process(q): qh = logging.handlers.QueueHandler(q) root = logging.getLogger() root.setLevel(logging.DEBUG) root.addHandler(qh) levels = [logging.DEBUG, logging.INFO, l...
python, official-docs, cpython, P0
Local_Trusted_Corpus
df4a3302-460e-4645-8f8a-503322894e37
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,496
supabase-export-v2
2393416b7fae3b93
message format string, and that the logging package will call ``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 ``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 ``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
dfbb92b2-08a6-4df5-b8b8-a0a0ee979068
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,310
supabase-export-v2
f3b198c8c5f54b0e
from ``QueueHandlers`` (or any other source of ``LogRecords``, for that matter). The ``LogRecords`` are removed from the queue and passed to the handlers for processing. The advantage of having a separate :class:`QueueListener` class is that you can use the same instance to service multiple ``QueueHandlers``. This is m...
trusted_official_docs
CPython Docs
from ``QueueHandlers`` (or any other source of ``LogRecords``, for that matter). The ``LogRecords`` are removed from the queue and passed to the handlers for processing. The advantage of having a separate :class:`QueueListener` class is that you can use the same instance to service multiple ``QueueHandlers``. This is m...
from ``QueueHandlers`` (or any other source of ``LogRecords``, for that matter). The ``LogRecords`` are removed from the queue and passed to the handlers for processing. The advantage of having a separate :class:`QueueListener` class is that you can use the same instance to service multiple ``QueueHandlers``. This is m...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e21f7ec9-ae9c-4348-a343-f48f2a1cf596
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,342
supabase-export-v2
e394ef011a96e3a2
if __name__ == '__main__': main() First run the server, and then the client. On the client side, nothing is printed on the console; on the server side, you should see something like:
trusted_official_docs
CPython Docs
if __name__ == '__main__': main() First run the server, and then the client. On the client side, nothing is printed on the console; on the server side, you should see something like:
if __name__ == '__main__': main() First run the server, and then the client. On the client side, nothing is printed on the console; on the server side, you should see something like:
python, official-docs, cpython, P0
Local_Trusted_Corpus
e3560c81-01f6-4d0b-a16a-280fdf321680
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,957
supabase-export-v2
204846e7afbb9d9e
the library developer. If you are maintaining a library, ensure that you don't add handlers to any of your loggers other than a :class:`~logging.NullHandler` instance. Creating a lot of loggers ^^^^^^^^^^^^^^^^^^^^^^^^^
trusted_official_docs
CPython Docs
the library developer. If you are maintaining a library, ensure that you don't add handlers to any of your loggers other than a :class:`~logging.NullHandler` instance. Creating a lot of loggers ^^^^^^^^^^^^^^^^^^^^^^^^^
the library developer. If you are maintaining a library, ensure that you don't add handlers to any of your loggers other than a :class:`~logging.NullHandler` instance. Creating a lot of loggers ^^^^^^^^^^^^^^^^^^^^^^^^^
python, official-docs, cpython, P0
Local_Trusted_Corpus
e5b60307-3ee2-4460-b0ac-a8822ac3cecf
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,861
supabase-export-v2
13847a4ca272dda3
# Connect the non-worker slots and signals self.log_button.clicked.connect(self.manual_update) self.clear_button.clicked.connect(self.clear_display) # 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 shou...
trusted_official_docs
CPython Docs
# Connect the non-worker slots and signals self.log_button.clicked.connect(self.manual_update) self.clear_button.clicked.connect(self.clear_display) # 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 shou...
# Connect the non-worker slots and signals self.log_button.clicked.connect(self.manual_update) self.clear_button.clicked.connect(self.clear_display) # 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 shou...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e7b4da6e-0abb-4824-8988-be8466aa299b
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,881
supabase-export-v2
628f23acba179561
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} {sdata} {msg}' You'll need to be familiar with RFC 5424 to fully understand the above code, and it may be that you have slightly differe...
trusted_official_docs
CPython Docs
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} {sdata} {msg}' You'll need to be familiar with RFC 5424 to fully understand the above code, and it may be that you have slightly differe...
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} {sdata} {msg}' You'll need to be familiar with RFC 5424 to fully understand the above code, and it may be that you have slightly differe...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e820ba8d-981c-4796-9eb4-9ea769ba9b7e
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,349
supabase-export-v2
f7c457724af1fa5b
`Supervisor <http://supervisord.org/>`_. `Here is a Gist <socket-listener-gist_>`__ which provides the bare-bones files to run the above functionality using Supervisor. It consists of the following files: +-------------------------+----------------------------------------------------+ | File | Purpose | +==============...
trusted_official_docs
CPython Docs
`Supervisor <http://supervisord.org/>`_. `Here is a Gist <socket-listener-gist_>`__ which provides the bare-bones files to run the above functionality using Supervisor. It consists of the following files: +-------------------------+----------------------------------------------------+ | File | Purpose | +==============...
`Supervisor <http://supervisord.org/>`_. `Here is a Gist <socket-listener-gist_>`__ which provides the bare-bones files to run the above functionality using Supervisor. It consists of the following files: +-------------------------+----------------------------------------------------+ | File | Purpose | +==============...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e883c352-5d7b-40cb-b3ff-551ba3095c18
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,522
supabase-export-v2
9bb737bc91cbe9a3
different libraries wanted to do different things. Each would attempt to set its own :class:`Logger` subclass, and the one which did this last would win. The second approach works reasonably well for many cases, but does not allow you to e.g. use a specialized subclass of :class:`LogRecord`. Library developers can set ...
trusted_official_docs
CPython Docs
different libraries wanted to do different things. Each would attempt to set its own :class:`Logger` subclass, and the one which did this last would win. The second approach works reasonably well for many cases, but does not allow you to e.g. use a specialized subclass of :class:`LogRecord`. Library developers can set ...
different libraries wanted to do different things. Each would attempt to set its own :class:`Logger` subclass, and the one which did this last would win. The second approach works reasonably well for many cases, but does not allow you to e.g. use a specialized subclass of :class:`LogRecord`. Library developers can set ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e903d8c1-cecf-4c58-8ccc-3ced510cfefa
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,800
supabase-export-v2
984021d3b7e195cc
appear once on stderr. 5. This should appear twice - once on stderr and once on stdout. 6. This should appear just once on stderr. In this case, the message #5 printed to ``stdout`` doesn't appear, as expected.
trusted_official_docs
CPython Docs
appear once on stderr. 5. This should appear twice - once on stderr and once on stdout. 6. This should appear just once on stderr. In this case, the message #5 printed to ``stdout`` doesn't appear, as expected.
appear once on stderr. 5. This should appear twice - once on stderr and once on stdout. 6. This should appear just once on stderr. In this case, the message #5 printed to ``stdout`` doesn't appear, as expected.
python, official-docs, cpython, P0
Local_Trusted_Corpus
e94fb793-6490-4460-bb8a-570c6495e7a8
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,947
supabase-export-v2
340d961228d8f39a
* Adding a file handler more than once which references the same file (e.g. by a copy/paste/forget-to-change error). * Opening two files that look different, as they have different names, but are the same because one is a symbolic link to the other.
trusted_official_docs
CPython Docs
* Adding a file handler more than once which references the same file (e.g. by a copy/paste/forget-to-change error). * Opening two files that look different, as they have different names, but are the same because one is a symbolic link to the other.
* Adding a file handler more than once which references the same file (e.g. by a copy/paste/forget-to-change error). * Opening two files that look different, as they have different names, but are the same because one is a symbolic link to the other.
python, official-docs, cpython, P0
Local_Trusted_Corpus
e99ca38f-19eb-4e55-865d-23a8af25ec3d
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,605
supabase-export-v2
fe1ff312352dfb61
def listener_process(q, stop_event, config): """ This could be done in the main process, but is just done in a separate process for illustrative purposes. This initialises logging according to the specified configuration, starts the listener and waits for the main process to signal completion via the event. The liste...
trusted_official_docs
CPython Docs
def listener_process(q, stop_event, config): """ This could be done in the main process, but is just done in a separate process for illustrative purposes. This initialises logging according to the specified configuration, starts the listener and waits for the main process to signal completion via the event. The liste...
def listener_process(q, stop_event, config): """ This could be done in the main process, but is just done in a separate process for illustrative purposes. This initialises logging according to the specified configuration, starts the listener and waits for the main process to signal completion via the event. The liste...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e9a638f0-e7a5-4bb0-bb56-d024d4980afb
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,681
supabase-export-v2
5277390ef4b64a19
Using LogRecord factories ^^^^^^^^^^^^^^^^^^^^^^^^^ In Python 3.2, along with the :class:`~logging.Formatter` changes mentioned above, the logging package gained the ability to allow users to set their own :class:`LogRecord` subclasses, using the :func:`setLogRecordFactory` function. You can use this to set your own su...
trusted_official_docs
CPython Docs
Using LogRecord factories ^^^^^^^^^^^^^^^^^^^^^^^^^ In Python 3.2, along with the :class:`~logging.Formatter` changes mentioned above, the logging package gained the ability to allow users to set their own :class:`LogRecord` subclasses, using the :func:`setLogRecordFactory` function. You can use this to set your own su...
Using LogRecord factories ^^^^^^^^^^^^^^^^^^^^^^^^^ In Python 3.2, along with the :class:`~logging.Formatter` changes mentioned above, the logging package gained the ability to allow users to set their own :class:`LogRecord` subclasses, using the :func:`setLogRecordFactory` function. You can use this to set your own su...
python, official-docs, cpython, P0
Local_Trusted_Corpus
e9da5581-71ad-4671-aaee-4d9381e6dc2d
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,215
supabase-export-v2
a5b6ad03a443169b
import logging import auxiliary_module # create logger with 'spam_application' logger = logging.getLogger('spam_application') 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 l...
trusted_official_docs
CPython Docs
import logging import auxiliary_module # create logger with 'spam_application' logger = logging.getLogger('spam_application') 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 l...
import logging import auxiliary_module # create logger with 'spam_application' logger = logging.getLogger('spam_application') 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 l...
python, official-docs, cpython, P0
Local_Trusted_Corpus
eb2a4eb1-be1a-449e-bfb6-8af52974b408
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,411
supabase-export-v2
ab1ba2144ffdebe4
Create our context variables. These will be filled at the start of request # processing, and used in the logging that happens during that processing ctx_request = ContextVar('request') ctx_appname = ContextVar('appname')
trusted_official_docs
CPython Docs
Create our context variables. These will be filled at the start of request # processing, and used in the logging that happens during that processing ctx_request = ContextVar('request') ctx_appname = ContextVar('appname')
Create our context variables. These will be filled at the start of request # processing, and used in the logging that happens during that processing ctx_request = ContextVar('request') ctx_appname = ContextVar('appname')
python, official-docs, cpython, P0
Local_Trusted_Corpus
eb2cc2c3-9d63-4937-80e3-94dd95a1cc3e
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,365
supabase-export-v2
e9ec77a01623b1d0
Adding contextual information to your logging output ---------------------------------------------------- Sometimes you want logging output to contain contextual information in addition to the parameters passed to the logging call. For example, in a networked application, it may be desirable to log client-specific info...
trusted_official_docs
CPython Docs
Adding contextual information to your logging output ---------------------------------------------------- Sometimes you want logging output to contain contextual information in addition to the parameters passed to the logging call. For example, in a networked application, it may be desirable to log client-specific info...
Adding contextual information to your logging output ---------------------------------------------------- Sometimes you want logging output to contain contextual information in addition to the parameters passed to the logging call. For example, in a networked application, it may be desirable to log client-specific info...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ecee9aab-eee9-4242-a60b-dc84df038860
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,350
supabase-export-v2
db9628470491cd3e
:file:`webapp.json` | A JSON configuration file for the web application | +-------------------------+----------------------------------------------------+ | :file:`client.py` | A Python script to exercise the web application | +-------------------------+----------------------------------------------------+ The web appl...
trusted_official_docs
CPython Docs
:file:`webapp.json` | A JSON configuration file for the web application | +-------------------------+----------------------------------------------------+ | :file:`client.py` | A Python script to exercise the web application | +-------------------------+----------------------------------------------------+ The web appl...
:file:`webapp.json` | A JSON configuration file for the web application | +-------------------------+----------------------------------------------------+ | :file:`client.py` | A Python script to exercise the web application | +-------------------------+----------------------------------------------------+ The web appl...
python, official-docs, cpython, P0
Local_Trusted_Corpus
ed2d0989-0f11-4b13-8ec2-80195a0cd914
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,779
supabase-export-v2
fc1aa68fc41002f2
2015-10-17 12:53:29,501 The local time is Sat Oct 17 13:53:29 2015 2015-10-17 13:53:29,501 The local time is Sat Oct 17 13:53:29 2015 showing how the time is formatted both as local time and UTC, one for each handler.
trusted_official_docs
CPython Docs
2015-10-17 12:53:29,501 The local time is Sat Oct 17 13:53:29 2015 2015-10-17 13:53:29,501 The local time is Sat Oct 17 13:53:29 2015 showing how the time is formatted both as local time and UTC, one for each handler.
2015-10-17 12:53:29,501 The local time is Sat Oct 17 13:53:29 2015 2015-10-17 13:53:29,501 The local time is Sat Oct 17 13:53:29 2015 showing how the time is formatted both as local time and UTC, one for each handler.
python, official-docs, cpython, P0
Local_Trusted_Corpus
f15081b1-d32e-4960-8ede-72b225dc2eca
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,728
supabase-export-v2
dfdac324a24dbf8d
import logging import subprocess import sys class TTSHandler(logging.Handler): def emit(self, record): msg = self.format(record) # Speak slowly in a female English voice cmd = ['espeak', '-s150', '-ven+f3', msg] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # wait for the program to...
trusted_official_docs
CPython Docs
import logging import subprocess import sys class TTSHandler(logging.Handler): def emit(self, record): msg = self.format(record) # Speak slowly in a female English voice cmd = ['espeak', '-s150', '-ven+f3', msg] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # wait for the program to...
import logging import subprocess import sys class TTSHandler(logging.Handler): def emit(self, record): msg = self.format(record) # Speak slowly in a female English voice cmd = ['espeak', '-s150', '-ven+f3', msg] p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # wait for the program to...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f25f748f-ca4c-4aeb-bc2b-e8f3b816e19c
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,309
supabase-export-v2
7da5d751642b81d5
to document this (together with a suggestion to attach only ``QueueHandlers`` to your loggers) for the benefit of other developers who will use your code. The second part of the solution is :class:`QueueListener`, which has been designed as the counterpart to :class:`QueueHandler`. A :class:`QueueListener` is very simp...
trusted_official_docs
CPython Docs
to document this (together with a suggestion to attach only ``QueueHandlers`` to your loggers) for the benefit of other developers who will use your code. The second part of the solution is :class:`QueueListener`, which has been designed as the counterpart to :class:`QueueHandler`. A :class:`QueueListener` is very simp...
to document this (together with a suggestion to attach only ``QueueHandlers`` to your loggers) for the benefit of other developers who will use your code. The second part of the solution is :class:`QueueListener`, which has been designed as the counterpart to :class:`QueueHandler`. A :class:`QueueListener` is very simp...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f274722b-4152-40ff-8f99-96a5d100935f
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,370
supabase-export-v2
7f56a9283857c1dc
Delegate a debug call to the underlying logger, after adding contextual information from this adapter instance. """ msg, kwargs = self.process(msg, kwargs) self.logger.debug(msg, *args, **kwargs) The :meth:`~LoggerAdapter.process` method of :class:`LoggerAdapter` is where the contextual information is added to the logg...
trusted_official_docs
CPython Docs
Delegate a debug call to the underlying logger, after adding contextual information from this adapter instance. """ msg, kwargs = self.process(msg, kwargs) self.logger.debug(msg, *args, **kwargs) The :meth:`~LoggerAdapter.process` method of :class:`LoggerAdapter` is where the contextual information is added to the logg...
Delegate a debug call to the underlying logger, after adding contextual information from this adapter instance. """ msg, kwargs = self.process(msg, kwargs) self.logger.debug(msg, *args, **kwargs) The :meth:`~LoggerAdapter.process` method of :class:`LoggerAdapter` is where the contextual information is added to the logg...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f33bf577-43ed-4b41-8a20-9796b8bf83ba
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,928
supabase-export-v2
58a12d63846dfa86
class StreamHandler(MultilineMixin, logging.StreamHandler): pass if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-9s %(message)s', handlers = [StreamHandler()]) logger.debug('Single line') logger.debug('Multiple lines:\nfool me once ...') logger.debug('Another si...
trusted_official_docs
CPython Docs
class StreamHandler(MultilineMixin, logging.StreamHandler): pass if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-9s %(message)s', handlers = [StreamHandler()]) logger.debug('Single line') logger.debug('Multiple lines:\nfool me once ...') logger.debug('Another si...
class StreamHandler(MultilineMixin, logging.StreamHandler): pass if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-9s %(message)s', handlers = [StreamHandler()]) logger.debug('Single line') logger.debug('Multiple lines:\nfool me once ...') logger.debug('Another si...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f36735a8-d12f-4097-b0c9-4aea1cff881e
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,840
supabase-export-v2
e916c2ad02a5bb4f
A Qt GUI for logging -------------------- A question that comes up from time to time is about 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.
trusted_official_docs
CPython Docs
A Qt GUI for logging -------------------- A question that comes up from time to time is about 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.
A Qt GUI for logging -------------------- A question that comes up from time to time is about 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.
python, official-docs, cpython, P0
Local_Trusted_Corpus
f3f4126d-7cea-484b-9ec7-1ecd520ae332
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,325
supabase-export-v2
0fe550f804c06a37
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.addHandler(socketHandler) # Now, we can log to the r...
trusted_official_docs
CPython Docs
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.addHandler(socketHandler) # Now, we can log to the r...
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.addHandler(socketHandler) # Now, we can log to the r...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f438e2ca-7622-4292-88f1-1124fa6ee1c9
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,368
supabase-export-v2
e172acb1ebf35b5d
:meth:`exception`, :meth:`critical` and :meth:`log`. These methods have the same signatures as their counterparts in :class:`Logger`, so you can use the two types of instances interchangeably. When you create an instance of :class:`LoggerAdapter`, you pass it a :class:`Logger` instance and a dict-like object which cont...
trusted_official_docs
CPython Docs
:meth:`exception`, :meth:`critical` and :meth:`log`. These methods have the same signatures as their counterparts in :class:`Logger`, so you can use the two types of instances interchangeably. When you create an instance of :class:`LoggerAdapter`, you pass it a :class:`Logger` instance and a dict-like object which cont...
:meth:`exception`, :meth:`critical` and :meth:`log`. These methods have the same signatures as their counterparts in :class:`Logger`, so you can use the two types of instances interchangeably. When you create an instance of :class:`LoggerAdapter`, you pass it a :class:`Logger` instance and a dict-like object which cont...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f63e1f00-5c7b-4359-b2b6-8e36e9b76093
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,852
supabase-export-v2
b8ae51c7bb8d0733
Python level # are named something like "Dummy-1". The function below gets the Qt name of the # current thread. # def ctname(): return QtCore.QThread.currentThread().objectName() # # Used to generate random levels for logging. # LEVELS = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL)
trusted_official_docs
CPython Docs
Python level # are named something like "Dummy-1". The function below gets the Qt name of the # current thread. # def ctname(): return QtCore.QThread.currentThread().objectName() # # Used to generate random levels for logging. # LEVELS = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL)
Python level # are named something like "Dummy-1". The function below gets the Qt name of the # current thread. # def ctname(): return QtCore.QThread.currentThread().objectName() # # Used to generate random levels for logging. # LEVELS = (logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.CRITICAL)
python, official-docs, cpython, P0
Local_Trusted_Corpus
f6c4d90b-cbe0-4e61-a539-9764faa24f12
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,922
supabase-export-v2
f174d0518e4bf633
# Assume this is in a module mymixins.py import copy class MultilineMixin: def emit(self, record): s = record.getMessage() if '\n' not in s: super().emit(record) else: lines = s.splitlines() rec = copy.copy(record) rec.args = None for line in lines: rec.msg = line super().emit(rec)
trusted_official_docs
CPython Docs
# Assume this is in a module mymixins.py import copy class MultilineMixin: def emit(self, record): s = record.getMessage() if '\n' not in s: super().emit(record) else: lines = s.splitlines() rec = copy.copy(record) rec.args = None for line in lines: rec.msg = line super().emit(rec)
# Assume this is in a module mymixins.py import copy class MultilineMixin: def emit(self, record): s = record.getMessage() if '\n' not in s: super().emit(record) else: lines = s.splitlines() rec = copy.copy(record) rec.args = None for line in lines: rec.msg = line super().emit(rec)
python, official-docs, cpython, P0
Local_Trusted_Corpus
f75f265d-d04c-4adc-8ae8-45a832753f71
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,702
supabase-export-v2
c291e1599d2c20a6
record): if self.param is None: allow = True else: allow = self.param not in record.msg if allow: record.msg = 'changed: ' + record.msg return allow LOGGING = { 'version': 1, 'filters': { 'myfilter': { '()': MyFilter, 'param': 'noshow', } }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'filte...
trusted_official_docs
CPython Docs
record): if self.param is None: allow = True else: allow = self.param not in record.msg if allow: record.msg = 'changed: ' + record.msg return allow LOGGING = { 'version': 1, 'filters': { 'myfilter': { '()': MyFilter, 'param': 'noshow', } }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'filte...
record): if self.param is None: allow = True else: allow = self.param not in record.msg if allow: record.msg = 'changed: ' + record.msg return allow LOGGING = { 'version': 1, 'filters': { 'myfilter': { '()': MyFilter, 'param': 'noshow', } }, 'handlers': { 'console': { 'class': 'logging.StreamHandler', 'filte...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f7743c8c-bc3f-419b-88e2-753877c625c1
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,889
supabase-export-v2
52b4b8b105923331
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 close(self): # doesn't actually do anything, but might be expected of a file-like # object - so optional depending on your situation. You might want # to set a flag so tha...
trusted_official_docs
CPython Docs
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 close(self): # doesn't actually do anything, but might be expected of a file-like # object - so optional depending on your situation. You might want # to set a flag so tha...
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 close(self): # doesn't actually do anything, but might be expected of a file-like # object - so optional depending on your situation. You might want # to set a flag so tha...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f7c0bd97-39fc-4da6-96f2-3affc2e61254
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,661
supabase-export-v2
4f1d209c9c68e3cc
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) LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'default': { ...
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) LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'default': { ...
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) LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'default': { ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f8172c0d-4a1e-4c16-b430-4b7a07ade012
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,929
supabase-export-v2
3be009f9f59fc765
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-9s %(message)s', handlers = [StreamHandler()]) logger.debug('Single line') logger.debug('Multiple lines:\nfool me once ...') logger.debug('Another single line') logger.debug('Multiple lines:\n%s', 'fool me ...\ncan\'t get fooled again') The scrip...
trusted_official_docs
CPython Docs
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-9s %(message)s', handlers = [StreamHandler()]) logger.debug('Single line') logger.debug('Multiple lines:\nfool me once ...') logger.debug('Another single line') logger.debug('Multiple lines:\n%s', 'fool me ...\ncan\'t get fooled again') The scrip...
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-9s %(message)s', handlers = [StreamHandler()]) logger.debug('Single line') logger.debug('Multiple lines:\nfool me once ...') logger.debug('Another single line') logger.debug('Multiple lines:\n%s', 'fool me ...\ncan\'t get fooled again') The scrip...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f83329a9-4e3f-455d-a570-3ac0b5d88112
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,580
supabase-export-v2
c3f13e2a585a255c
657 Message no. 7 CRITICAL myapp.lib1 613 Message no. 7 INFO myapp.lib1 613 Message no. 8 DEBUG myapp.lib1 657 Message no. 8 (and so on) As you can see, the logging from the two sender processes is interleaved in the listener's output.
trusted_official_docs
CPython Docs
657 Message no. 7 CRITICAL myapp.lib1 613 Message no. 7 INFO myapp.lib1 613 Message no. 8 DEBUG myapp.lib1 657 Message no. 8 (and so on) As you can see, the logging from the two sender processes is interleaved in the listener's output.
657 Message no. 7 CRITICAL myapp.lib1 613 Message no. 7 INFO myapp.lib1 613 Message no. 8 DEBUG myapp.lib1 657 Message no. 8 (and so on) As you can see, the logging from the two sender processes is interleaved in the listener's output.
python, official-docs, cpython, P0
Local_Trusted_Corpus
f8515b76-bf5c-47ca-9647-a357d17b95c7
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,752
supabase-export-v2
833d015d51db6a96
.. code-block:: none Calling undecorated foo with False about to log at DEBUG ... about to log at INFO ... about to log at WARNING ... Calling undecorated foo with True about to log at DEBUG ... about to log at INFO ... about to log at WARNING ... about to log at ERROR ... about to log at CRITICAL ... Calling decorat...
trusted_official_docs
CPython Docs
.. code-block:: none Calling undecorated foo with False about to log at DEBUG ... about to log at INFO ... about to log at WARNING ... Calling undecorated foo with True about to log at DEBUG ... about to log at INFO ... about to log at WARNING ... about to log at ERROR ... about to log at CRITICAL ... Calling decorat...
.. code-block:: none Calling undecorated foo with False about to log at DEBUG ... about to log at INFO ... about to log at WARNING ... Calling undecorated foo with True about to log at DEBUG ... about to log at INFO ... about to log at WARNING ... about to log at ERROR ... about to log at CRITICAL ... Calling decorat...
python, official-docs, cpython, P0
Local_Trusted_Corpus
f87b0cb7-c234-4605-ba4c-7a2cd4d49f0b
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,419
supabase-export-v2
b1cf1ad430264f9b
to process app = choice(apps) request = choice(REQUESTS) # Process the request in its own thread t = threading.Thread(target=app.process_request, args=(request,)) threads.append(t) t.start() except KeyboardInterrupt: break # Wait for the threads to terminate for t in threads: t.join()
trusted_official_docs
CPython Docs
to process app = choice(apps) request = choice(REQUESTS) # Process the request in its own thread t = threading.Thread(target=app.process_request, args=(request,)) threads.append(t) t.start() except KeyboardInterrupt: break # Wait for the threads to terminate for t in threads: t.join()
to process app = choice(apps) request = choice(REQUESTS) # Process the request in its own thread t = threading.Thread(target=app.process_request, args=(request,)) threads.append(t) t.start() except KeyboardInterrupt: break # Wait for the threads to terminate for t in threads: t.join()
python, official-docs, cpython, P0
Local_Trusted_Corpus
f989d308-bcb2-467d-9ac9-4bc17cf039ed
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,843
supabase-export-v2
e4b68c1c28c8a2a8
``QThread`` class rather than the :mod:`threading` module, as there are circumstances where one has to use ``QThread``, which offers better integration with other ``Qt`` components. The code should work with recent releases of any of ``PySide6``, ``PyQt6``, ``PySide2`` or ``PyQt5``. You should be able to adapt the appr...
trusted_official_docs
CPython Docs
``QThread`` class rather than the :mod:`threading` module, as there are circumstances where one has to use ``QThread``, which offers better integration with other ``Qt`` components. The code should work with recent releases of any of ``PySide6``, ``PyQt6``, ``PySide2`` or ``PyQt5``. You should be able to adapt the appr...
``QThread`` class rather than the :mod:`threading` module, as there are circumstances where one has to use ``QThread``, which offers better integration with other ``Qt`` components. The code should work with recent releases of any of ``PySide6``, ``PyQt6``, ``PySide2`` or ``PyQt5``. You should be able to adapt the appr...
python, official-docs, cpython, P0
Local_Trusted_Corpus
fb37581e-5437-4063-b0c4-5374cceffec1
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,413
supabase-export-v2
add05cf3a38a0bd0
context-specific information into logs and ensures that only information for a specific webapp is included in its log """ def __init__(self, app): self.app = app def filter(self, record): request = ctx_request.get() record.method = request.method record.ip = request.ip record.user = request.user record.appName = a...
trusted_official_docs
CPython Docs
context-specific information into logs and ensures that only information for a specific webapp is included in its log """ def __init__(self, app): self.app = app def filter(self, record): request = ctx_request.get() record.method = request.method record.ip = request.ip record.user = request.user record.appName = a...
context-specific information into logs and ensures that only information for a specific webapp is included in its log """ def __init__(self, app): self.app = app def filter(self, record): request = ctx_request.get() record.method = request.method record.ip = request.ip record.user = request.user record.appName = a...
python, official-docs, cpython, P0
Local_Trusted_Corpus
fb8e9cb9-d18e-4c75-8228-d8e95cdd346c
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,604
supabase-export-v2
a3f525b8da709685
transformed just to show that it's the listener # doing the logging to files and console record.processName = '%s (for %s)' % (current_process().name, record.processName) logger.handle(record) def listener_process(q, stop_event, config): """ This could be done in the main process, but is just done in a separate proc...
trusted_official_docs
CPython Docs
transformed just to show that it's the listener # doing the logging to files and console record.processName = '%s (for %s)' % (current_process().name, record.processName) logger.handle(record) def listener_process(q, stop_event, config): """ This could be done in the main process, but is just done in a separate proc...
transformed just to show that it's the listener # doing the logging to files and console record.processName = '%s (for %s)' % (current_process().name, record.processName) logger.handle(record) def listener_process(q, stop_event, config): """ This could be done in the main process, but is just done in a separate proc...
python, official-docs, cpython, P0
Local_Trusted_Corpus
fbfb2835-e88a-4458-938b-320df22e089d
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,560
supabase-export-v2
14b2099596fcf76f
when you hit Ctrl-C break if data is None: return None # Get the logging event sent from a publisher event = json.loads(data.decode('utf-8')) return logging.makeLogRecord(event) def enqueue_sentinel(self): # Not used in this implementation, as the socket isn't really a # queue pass
trusted_official_docs
CPython Docs
when you hit Ctrl-C break if data is None: return None # Get the logging event sent from a publisher event = json.loads(data.decode('utf-8')) return logging.makeLogRecord(event) def enqueue_sentinel(self): # Not used in this implementation, as the socket isn't really a # queue pass
when you hit Ctrl-C break if data is None: return None # Get the logging event sent from a publisher event = json.loads(data.decode('utf-8')) return logging.makeLogRecord(event) def enqueue_sentinel(self): # Not used in this implementation, as the socket isn't really a # queue pass
python, official-docs, cpython, P0
Local_Trusted_Corpus
fdb3fd8a-8908-4440-9be6-b517ab2245fb
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,911
supabase-export-v2
f3eae7543d4fc641
WARNING:demo: WARNING:demo:1 / 0 WARNING:demo:ZeroDivisionError WARNING:demo:: WARNING:demo:division by zero As you can see, this output isn't ideal. That's because the underlying code which writes to ``sys.stderr`` makes multiple writes, each of which results in a separate logged line (for example, the last three line...
trusted_official_docs
CPython Docs
WARNING:demo: WARNING:demo:1 / 0 WARNING:demo:ZeroDivisionError WARNING:demo:: WARNING:demo:division by zero As you can see, this output isn't ideal. That's because the underlying code which writes to ``sys.stderr`` makes multiple writes, each of which results in a separate logged line (for example, the last three line...
WARNING:demo: WARNING:demo:1 / 0 WARNING:demo:ZeroDivisionError WARNING:demo:: WARNING:demo:division by zero As you can see, this output isn't ideal. That's because the underlying code which writes to ``sys.stderr`` makes multiple writes, each of which results in a separate logged line (for example, the last three line...
python, official-docs, cpython, P0
Local_Trusted_Corpus
fe45f52c-3ab5-41e1-a622-7f973b173a1d
CPython Docs
file://datasets/cpython/Doc/howto/logging-cookbook.rst
unknown
5070c1c1-62f1-4f2f-bb22-ac9ebc36a263
56,744
supabase-export-v2
73bc74bb00b2fa25
target_handler is None: target_handler = logging.StreamHandler() if flush_level is None: flush_level = logging.ERROR if capacity is None: capacity = 100 handler = MemoryHandler(capacity, flushLevel=flush_level, target=target_handler) def decorator(fn): def wrapper(*args, **kwargs): logger.addHandler(handler) try: r...
trusted_official_docs
CPython Docs
target_handler is None: target_handler = logging.StreamHandler() if flush_level is None: flush_level = logging.ERROR if capacity is None: capacity = 100 handler = MemoryHandler(capacity, flushLevel=flush_level, target=target_handler) def decorator(fn): def wrapper(*args, **kwargs): logger.addHandler(handler) try: r...
target_handler is None: target_handler = logging.StreamHandler() if flush_level is None: flush_level = logging.ERROR if capacity is None: capacity = 100 handler = MemoryHandler(capacity, flushLevel=flush_level, target=target_handler) def decorator(fn): def wrapper(*args, **kwargs): logger.addHandler(handler) try: r...
python, official-docs, cpython, P0
Local_Trusted_Corpus
3e397342-8e38-49ea-bf4e-c6752319de53
CPython Docs
file://datasets/cpython/Doc/howto/argparse-optparse.rst
unknown
9283e594-5642-47e6-8c3c-ecef596a2c9c
56,973
supabase-export-v2
c9f8fa9798570ef4
that are considering migrating should also review the list of intrinsic behavioural differences described in that section before deciding whether or not migration is desirable. For applications that do choose to migrate from :mod:`optparse` to :mod:`argparse`, the following suggestions should be helpful:
trusted_official_docs
CPython Docs
that are considering migrating should also review the list of intrinsic behavioural differences described in that section before deciding whether or not migration is desirable. For applications that do choose to migrate from :mod:`optparse` to :mod:`argparse`, the following suggestions should be helpful:
that are considering migrating should also review the list of intrinsic behavioural differences described in that section before deciding whether or not migration is desirable. For applications that do choose to migrate from :mod:`optparse` to :mod:`argparse`, the following suggestions should be helpful:
python, official-docs, cpython, P0
Local_Trusted_Corpus
516dd52d-944d-45c0-a2aa-3c2cf4dd5688
CPython Docs
file://datasets/cpython/Doc/howto/argparse-optparse.rst
unknown
9283e594-5642-47e6-8c3c-ecef596a2c9c
56,970
supabase-export-v2
005663b0a0b9e2ca
``/``. * Handling zero-or-more and one-or-more style arguments. * Producing more informative usage messages. * Providing a much simpler interface for custom ``type`` and ``action``. Originally, the :mod:`argparse` module attempted to maintain compatibility with :mod:`optparse`. However, the fundamental design differenc...
trusted_official_docs
CPython Docs
``/``. * Handling zero-or-more and one-or-more style arguments. * Producing more informative usage messages. * Providing a much simpler interface for custom ``type`` and ``action``. Originally, the :mod:`argparse` module attempted to maintain compatibility with :mod:`optparse`. However, the fundamental design differenc...
``/``. * Handling zero-or-more and one-or-more style arguments. * Producing more informative usage messages. * Providing a much simpler interface for custom ``type`` and ``action``. Originally, the :mod:`argparse` module attempted to maintain compatibility with :mod:`optparse`. However, the fundamental design differenc...
python, official-docs, cpython, P0
Local_Trusted_Corpus
57d459e0-e42d-40d0-9a06-51c4bab95d91
CPython Docs
file://datasets/cpython/Doc/howto/argparse-optparse.rst
unknown
9283e594-5642-47e6-8c3c-ecef596a2c9c
56,972
supabase-export-v2
cd493d29445b3176
As described in :ref:`choosing-an-argument-parser`, applications that are currently using :mod:`optparse` and are happy with the way it works can just continue to use ``optparse``. Application developers that are considering migrating should also review the list of intrinsic behavioural differences described in that se...
trusted_official_docs
CPython Docs
As described in :ref:`choosing-an-argument-parser`, applications that are currently using :mod:`optparse` and are happy with the way it works can just continue to use ``optparse``. Application developers that are considering migrating should also review the list of intrinsic behavioural differences described in that se...
As described in :ref:`choosing-an-argument-parser`, applications that are currently using :mod:`optparse` and are happy with the way it works can just continue to use ``optparse``. Application developers that are considering migrating should also review the list of intrinsic behavioural differences described in that se...
python, official-docs, cpython, P0
Local_Trusted_Corpus
596c082f-5839-4a6a-8df6-df58e8a109c4
CPython Docs
file://datasets/cpython/Doc/howto/argparse-optparse.rst
unknown
9283e594-5642-47e6-8c3c-ecef596a2c9c
56,981
supabase-export-v2
11e59d13325e11a7
strings with implicit arguments such as ``%default`` or ``%prog`` with the standard Python syntax to use dictionaries to format strings, that is, ``%(default)s`` and ``%(prog)s``. * Replace the OptionParser constructor ``version`` argument with a call to ``parser.add_argument('--version', action='version', version='<t...
trusted_official_docs
CPython Docs
strings with implicit arguments such as ``%default`` or ``%prog`` with the standard Python syntax to use dictionaries to format strings, that is, ``%(default)s`` and ``%(prog)s``. * Replace the OptionParser constructor ``version`` argument with a call to ``parser.add_argument('--version', action='version', version='<t...
strings with implicit arguments such as ``%default`` or ``%prog`` with the standard Python syntax to use dictionaries to format strings, that is, ``%(default)s`` and ``%(prog)s``. * Replace the OptionParser constructor ``version`` argument with a call to ``parser.add_argument('--version', action='version', version='<t...
python, official-docs, cpython, P0
Local_Trusted_Corpus
6e21945b-9762-4868-8870-0b6ecdd92947
CPython Docs
file://datasets/cpython/Doc/howto/argparse-optparse.rst
unknown
9283e594-5642-47e6-8c3c-ecef596a2c9c
56,969
supabase-export-v2
c02591cecd254c09
The :mod:`argparse` module offers several higher level features not natively provided by the :mod:`optparse` module, including: * Handling positional arguments. * Supporting subcommands. * Allowing alternative option prefixes like ``+`` and ``/``. * Handling zero-or-more and one-or-more style arguments. * Producing mor...
trusted_official_docs
CPython Docs
The :mod:`argparse` module offers several higher level features not natively provided by the :mod:`optparse` module, including: * Handling positional arguments. * Supporting subcommands. * Allowing alternative option prefixes like ``+`` and ``/``. * Handling zero-or-more and one-or-more style arguments. * Producing mor...
The :mod:`argparse` module offers several higher level features not natively provided by the :mod:`optparse` module, including: * Handling positional arguments. * Supporting subcommands. * Allowing alternative option prefixes like ``+`` and ``/``. * Handling zero-or-more and one-or-more style arguments. * Producing mor...
python, official-docs, cpython, P0
Local_Trusted_Corpus
9f91a358-1222-4db3-945d-f6ee63f45cc2
CPython Docs
file://datasets/cpython/Doc/howto/argparse-optparse.rst
unknown
9283e594-5642-47e6-8c3c-ecef596a2c9c
56,980
supabase-export-v2
c771bfd7e690876a
* Replace :class:`optparse.Values` with :class:`Namespace` and :exc:`optparse.OptionError` and :exc:`optparse.OptionValueError` with :exc:`ArgumentError`. * Replace strings with implicit arguments such as ``%default`` or ``%prog`` with the standard Python syntax to use dictionaries to format strings, that is, ``%(def...
trusted_official_docs
CPython Docs
* Replace :class:`optparse.Values` with :class:`Namespace` and :exc:`optparse.OptionError` and :exc:`optparse.OptionValueError` with :exc:`ArgumentError`. * Replace strings with implicit arguments such as ``%default`` or ``%prog`` with the standard Python syntax to use dictionaries to format strings, that is, ``%(def...
* Replace :class:`optparse.Values` with :class:`Namespace` and :exc:`optparse.OptionError` and :exc:`optparse.OptionValueError` with :exc:`ArgumentError`. * Replace strings with implicit arguments such as ``%default`` or ``%prog`` with the standard Python syntax to use dictionaries to format strings, that is, ``%(def...
python, official-docs, cpython, P0
Local_Trusted_Corpus
c41513c8-24a8-4c43-9c60-397f8c90fc59
CPython Docs
file://datasets/cpython/Doc/howto/argparse-optparse.rst
unknown
9283e594-5642-47e6-8c3c-ecef596a2c9c
56,971
supabase-export-v2
e6a09a8060075816
code), and supporting both named options and positional arguments in the declarative interface mean that the API has diverged from that of ``optparse`` over time. As described in :ref:`choosing-an-argument-parser`, applications that are currently using :mod:`optparse` and are happy with the way it works can just contin...
trusted_official_docs
CPython Docs
code), and supporting both named options and positional arguments in the declarative interface mean that the API has diverged from that of ``optparse`` over time. As described in :ref:`choosing-an-argument-parser`, applications that are currently using :mod:`optparse` and are happy with the way it works can just contin...
code), and supporting both named options and positional arguments in the declarative interface mean that the API has diverged from that of ``optparse`` over time. As described in :ref:`choosing-an-argument-parser`, applications that are currently using :mod:`optparse` and are happy with the way it works can just contin...
python, official-docs, cpython, P0
Local_Trusted_Corpus
cde5aed0-8cba-4138-b926-6cc6247b5556
CPython Docs
file://datasets/cpython/Doc/howto/argparse-optparse.rst
unknown
9283e594-5642-47e6-8c3c-ecef596a2c9c
56,976
supabase-export-v2
c95d6b26cf3cd09a
add additional :meth:`ArgumentParser.add_argument` calls for the positional arguments. Keep in mind that what was previously called ``options``, now in the :mod:`argparse` context is called ``args``. * Replace :meth:`optparse.OptionParser.disable_interspersed_args` by using :meth:`~ArgumentParser.parse_intermixed_args...
trusted_official_docs
CPython Docs
add additional :meth:`ArgumentParser.add_argument` calls for the positional arguments. Keep in mind that what was previously called ``options``, now in the :mod:`argparse` context is called ``args``. * Replace :meth:`optparse.OptionParser.disable_interspersed_args` by using :meth:`~ArgumentParser.parse_intermixed_args...
add additional :meth:`ArgumentParser.add_argument` calls for the positional arguments. Keep in mind that what was previously called ``options``, now in the :mod:`argparse` context is called ``args``. * Replace :meth:`optparse.OptionParser.disable_interspersed_args` by using :meth:`~ArgumentParser.parse_intermixed_args...
python, official-docs, cpython, P0
Local_Trusted_Corpus
d2fbdd38-4a9a-4afb-b13f-ae4728dde690
CPython Docs
file://datasets/cpython/Doc/howto/argparse-optparse.rst
unknown
9283e594-5642-47e6-8c3c-ecef596a2c9c
56,978
supabase-export-v2
031f8a29a570f5ca
* Replace callback actions and the ``callback_*`` keyword arguments with ``type`` or ``action`` arguments. * Replace string names for ``type`` keyword arguments with the corresponding type objects (e.g. int, float, complex, etc).
trusted_official_docs
CPython Docs
* Replace callback actions and the ``callback_*`` keyword arguments with ``type`` or ``action`` arguments. * Replace string names for ``type`` keyword arguments with the corresponding type objects (e.g. int, float, complex, etc).
* Replace callback actions and the ``callback_*`` keyword arguments with ``type`` or ``action`` arguments. * Replace string names for ``type`` keyword arguments with the corresponding type objects (e.g. int, float, complex, etc).
python, official-docs, cpython, P0
Local_Trusted_Corpus
dcf84cec-c351-4ec1-a699-fcf28717810c
CPython Docs
file://datasets/cpython/Doc/howto/argparse-optparse.rst
unknown
9283e594-5642-47e6-8c3c-ecef596a2c9c
56,975
supabase-export-v2
71cf2af7818cc2d3
* Replace all :meth:`optparse.OptionParser.add_option` calls with :meth:`ArgumentParser.add_argument` calls. * Replace ``(options, args) = parser.parse_args()`` with ``args = parser.parse_args()`` and add additional :meth:`ArgumentParser.add_argument` calls for the positional arguments. Keep in mind that what was pre...
trusted_official_docs
CPython Docs
* Replace all :meth:`optparse.OptionParser.add_option` calls with :meth:`ArgumentParser.add_argument` calls. * Replace ``(options, args) = parser.parse_args()`` with ``args = parser.parse_args()`` and add additional :meth:`ArgumentParser.add_argument` calls for the positional arguments. Keep in mind that what was pre...
* Replace all :meth:`optparse.OptionParser.add_option` calls with :meth:`ArgumentParser.add_argument` calls. * Replace ``(options, args) = parser.parse_args()`` with ``args = parser.parse_args()`` and add additional :meth:`ArgumentParser.add_argument` calls for the positional arguments. Keep in mind that what was pre...
python, official-docs, cpython, P0
Local_Trusted_Corpus
003d6d3a-d97a-45df-bc89-81d9a1db5e0f
CPython Docs
file://datasets/cpython/Doc/howto/functional.rst
unknown
96a5a3c7-7880-46e2-a48a-2e8064e3ea09
57,043
supabase-export-v2
279e77d1d2449734
Generator expressions and list comprehensions ============================================= Two common operations on an iterator's output are 1) performing some operation for every element, 2) selecting a subset of elements that meet some condition. For example, given a list of strings, you might want to strip off trai...
trusted_official_docs
CPython Docs
Generator expressions and list comprehensions ============================================= Two common operations on an iterator's output are 1) performing some operation for every element, 2) selecting a subset of elements that meet some condition. For example, given a list of strings, you might want to strip off trai...
Generator expressions and list comprehensions ============================================= Two common operations on an iterator's output are 1) performing some operation for every element, 2) selecting a subset of elements that meet some condition. For example, given a list of strings, you might want to strip off trai...
python, official-docs, cpython, P0
Local_Trusted_Corpus
00a73b24-3fba-4f79-982e-2d16df81dba8
CPython Docs
file://datasets/cpython/Doc/howto/functional.rst
unknown
96a5a3c7-7880-46e2-a48a-2e8064e3ea09
57,093
supabase-export-v2
409ee1a1f87bb193
And here's an example of changing the counter: >>> it = counter(10) #doctest: +SKIP >>> next(it) #doctest: +SKIP 0 >>> next(it) #doctest: +SKIP 1 >>> it.send(8) #doctest: +SKIP 8 >>> next(it) #doctest: +SKIP 9 >>> next(it) #doctest: +SKIP Traceback (most recent call last): File "t.py", line 15, in <module> ...
trusted_official_docs
CPython Docs
And here's an example of changing the counter: >>> it = counter(10) #doctest: +SKIP >>> next(it) #doctest: +SKIP 0 >>> next(it) #doctest: +SKIP 1 >>> it.send(8) #doctest: +SKIP 8 >>> next(it) #doctest: +SKIP 9 >>> next(it) #doctest: +SKIP Traceback (most recent call last): File "t.py", line 15, in <module> ...
And here's an example of changing the counter: >>> it = counter(10) #doctest: +SKIP >>> next(it) #doctest: +SKIP 0 >>> next(it) #doctest: +SKIP 1 >>> it.send(8) #doctest: +SKIP 8 >>> next(it) #doctest: +SKIP 9 >>> next(it) #doctest: +SKIP Traceback (most recent call last): File "t.py", line 15, in <module> ...
python, official-docs, cpython, P0
Local_Trusted_Corpus
04388075-a04a-48ec-b655-151ffa792fd2
CPython Docs
file://datasets/cpython/Doc/howto/functional.rst
unknown
96a5a3c7-7880-46e2-a48a-2e8064e3ea09
57,035
supabase-export-v2
63942f11206864cf
dictionary iteration order is guaranteed to be the same as the insertion order. In earlier versions, the behaviour was unspecified and could vary between implementations. Applying :func:`iter` to a dictionary always loops over the keys, but dictionaries have methods that return other iterators. If you want to iterate o...
trusted_official_docs
CPython Docs
dictionary iteration order is guaranteed to be the same as the insertion order. In earlier versions, the behaviour was unspecified and could vary between implementations. Applying :func:`iter` to a dictionary always loops over the keys, but dictionaries have methods that return other iterators. If you want to iterate o...
dictionary iteration order is guaranteed to be the same as the insertion order. In earlier versions, the behaviour was unspecified and could vary between implementations. Applying :func:`iter` to a dictionary always loops over the keys, but dictionaries have methods that return other iterators. If you want to iterate o...
python, official-docs, cpython, P0
Local_Trusted_Corpus
04ef67de-cdc4-4f71-87fb-9f7852af6bb7
CPython Docs
file://datasets/cpython/Doc/howto/functional.rst
unknown
96a5a3c7-7880-46e2-a48a-2e8064e3ea09
57,223
supabase-export-v2
e06dcb49616a7e2f
it takes time to disentangle the expression to figure out what's going on. Using a short nested ``def`` statements makes things a little bit better:: import functools def combine(a, b): return 0, a[1] + b[1]
trusted_official_docs
CPython Docs
it takes time to disentangle the expression to figure out what's going on. Using a short nested ``def`` statements makes things a little bit better:: import functools def combine(a, b): return 0, a[1] + b[1]
it takes time to disentangle the expression to figure out what's going on. Using a short nested ``def`` statements makes things a little bit better:: import functools def combine(a, b): return 0, a[1] + b[1]
python, official-docs, cpython, P0
Local_Trusted_Corpus
05b0d5f5-43d9-4179-a632-b918ec994d1f
CPython Docs
file://datasets/cpython/Doc/howto/functional.rst
unknown
96a5a3c7-7880-46e2-a48a-2e8064e3ea09
57,027
supabase-export-v2
c0e4d1e369900672
Sequence unpacking also supports iterators: if you know an iterator will return N elements, you can unpack them into an N-tuple: >>> L = [1, 2, 3] >>> iterator = iter(L) >>> a, b, c = iterator >>> a, b, c (1, 2, 3)
trusted_official_docs
CPython Docs
Sequence unpacking also supports iterators: if you know an iterator will return N elements, you can unpack them into an N-tuple: >>> L = [1, 2, 3] >>> iterator = iter(L) >>> a, b, c = iterator >>> a, b, c (1, 2, 3)
Sequence unpacking also supports iterators: if you know an iterator will return N elements, you can unpack them into an N-tuple: >>> L = [1, 2, 3] >>> iterator = iter(L) >>> a, b, c = iterator >>> a, b, c (1, 2, 3)
python, official-docs, cpython, P0
Local_Trusted_Corpus
06432326-2c29-45a1-9beb-2c44da67d7ec
CPython Docs
file://datasets/cpython/Doc/howto/functional.rst
unknown
96a5a3c7-7880-46e2-a48a-2e8064e3ea09
57,082
supabase-export-v2
d48b83fd35e7ed1f
threatens another) and the Knight's Tour (finding a route that takes a knight to every square of an NxN chessboard without visiting any square twice). Passing values into a generator -------------------------------
trusted_official_docs
CPython Docs
threatens another) and the Knight's Tour (finding a route that takes a knight to every square of an NxN chessboard without visiting any square twice). Passing values into a generator -------------------------------
threatens another) and the Knight's Tour (finding a route that takes a knight to every square of an NxN chessboard without visiting any square twice). Passing values into a generator -------------------------------
python, official-docs, cpython, P0
Local_Trusted_Corpus
066a8ff3-c41d-4681-b4c6-f3a667856cab
CPython Docs
file://datasets/cpython/Doc/howto/functional.rst
unknown
96a5a3c7-7880-46e2-a48a-2e8064e3ea09
57,099
supabase-export-v2
fef434dfb2e862c8
If you need to run cleanup code when a :exc:`GeneratorExit` occurs, I suggest using a ``try: ... finally:`` suite instead of catching :exc:`GeneratorExit`. The cumulative effect of these changes is to turn generators from one-way producers of information into both producers and consumers.
trusted_official_docs
CPython Docs
If you need to run cleanup code when a :exc:`GeneratorExit` occurs, I suggest using a ``try: ... finally:`` suite instead of catching :exc:`GeneratorExit`. The cumulative effect of these changes is to turn generators from one-way producers of information into both producers and consumers.
If you need to run cleanup code when a :exc:`GeneratorExit` occurs, I suggest using a ``try: ... finally:`` suite instead of catching :exc:`GeneratorExit`. The cumulative effect of these changes is to turn generators from one-way producers of information into both producers and consumers.
python, official-docs, cpython, P0
Local_Trusted_Corpus