MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / log_context

Function log_context

_pydev_bundle/pydev_log.py:108–130  ·  view source on GitHub ↗

To be used to temporarily change the logging settings.

(trace_level, stream)

Source from the content-addressed store, hash-verified

106
107@contextmanager
108def 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
133import time

Callers 4

test_pydevd_logFunction · 0.90
disable_critical_logFunction · 0.90

Calls

no outgoing calls

Tested by 4

test_pydevd_logFunction · 0.72
disable_critical_logFunction · 0.72