code: def configure_logging(
      verbosity: Verbosity,
      *,
      progress_bar_friendly: bool = True,
      manage_root_logger: bool = False,
      plugin_manager: pluggy.PluginManager | None = None,
  ):
      """Set up logging.
  
      Before calling :func:`ocrmypdf.ocr()`, you can use this function to
      configure logging if you want ocrmypdf's output to look like the ocrmypdf
      command line interface. It will register log handlers, log filters, and
      formatters, configure color logging to standard error, and adjust the log
      levels of third party libraries. Details of this are fine-tuned and subject
      to change. The ``verbosity`` argument is equivalent to the argument
      ``--verbose`` and applies those settings. If you have a wrapper
      script for ocrmypdf and you want it to be very similar to ocrmypdf, use this
      function; if you are using ocrmypdf as part of an application that manages
      its own logging, you probably do not want this function.
  
      If this function is not called, ocrmypdf will not configure logging, and it
      is up to the caller of ``ocrmypdf.ocr()`` to set up logging as it wishes using
      the Python standard library's logging module. If this function is called,
      the caller may of course make further adjustments to logging.
  
      Regardless of whether this function is called, ocrmypdf will perform all of
      its logging under the ``"ocrmypdf"`` logging namespace. In addition,
      ocrmypdf imports pdfminer, which logs under ``"pdfminer"``. A library user
      may wish to configure both; note that pdfminer is extremely chatty at the
      log level ``logging.INFO``.
  
      This function does not set up the ``debug.log`` log file that the command
      line interface does at certain verbosity levels. Applications should configure
      their own debug logging.
  
      Args:
          verbosity: Verbosity level.
          progress_bar_friendly: If True (the default), install a custom log handler
              that is compatible with progress bars and colored output.
          manage_root_logger: Configure the process's root logger.
          plugin_manager: The plugin manager, used for obtaining the custom log handler.
  
      Returns:
          The toplevel logger for ocrmypdf (or the root logger, if we are managing it).
      """
      prefix = "" if manage_root_logger else "ocrmypdf"
  
      log = logging.getLogger(prefix)
      log.setLevel(logging.DEBUG)
  
      console = None
      if plugin_manager and progress_bar_friendly:
          console = plugin_manager.hook.get_logging_console()
  
      if not console:
          console = logging.StreamHandler(stream=sys.stderr)
  
      if verbosity < 0:
          console.setLevel(logging.ERROR)
      elif verbosity >= 1:
          console.setLevel(logging.DEBUG)
      else:
          console.setLevel(logging.INFO)
  
      console.addFilter(PageNumberFilter())
  
      if verbosity >= 2:
          fmt = "%(levelname)7s %(name)s -%(pageno)s %(message)s"
      else:
          fmt = "%(pageno)s%(message)s"
  
      formatter = None
  
      if not formatter:
          formatter = logging.Formatter(fmt=fmt)
  
      console.setFormatter(formatter)
      log.addHandler(console)
  
      if verbosity <= 1:
          pdfminer_log = logging.getLogger("pdfminer")
          pdfminer_log.setLevel(logging.ERROR)
          pil_log = logging.getLogger("PIL")
          pil_log.setLevel(logging.INFO)
  
      if manage_root_logger:
          logging.captureWarnings(True)
  
      return log
  
imports: from __future__ import annotations
  import logging
  import os
  import sys
  import threading
  from argparse import Namespace
  from collections.abc import Iterable, Sequence
  from enum import IntEnum
  from io import IOBase
  from pathlib import Path
  from typing import AnyStr, BinaryIO, Union
  from warnings import warn
  import pluggy
  from ocrmypdf._logging import PageNumberFilter
  from ocrmypdf._pipelines.hocr_to_ocr_pdf import run_hocr_to_ocr_pdf_pipeline
  from ocrmypdf._pipelines.ocr import run_pipeline, run_pipeline_cli
  from ocrmypdf._pipelines.pdf_to_hocr import run_hocr_pipeline
  from ocrmypdf._plugin_manager import get_plugin_manager
  from ocrmypdf._validation import check_options
  from ocrmypdf.cli import ArgumentParser, get_parser
  from ocrmypdf.helpers import is_iterable_notstr
label_desc: Use image node_id 1 for calling a global function with example usage: configure_logging(verbosity) and returns: log