class_docstr: context manager version of trace(); can redirect the trace to a file
class_docstr_tok: ["context","manager","version","of","trace","(",")",";","can","redirect","the","trace","to","a","file"]
code: def __enter__(self):
      if self.redirect:
          stderr_handler.flush()
          if self.file_is_stream:
              self.handler = logging.StreamHandler(self.file)
          else:
              self.handler = logging.FileHandler(self.file, self.mode)
          adapter.removeHandler(stderr_handler)
          adapter.addHandler(self.handler)
      self.old_level = adapter.getEffectiveLevel()
      adapter.setLevel(logging.INFO)
      return adapter.info
  
imports: import codecs
  import contextlib
  import locale
  import logging
  import math
  import os
  from functools import partial
  from typing import TextIO, Union
  import dill
label_desc: Use image node_id 2 for calling the TraceManager obj's underlying member method code with example usage: obj.__enter__() and returns: adapter