# Path: robottools/testrobot/highlighting.py
# class Highlighter(object):
#     def __init__(self, color, stream):
#         self.color = color
#         self.stream = stream
#         self._highlighter = _Highlighter(stream)
# 
#     def __enter__(self):
#         getattr(self._highlighter, self.color)()
#         return self.stream
# 
#     def __exit__(self, *exc):
#         self._highlighter.reset()


import re
import sys
import logging
from robot.output import LOGGER, LEVELS as LOG_LEVELS
from robot.output.loggerhelper import AbstractLogger
from robot.output.pyloggingconf import RobotHandler
    from robot.output.listeners import LibraryListeners
from .highlighting import Highlighter
        LOGGER.unregister_logger(self)
        # unset internal streams
        self._out = self._err = None

    _re_log_level = re.compile('|'.join(r % '|'.join(LOG_LEVELS)
      for r in [r'^\[ ?(%s) ?\] *', r'^\* ?(%s) ?\* *']))

    def message(self, message):
        msg = message.message
        try:
            _, brackets, stars, msg = self._re_log_level.split(msg)
        except ValueError:
            level = message.level
        else:
            level = brackets or stars
        if not self._is_logged(level):
            return

        # select streams to use
        if level == 'INFO':
            stream = self._out or sys.__stdout__
        else:
            stream = self._err or sys.__stderr__
        #... and finally write the message
        stream.write("[ ")
        try:
            color = LOG_LEVEL_COLORS[level]
        except KeyError:
            stream.write(level)
        else:

# Path: robottools/testrobot/highlighting.py
# class Highlighter(object):
#     def __init__(self, color, stream):
#         self.color = color
#         self.stream = stream
#         self._highlighter = _Highlighter(stream)
# 
#     def __enter__(self):
#         getattr(self._highlighter, self.color)()
#         return self.stream
# 
#     def __exit__(self, *exc):
#         self._highlighter.reset()


# Path: robottools/testrobot/output.py
import re
import sys
import logging
from robot.output import LOGGER, LEVELS as LOG_LEVELS
from robot.output.loggerhelper import AbstractLogger
from robot.output.pyloggingconf import RobotHandler
    from robot.output.listeners import LibraryListeners
from .highlighting import Highlighter

        LOGGER.unregister_logger(self)
        # unset internal streams
        self._out = self._err = None

    _re_log_level = re.compile('|'.join(r % '|'.join(LOG_LEVELS)
      for r in [r'^\[ ?(%s) ?\] *', r'^\* ?(%s) ?\* *']))

    def message(self, message):
        msg = message.message
        try:
            _, brackets, stars, msg = self._re_log_level.split(msg)
        except ValueError:
            level = message.level
        else:
            level = brackets or stars
        if not self._is_logged(level):
            return

        # select streams to use
        if level == 'INFO':
            stream = self._out or sys.__stdout__
        else:
            stream = self._err or sys.__stderr__
        #... and finally write the message
        stream.write("[ ")
        try:
            color = LOG_LEVEL_COLORS[level]
        except KeyError:
            stream.write(level)
        else:

            with Highlighter(color, stream) as hl: