mirror of
https://github.com/d9pouces/id_configurator.git
synced 2026-11-09 01:47:21 +01:00
feat: new configurations for APK/Java/Python/Yum
Signed-off-by: d9pouces <github@19pouces.net>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import logging
|
||||
|
||||
import typer
|
||||
|
||||
from id_tools.build import app as build_app
|
||||
|
||||
SUCCESS = 25
|
||||
|
||||
|
||||
class ColorFormatter(logging.Formatter):
|
||||
"""Logging formatter that adds ANSI color codes based on log level."""
|
||||
|
||||
RESET = "\033[0m"
|
||||
COLORS = {
|
||||
logging.DEBUG: "\033[90m", # gris
|
||||
logging.INFO: "\033[34m", # bleu
|
||||
SUCCESS: "\033[32m", # vert
|
||||
logging.WARNING: "\033[33m", # orange
|
||||
logging.ERROR: "\033[31m", # rouge
|
||||
logging.CRITICAL: "\033[1;31m", # rouge gras
|
||||
}
|
||||
|
||||
def format(self, record):
|
||||
color = self.COLORS.get(record.levelno, self.RESET)
|
||||
message = super().format(record)
|
||||
return f"{color}{message}{self.RESET}"
|
||||
|
||||
|
||||
def setup_logging():
|
||||
handler = logging.StreamHandler()
|
||||
handler.setFormatter(ColorFormatter("%(message)s"))
|
||||
logging.root.addHandler(handler)
|
||||
logging.root.setLevel(logging.INFO)
|
||||
|
||||
|
||||
app = typer.Typer()
|
||||
|
||||
|
||||
@app.callback()
|
||||
def main():
|
||||
setup_logging()
|
||||
|
||||
|
||||
app.add_typer(build_app, name="build")
|
||||
if __name__ == "__main__":
|
||||
app()
|
||||
Reference in New Issue
Block a user