From b7f6f77a62eef943a0ceac4e25663f46ce9f2a56 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 21 Nov 2024 18:40:03 +0000 Subject: [PATCH] fix logging syntax --- main.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 535b447..b9ffafb 100644 --- a/main.py +++ b/main.py @@ -1,10 +1,10 @@ import requests import time import logging -from logging.handlers import RotatingFileHandler from datetime import datetime import subprocess import os +import sys import threading from dotenv import load_dotenv @@ -14,21 +14,22 @@ from KubernetesLogFormatter import KubernetesLogFormatter # Configure logging -log_formatter = KubernetesFormatter() +logger = logging.getLogger() +log_formatter = KubernetesLogFormatter() # StreamHandler for stdout (INFO and below) -stdout_handler = logger.StreamHandler(sys.stdout) -stdout_handler.setLevel(logger.INFO) +stdout_handler = logging.StreamHandler(sys.stdout) +stdout_handler.setLevel(logging.INFO) stdout_handler.setFormatter(log_formatter) # StreamHandler for stderr (WARNING and above) -stderr_handler = logger.StreamHandler(sys.stderr) -stderr_handler.setLevel(logger.WARNING) +stderr_handler = logging.StreamHandler(sys.stderr) +stderr_handler.setLevel(logging.WARNING) stderr_handler.setFormatter(log_formatter) # Initialize logger -logger = logger.getLogger() -logger.setLevel(logger.DEBUG) +logger = logging.getLogger() +logger.setLevel(logging.DEBUG) # Add handlers to logger logger.addHandler(stdout_handler)