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","."]
docstr: Creates a new plugin to capture log messages.
  
  The formatter can be safely shared across all handlers so
  create a single one for the entire test session here.
docstr_tok: ["Creates","a","new","plugin","to","capture","log","messages",".","The","formatter","can","be","safely","shared","across","all","handlers","so","create","a","single","one","for","the","entire","test","session","here","."]
code: def __init__(self, config):
      """Creates a new plugin to capture log messages.
  
      The formatter can be safely shared across all handlers so
      create a single one for the entire test session here.
      """
      self._config = config
  
      self.print_logs = get_option_ini(config, "log_print")
      self.formatter = self._create_formatter(
          get_option_ini(config, "log_format"),
          get_option_ini(config, "log_date_format"),
      )
      self.log_level = get_actual_log_level(config, "log_level")
  
      self.log_file_level = get_actual_log_level(
          config, "log_file_level"
      )
      self.log_file_format = get_option_ini(
          config, "log_file_format", "log_format"
      )
      self.log_file_date_format = get_option_ini(
          config, "log_file_date_format", "log_date_format"
      )
      self.log_file_formatter = logging.Formatter(
          self.log_file_format, datefmt=self.log_file_date_format
      )
  
      log_file = get_option_ini(config, "log_file")
      if log_file:
          self.log_file_handler = logging.FileHandler(
              log_file, mode="w", encoding="UTF-8"
          )
          self.log_file_handler.setFormatter(self.log_file_formatter)
      else:
          self.log_file_handler = None
  
      self.log_cli_handler = None
  
      self.live_logs_context = lambda: dummy_context_manager()
      # Note that the lambda for the live_logs_context is needed because
      # live_logs_context can otherwise not be entered multiple times due
      # to limitations of contextlib.contextmanager.
  
      if self._log_cli_enabled():
          self._setup_cli_logging()
  
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 1 to create a new LoggingPlugin object from inherited base classes: object with example: obj = LoggingPlugin(config)