Secrets tests passing. nix fmt doesn't complain

This commit is contained in:
Qubasa
2023-10-17 23:49:16 +02:00
parent 1631dc631b
commit d96ea61243
14 changed files with 281 additions and 139 deletions

View File

@@ -1,5 +1,6 @@
import logging
from typing import Any
from typing import Any, Callable
from pathlib import Path
grey = "\x1b[38;20m"
yellow = "\x1b[33;20m"
@@ -9,11 +10,14 @@ green = "\u001b[32m"
blue = "\u001b[34m"
def get_formatter(color: str) -> logging.Formatter:
reset = "\x1b[0m"
return logging.Formatter(
f"{color}%(levelname)s{reset}:(%(filename)s:%(lineno)d): %(message)s"
)
def get_formatter(color: str) -> Callable[[logging.LogRecord], logging.Formatter]:
def myformatter(record: logging.LogRecord) -> logging.Formatter:
reset = "\x1b[0m"
filepath = Path(record.pathname).resolve()
return logging.Formatter(
f"{filepath}:%(lineno)d::%(funcName)s\n{color}%(levelname)s{reset}: %(message)s"
)
return myformatter
FORMATTER = {
@@ -26,8 +30,8 @@ FORMATTER = {
class CustomFormatter(logging.Formatter):
def format(self, record: Any) -> str:
return FORMATTER[record.levelno].format(record)
def format(self, record: logging.LogRecord) -> str:
return FORMATTER[record.levelno](record).format(record)
def register(level: Any) -> None: