To be used to temporarily change the logging settings.
(trace_level, stream)
| 106 | |
| 107 | @contextmanager |
| 108 | def log_context(trace_level, stream): |
| 109 | """ |
| 110 | To be used to temporarily change the logging settings. |
| 111 | """ |
| 112 | with _LoggingGlobals._initialize_lock: |
| 113 | original_trace_level = DebugInfoHolder.DEBUG_TRACE_LEVEL |
| 114 | original_debug_stream = _LoggingGlobals._debug_stream |
| 115 | original_pydevd_debug_file = DebugInfoHolder.PYDEVD_DEBUG_FILE |
| 116 | original_debug_stream_filename = _LoggingGlobals._debug_stream_filename |
| 117 | original_initialized = _LoggingGlobals._debug_stream_initialized |
| 118 | |
| 119 | DebugInfoHolder.DEBUG_TRACE_LEVEL = trace_level |
| 120 | _LoggingGlobals._debug_stream = stream |
| 121 | _LoggingGlobals._debug_stream_initialized = True |
| 122 | try: |
| 123 | yield |
| 124 | finally: |
| 125 | with _LoggingGlobals._initialize_lock: |
| 126 | DebugInfoHolder.DEBUG_TRACE_LEVEL = original_trace_level |
| 127 | _LoggingGlobals._debug_stream = original_debug_stream |
| 128 | DebugInfoHolder.PYDEVD_DEBUG_FILE = original_pydevd_debug_file |
| 129 | _LoggingGlobals._debug_stream_filename = original_debug_stream_filename |
| 130 | _LoggingGlobals._debug_stream_initialized = original_initialized |
| 131 | |
| 132 | |
| 133 | import time |
no outgoing calls