- CitrineOS core extracted (CSMS OCPP 2.0.1) - OpenOCPP extracted (firmware OCPP 1.6J/2.0.1) - ShapeShifter library installed (pip install -e) - ShapeShifter specification extracted - EVerest extracted TODO updated with progress
38 lines
871 B
Python
38 lines
871 B
Python
import logging
|
|
from datetime import datetime
|
|
|
|
from termcolor import colored
|
|
|
|
color_map = {
|
|
logging.DEBUG: "cyan",
|
|
logging.INFO: "green",
|
|
logging.WARNING: "yellow",
|
|
logging.ERROR: "red",
|
|
logging.CRITICAL: "magenta",
|
|
}
|
|
|
|
|
|
class ShapeshifterLogFormatter(logging.Formatter):
|
|
"""
|
|
Formatter for the shapeshifter logs.
|
|
"""
|
|
|
|
def format(self, record):
|
|
"""
|
|
Format log recors using colors.
|
|
"""
|
|
color = color_map[record.levelno]
|
|
return (
|
|
colored(f"{record.levelname:10}", color)
|
|
+ f"{datetime.now().astimezone().isoformat()} - {record.getMessage()}"
|
|
)
|
|
|
|
|
|
handler = logging.StreamHandler()
|
|
handler.setFormatter(ShapeshifterLogFormatter())
|
|
handler.setLevel(logging.DEBUG)
|
|
|
|
logger = logging.getLogger("shapeshifter-uftp")
|
|
logger.addHandler(handler)
|
|
logger.setLevel(logging.DEBUG)
|