diff --git a/README.md b/README.md index a338113..5ab3905 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +[![Supported Python Versions](https://img.shields.io/pypi/pyversions/simple-http-checker-PedroLima)](https://pypi.org/project/simple-http-checker-PedroLima/) +[![PyPI version](https://img.shields.io/pypi/v/simple-http-checker-PedroLima)](https://pypi.org/project/simple-http-checker-PedroLima/) +[![Downloads](https://pepy.tech/badge/simple-http-checker-PedroLima/month)](https://pepy.tech/project/simple-http-checker-PedroLima) +[![CI/CD](https://github.com/PedroBizachi/python-devops-cicd-project/actions/workflows/python-ci.yaml/badge.svg)](https://github.com/PedroBizachi/python-devops-cicd-project/actions/workflows/python-ci.yaml) +[![Publish](https://github.com/PedroBizachi/python-devops-cicd-project/actions/workflows/publish.yaml/badge.svg)](https://github.com/PedroBizachi/python-devops-cicd-project/actions/workflows/publish.yaml) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) # Python for DevOps: CI/CD for Python Projects diff --git a/pyproject.toml b/pyproject.toml index 4c2be65..8dd2219 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ version = "1.2.0" description = "A simple CLI tool to check the status of URLs." readme = "README.md" requires-python = ">=3.9" -dependencies = ["click>=8.0,<9.0", "requests>=2.28,<3.0"] +dependencies = ["click>=8.0,<9.0", "requests>=2.28,<3.0", "rich>=15.0,<16.0"] authors = [{ name = "Pedro Lima" }, { email = "bizak.dev@outlook.com" }] license = { text = "MIT" } classifiers = [ @@ -29,7 +29,7 @@ classifiers = [ [project.urls] Homepage = "https://github.com/PedroBizachi/python-devops-cicd-project" -Documentation = "https://github.com/lm-academy/python-devops-cicd-project/blob/main/README.md" +Documentation = "https://github.com/PedroBizachi/python-devops-cicd-project/blob/main/README.md" Repository = "https://github.com/PedroBizachi/python-devops-cicd-project" Issues = "https://github.com/PedroBizachi/python-devops-cicd-project/issues" Changelog = "https://github.com/PedroBizachi/python-devops-cicd-project/blob/main/CHANGELOG.md" diff --git a/src/simple_http_checker/cli.py b/src/simple_http_checker/cli.py index c82fe3b..f635c47 100644 --- a/src/simple_http_checker/cli.py +++ b/src/simple_http_checker/cli.py @@ -1,43 +1,22 @@ import logging from collections.abc import Collection -from typing import ClassVar import click +from rich.logging import RichHandler from simple_http_checker.checker import check_urls - -class ColoredLevelFormatter(logging.Formatter): - LEVEL_COLORS: ClassVar[dict[int, str]] = { - logging.DEBUG: "cyan", - logging.INFO: "green", - logging.WARNING: "yellow", - logging.ERROR: "red", - logging.CRITICAL: "magenta", - } - - def format(self, record: logging.LogRecord) -> str: - original_levelname = record.levelname - color = self.LEVEL_COLORS.get(record.levelno) - if color: - record.levelname = click.style(record.levelname, fg=color) - - try: - return super().format(record) - finally: - record.levelname = original_levelname - - -handler = logging.StreamHandler() -handler.setFormatter( - ColoredLevelFormatter( - fmt="[%(asctime)s] %(levelname)s: %(message)s", - datefmt="%Y-%m-%d %H:%M:%S", - ) +logging.basicConfig( + level=logging.INFO, + format="%(message)s", + datefmt="%Y-%m-%d %H:%M:%S", + handlers=[ + RichHandler( + show_path=False, + ) + ], ) -logging.basicConfig(level=logging.INFO, handlers=[handler]) - logger = logging.getLogger(__name__)