Skip to content

Commit

Permalink
fix logging syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
alexboden committed Nov 21, 2024
1 parent 2a59c60 commit b7f6f77
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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)
Expand Down

0 comments on commit b7f6f77

Please sign in to comment.