<commit_before>"""Lightbus logging setup

Credit to: https://github.com/borntyping/python-colorlog

This has been vendored to minimise dependencies and allow for
customisation in the long term.

"""

import logging
import sys

__all__ = ("escape_codes", "default_log_colors", "LightbusFormatter")

# The default colors to use for the debug levels
default_log_colors = {
    "DEBUG": "white",
    "INFO": "green",
    "WARNING": "yellow",
    "ERROR": "red",
    "CRITICAL": "bold_red",
}

# The default format to use for each style
default_formats = {
    "%": {
        "DEBUG": "%(log_color)s%(name)s | %(msg)s",
        "INFO": "%(log_color)s%(name)s | %(msg)s",
        "WARNING": "%(log_color)s%(name)s | %(msg)s",
        "ERROR": "%(log_color)s%(name)s | ERROR: %(msg)s (%(module)s:%(lineno)d)",
        "CRITICAL": "%(log_color)s%(name)s | CRITICAL: %(msg)s",
    },
    "{": "{log_color}{levelname}:{name}:{message}",
    "$": "${log_color}${levelname}:${name}:${message}",
}


def esc(*x):
    return "\033[" + ";".join(x) + "m"


escape_codes = {"reset": esc("0"), "bold": esc("01"), "thin": esc("02")}

# The color names
COLORS = ["black", "red", "green", "yellow", "blue", "purple", "cyan", "white"]

PREFIXES = [
    # Foreground without prefix
    ("3", ""),
    ("01;3", "bold_"),
    ("02;3", "thin_"),
    # Foreground with fg_ prefix
    ("3", "fg_"),
    ("01;3", "fg_bold_"),
    ("02;3", "fg_thin_"),
    # Background with bg_ prefix - bold/light works differently
    ("4", "bg_"),
    ("10", "bg_bold_"),
]

for prefix, prefix_name in PREFIXES:
    for code, name in enumerate(COLORS):
        escape_codes[prefix_name + name] = esc(prefix + str(code))<commit_msg>Adding time to redis logging<commit_after>"""Lightbus logging setup

Credit to: https://github.com/borntyping/python-colorlog

This has been vendored to minimise dependencies and allow for
customisation in the long term.

"""

import logging
import sys

__all__ = ("escape_codes", "default_log_colors", "LightbusFormatter")

# The default colors to use for the debug levels
default_log_colors = {
    "DEBUG": "white",
    "INFO": "green",
    "WARNING": "yellow",
    "ERROR": "red",
    "CRITICAL": "bold_red",
}

# The default format to use for each style
default_formats = {
    "%": {
        "DEBUG": "%(log_color)s%(asctime)s %(name)s | %(msg)s",
        "INFO": "%(log_color)s%(asctime)s %(name)s | %(msg)s",
        "WARNING": "%(log_color)s%(asctime)s %(name)s | %(msg)s",
        "ERROR": "%(log_color)s%(asctime)s %(name)s | ERROR: %(msg)s (%(module)s:%(lineno)d)",
        "CRITICAL": "%(log_color)s%(asctime)s %(name)s | CRITICAL: %(msg)s",
    },
    "{": "{log_color}{asctime} {levelname}:{name}:{message}",
    "$": "${log_color}${asctime} ${levelname}:${name}:${message}",
}


def esc(*x):
    return "\033[" + ";".join(x) + "m"


escape_codes = {"reset": esc("0"), "bold": esc("01"), "thin": esc("02")}

# The color names
COLORS = ["black", "red", "green", "yellow", "blue", "purple", "cyan", "white"]

PREFIXES = [
    # Foreground without prefix
    ("3", ""),
    ("01;3", "bold_"),
    ("02;3", "thin_"),
    # Foreground with fg_ prefix
    ("3", "fg_"),
    ("01;3", "fg_bold_"),
    ("02;3", "fg_thin_"),
    # Background with bg_ prefix - bold/light works differently
    ("4", "bg_"),
    ("10", "bg_bold_"),
]

for prefix, prefix_name in PREFIXES:
    for code, name in enumerate(COLORS):
        escape_codes[prefix_name + name] = esc(prefix + str(code))
{'fraction_non_alphanumeric': 0.21601382488479262, 'fraction_numerical': 0.014400921658986175, 'mean_word_length': 3.975644699140401, 'pattern_counts': {'":': 32, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6910531', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1274, 'n_words': 304}