diff --git a/axonops/logger.py b/axonops/logger.py index 796b8ff..cd525a8 100644 --- a/axonops/logger.py +++ b/axonops/logger.py @@ -13,6 +13,7 @@ # limitations under the License. import logging import sys +from colorlog import ColoredFormatter def setup_logger(name='AxonOpsLogger', level=logging.INFO): @@ -23,9 +24,19 @@ def setup_logger(name='AxonOpsLogger', level=logging.INFO): # Create handlers console_handler = logging.StreamHandler(sys.stdout) console_handler.setLevel(level) + # Define a colored formatter + formatter = ColoredFormatter( + '%(log_color)s%(asctime)s - %(name)s - %(levelname)s - %(funcName)s - %(message)s', + datefmt='%Y-%m-%d %H:%M:%S', + log_colors={ + 'DEBUG': 'cyan', + 'INFO': 'green', + 'WARNING': 'yellow', + 'ERROR': 'red', + 'CRITICAL': 'bold_red', + } + ) - # Create formatters and add them to handlers - formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(funcName)s - %(message)s') console_handler.setFormatter(formatter) # Clear existing handlers, and add new ones diff --git a/requirements.txt b/requirements.txt index 579e47b..f100e63 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ certifi==2024.8.30 charset-normalizer==3.4.0 cloudscraper==1.2.71 +colorlog==6.8.2 idna==3.10 numpy==2.1.2 pandas==2.2.3 @@ -12,6 +13,7 @@ PyYAML==6.0.2 requests==2.32.3 requests-toolbelt==1.0.0 six==1.16.0 +termcolor==2.3.0 tzdata==2024.2 urllib3==2.2.3 -yaspin \ No newline at end of file +yaspin==3.1.0