# Path: pre_commit/color.py
#     def _enable() -> None:
#         def bool_errcheck(result, func, args):
# def format_color(text: str, color: str, use_color_setting: bool) -> str:
# def use_color(setting: str) -> bool:
# def add_color_option(parser: argparse.ArgumentParser) -> None:
#         STD_ERROR_HANDLE = -12
#         ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4
# RED = '\033[41m'
# GREEN = '\033[42m'
# YELLOW = '\033[43;30m'
# TURQUOISE = '\033[46;30m'
# SUBTLE = '\033[2m'
# NORMAL = '\033[m'
# COLOR_CHOICES = ('auto', 'always', 'never')
# 
# Path: pre_commit/output.py
# def write(s: str, stream: IO[bytes] = sys.stdout.buffer) -> None:
# def write_line_b(
#         s: bytes | None = None,
#         stream: IO[bytes] = sys.stdout.buffer,
#         logfile_name: str | None = None,
# ) -> None:
# def write_line(s: str | None = None, **kwargs: Any) -> None:


import contextlib
import logging
from typing import Generator
from pre_commit import color
from pre_commit import output
from __future__ import annotations



logger = logging.getLogger('pre_commit')

LOG_LEVEL_COLORS = {
    'DEBUG': '',
    'INFO': '',
    'WARNING': color.YELLOW,
    'ERROR': color.RED,
}


class LoggingHandler(logging.Handler):
    def __init__(self, use_color: bool) -> None:
        super().__init__()
        self.use_color = use_color

    def emit(self, record: logging.LogRecord) -> None:
        level_msg = color.format_color(
            f'[{record.levelname}]',
            LOG_LEVEL_COLORS[record.levelname],
            self.use_color,
        )

# Path: pre_commit/color.py
#     def _enable() -> None:
#         def bool_errcheck(result, func, args):
# def format_color(text: str, color: str, use_color_setting: bool) -> str:
# def use_color(setting: str) -> bool:
# def add_color_option(parser: argparse.ArgumentParser) -> None:
#         STD_ERROR_HANDLE = -12
#         ENABLE_VIRTUAL_TERMINAL_PROCESSING = 4
# RED = '\033[41m'
# GREEN = '\033[42m'
# YELLOW = '\033[43;30m'
# TURQUOISE = '\033[46;30m'
# SUBTLE = '\033[2m'
# NORMAL = '\033[m'
# COLOR_CHOICES = ('auto', 'always', 'never')
# 
# Path: pre_commit/output.py
# def write(s: str, stream: IO[bytes] = sys.stdout.buffer) -> None:
# def write_line_b(
#         s: bytes | None = None,
#         stream: IO[bytes] = sys.stdout.buffer,
#         logfile_name: str | None = None,
# ) -> None:
# def write_line(s: str | None = None, **kwargs: Any) -> None:


# Path: pre_commit/logging_handler.py
import contextlib
import logging
from typing import Generator
from pre_commit import color
from pre_commit import output

from __future__ import annotations



logger = logging.getLogger('pre_commit')

LOG_LEVEL_COLORS = {
    'DEBUG': '',
    'INFO': '',
    'WARNING': color.YELLOW,
    'ERROR': color.RED,
}


class LoggingHandler(logging.Handler):
    def __init__(self, use_color: bool) -> None:
        super().__init__()
        self.use_color = use_color

    def emit(self, record: logging.LogRecord) -> None:
        level_msg = color.format_color(
            f'[{record.levelname}]',
            LOG_LEVEL_COLORS[record.levelname],
            self.use_color,
        )

        output.write_line(f'{level_msg} {record.getMessage()}')