# 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/logging_handler.py
# 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()}')


import logging
from pre_commit import color
from pre_commit.logging_handler import LoggingHandler
from __future__ import annotations




def _log_record(message, level):
    return logging.LogRecord('name', level, '', 1, message, {}, None)


def test_logging_handler_color(cap_out):
    handler = LoggingHandler(True)
    handler.emit(_log_record('hi', logging.WARNING))
    ret = cap_out.get()

# 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/logging_handler.py
# 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()}')


# Path: tests/logging_handler_test.py
import logging
from pre_commit import color
from pre_commit.logging_handler import LoggingHandler

from __future__ import annotations




def _log_record(message, level):
    return logging.LogRecord('name', level, '', 1, message, {}, None)


def test_logging_handler_color(cap_out):
    handler = LoggingHandler(True)
    handler.emit(_log_record('hi', logging.WARNING))
    ret = cap_out.get()

    assert ret == f'{color.YELLOW}[WARNING]{color.NORMAL} hi\n'