22import sys
33
44from ..assignment import AssignmentConfig
5- from ..cohort .cohort_sync_config import (
6- CohortSyncConfig ,
7- DEFAULT_COHORT_SYNC_URL ,
8- EU_COHORT_SYNC_URL ,
9- )
5+ from ..cohort .cohort_sync_config import CohortSyncConfig , DEFAULT_COHORT_SYNC_URL , EU_COHORT_SYNC_URL
106from ..server_zone import ServerZone
117
12- DEFAULT_SERVER_URL = " https://api.lab.amplitude.com"
13- EU_SERVER_URL = " https://flag.lab.eu.amplitude.com"
8+ DEFAULT_SERVER_URL = ' https://api.lab.amplitude.com'
9+ EU_SERVER_URL = ' https://flag.lab.eu.amplitude.com'
1410
15- DEFAULT_STREAM_URL = " https://stream.lab.amplitude.com"
16- EU_STREAM_SERVER_URL = " https://stream.lab.eu.amplitude.com"
11+ DEFAULT_STREAM_URL = ' https://stream.lab.amplitude.com'
12+ EU_STREAM_SERVER_URL = ' https://stream.lab.eu.amplitude.com'
1713
1814
1915class LocalEvaluationConfig :
2016 """Experiment Local Client Configuration"""
2117
22- def __init__ (
23- self ,
24- debug : bool = False ,
25- server_url : str = DEFAULT_SERVER_URL ,
26- server_zone : ServerZone = ServerZone .US ,
27- flag_config_polling_interval_millis : int = 30000 ,
28- flag_config_poller_request_timeout_millis : int = 10000 ,
29- stream_updates : bool = False ,
30- stream_server_url : str = DEFAULT_STREAM_URL ,
31- stream_flag_conn_timeout : int = 1500 ,
32- assignment_config : AssignmentConfig = None ,
33- cohort_sync_config : CohortSyncConfig = None ,
34- logger : logging .Logger = None ,
35- ):
18+ def __init__ (self , debug : bool = False ,
19+ server_url : str = DEFAULT_SERVER_URL ,
20+ server_zone : ServerZone = ServerZone .US ,
21+ flag_config_polling_interval_millis : int = 30000 ,
22+ flag_config_poller_request_timeout_millis : int = 10000 ,
23+ stream_updates : bool = False ,
24+ stream_server_url : str = DEFAULT_STREAM_URL ,
25+ stream_flag_conn_timeout : int = 1500 ,
26+ assignment_config : AssignmentConfig = None ,
27+ cohort_sync_config : CohortSyncConfig = None ,
28+ logger : logging .Logger = None ):
3629 """
3730 Initialize a config
3831 Parameters:
@@ -46,7 +39,7 @@ def __init__(
4639 assignment_config (AssignmentConfig): The assignment configuration.
4740 cohort_sync_config (CohortSyncConfig): The cohort sync configuration.
4841 logger (logging.Logger): Optional logger instance. If provided, this logger will be used instead of
49- creating a new one. The debug flag will still be applied to set the log level .
42+ creating a new one. The debug flag only applies when no logger is provided .
5043
5144 Returns:
5245 The config object
@@ -57,20 +50,16 @@ def __init__(
5750 self .cohort_sync_config = cohort_sync_config
5851 if server_url == DEFAULT_SERVER_URL and server_zone == ServerZone .EU :
5952 self .server_url = EU_SERVER_URL
60- if (
61- cohort_sync_config is not None
62- and cohort_sync_config .cohort_server_url == DEFAULT_COHORT_SYNC_URL
63- ):
53+ if (cohort_sync_config is not None and
54+ cohort_sync_config .cohort_server_url == DEFAULT_COHORT_SYNC_URL ):
6455 self .cohort_sync_config .cohort_server_url = EU_COHORT_SYNC_URL
6556
6657 self .stream_server_url = stream_server_url
6758 if stream_server_url == DEFAULT_SERVER_URL and server_zone == ServerZone .EU :
6859 self .stream_server_url = EU_STREAM_SERVER_URL
6960
7061 self .flag_config_polling_interval_millis = flag_config_polling_interval_millis
71- self .flag_config_poller_request_timeout_millis = (
72- flag_config_poller_request_timeout_millis
73- )
62+ self .flag_config_poller_request_timeout_millis = flag_config_poller_request_timeout_millis
7463 self .stream_updates = stream_updates
7564 self .stream_flag_conn_timeout = stream_flag_conn_timeout
7665 self .assignment_config = assignment_config
@@ -82,10 +71,9 @@ def __init__(
8271 if not self .logger .handlers :
8372 handler = logging .StreamHandler (sys .stderr )
8473 self .logger .addHandler (handler )
74+ # Set log level: DEBUG if debug=True, otherwise WARNING
75+ # Only apply debug flag to default logger, not user-provided loggers
76+ log_level = logging .DEBUG if self .debug else logging .WARNING
77+ self .logger .setLevel (log_level )
8578 else :
8679 self .logger = logger
87-
88- # Set log level: DEBUG if debug=True, otherwise WARNING
89- # This applies to both provided loggers and the default logger
90- log_level = logging .DEBUG if self .debug else logging .WARNING
91- self .logger .setLevel (log_level )
0 commit comments