4242
4343
4444def init_loggers (
45- config : ReportingConfig | None = None ,
45+ config : GraphRagConfig | None = None ,
4646 root_dir : str | None = None ,
4747 log_level : int | str = logging .INFO ,
4848 enable_console : bool = False ,
@@ -57,8 +57,8 @@ def init_loggers(
5757
5858 Parameters
5959 ----------
60- config : ReportingConfig | None, default=None
61- The reporting configuration. If None, defaults to file-based reporting.
60+ config : GraphRagConfig | None, default=None
61+ The GraphRAG configuration. If None, defaults to file-based reporting.
6262 root_dir : str | None, default=None
6363 The root directory for file-based logging.
6464 log_level : Union[int, str], default=logging.INFO
@@ -75,16 +75,21 @@ def init_loggers(
7575 # Import BlobWorkflowLogger here to avoid circular imports
7676 from graphrag .logger .blob_workflow_logger import BlobWorkflowLogger
7777
78- # If log_file is provided directly, override config to use file-based logging
78+ # Extract reporting config from GraphRagConfig if provided
79+ reporting_config : ReportingConfig
7980 if log_file :
81+ # If log_file is provided directly, override config to use file-based logging
8082 log_path = Path (log_file )
81- config = ReportingConfig (
83+ reporting_config = ReportingConfig (
8284 type = ReportingType .file ,
8385 base_dir = str (log_path .parent ),
8486 )
85- elif config is None :
87+ elif config is not None :
88+ # Use the reporting configuration from GraphRagConfig
89+ reporting_config = config .reporting
90+ else :
8691 # Default to file-based logging if no config provided (maintains backward compatibility)
87- config = ReportingConfig (base_dir = "logs" , type = ReportingType .file )
92+ reporting_config = ReportingConfig (base_dir = "logs" , type = ReportingType .file )
8893
8994 # Convert string log level to numeric value if needed
9095 if isinstance (log_level , str ):
@@ -113,7 +118,7 @@ def init_loggers(
113118
114119 # Add handlers based on configuration
115120 handler : logging .Handler
116- match config .type :
121+ match reporting_config .type :
117122 case ReportingType .file :
118123 if log_file :
119124 # Use the specific log file provided
@@ -122,7 +127,7 @@ def init_loggers(
122127 handler = logging .FileHandler (str (log_file_path ), mode = "a" )
123128 else :
124129 # Use the config-based file path
125- log_dir = Path (root_dir or "" ) / (config .base_dir or "" )
130+ log_dir = Path (root_dir or "" ) / (reporting_config .base_dir or "" )
126131 log_dir .mkdir (parents = True , exist_ok = True )
127132 log_file_path = log_dir / "logs.txt"
128133 handler = logging .FileHandler (str (log_file_path ), mode = "a" )
@@ -136,10 +141,10 @@ def init_loggers(
136141 logger .addHandler (handler )
137142 case ReportingType .blob :
138143 handler = BlobWorkflowLogger (
139- config .connection_string ,
140- config .container_name ,
141- base_dir = config .base_dir ,
142- storage_account_blob_url = config .storage_account_blob_url ,
144+ reporting_config .connection_string ,
145+ reporting_config .container_name ,
146+ base_dir = reporting_config .base_dir ,
147+ storage_account_blob_url = reporting_config .storage_account_blob_url ,
143148 )
144149 logger .addHandler (handler )
145150
0 commit comments