Skip to content

Commit 7f3d868

Browse files
committed
circular loop fix
1 parent d2db7c9 commit 7f3d868

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lxc_autoscale/config.py

-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import Any, Dict, List, Set, Union
66

77
import yaml
8-
from logging_setup import setup_logging # Import the logging setup function
98

109
CONFIG_FILE = "/etc/lxc_autoscale/lxc_autoscale.yaml"
1110

@@ -25,9 +24,6 @@ def load_tier_configurations() -> Dict[str, Dict[str, Any]]:
2524
"""Load and validate tier configurations."""
2625
tier_configs: Dict[str, Dict[str, Any]] = {}
2726

28-
# Setup logging based on the configuration
29-
setup_logging()
30-
3127
for section, values in config.items():
3228
if section.startswith('TIER_'):
3329
tier_name = section[5:]

lxc_autoscale/logging_setup.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import logging # Import the logging module to handle logging throughout the application
22
import os # Import os module to handle directory operations
3-
from config import get_config_value # Import the get_config_value function to retrieve configuration settings
43

5-
# Retrieve the log file path from the configuration
6-
LOG_FILE = get_config_value('DEFAULT', 'log_file', '/var/log/lxc_autoscale.log')
4+
# Removed: from config import get_config_value and global LOG_FILE assignment
75

86
def setup_logging():
97
"""
@@ -13,6 +11,10 @@ def setup_logging():
1311
Log messages will include timestamps and the severity level of the message.
1412
"""
1513

14+
# Lazy import to break circular dependency
15+
from config import get_config_value
16+
LOG_FILE = get_config_value('DEFAULT', 'log_file', '/var/log/lxc_autoscale.log')
17+
1618
# Ensure the directory for the log file exists
1719
log_dir = os.path.dirname(LOG_FILE)
1820
if not os.path.exists(log_dir):

0 commit comments

Comments
 (0)