class_docstr: Attaches to the logging module and captures log messages for each test.
      
class_docstr_tok: ["Attaches","to","the","logging","module","and","captures","log","messages","for","each","test","."]
code: def _setup_cli_logging(self):
      config = self._config
      terminal_reporter = config.pluginmanager.get_plugin(
          "terminalreporter"
      )
      if terminal_reporter is None:
          # terminal reporter is disabled e.g. by pytest-xdist.
          return
  
      capture_manager = config.pluginmanager.get_plugin(
          "capturemanager"
      )
      # if capturemanager plugin is disabled, live logging still works.
      log_cli_handler = _LiveLoggingStreamHandler(
          terminal_reporter, capture_manager
      )
  
      log_cli_formatter = self._create_formatter(
          get_option_ini(config, "log_cli_format", "log_format"),
          get_option_ini(
              config, "log_cli_date_format", "log_date_format"
          ),
      )
  
      log_cli_level = get_actual_log_level(
          config, "log_cli_level", "log_level"
      )
      self.log_cli_handler = log_cli_handler
      self.live_logs_context = lambda: catching_logs(
          log_cli_handler,
          formatter=log_cli_formatter,
          level=log_cli_level,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import logging
  import re
  from contextlib import contextmanager
  import py
  import six
  import pytest
  from _pytest.compat import dummy_context_manager
  from _pytest.config import create_terminal_writer
  from _pytest.pathlib import Path
label_desc: Use image node_id 3 for calling the LoggingPlugin obj's underlying member method code with example usage: obj._setup_cli_logging() without return types