@@ -163,27 +163,42 @@ def configure(
163
163
enabled
164
164
"""
165
165
166
+ write_to_log_file = log_file is not None or log_file == ""
167
+
166
168
if multitenant :
169
+ # The default logging config for multi-tenant mode specifies a log file
170
+ # location if --log-file is specified on startup and a config file is not.
171
+ # When all else fails, the default single-tenant config file is used.
172
+ if not log_config_path :
173
+ log_config_path = (
174
+ cls .default_multitenant_config_path_ini
175
+ if write_to_log_file
176
+ else cls .default_config_path_ini
177
+ )
178
+
167
179
cls ._configure_multitenant_logging (
168
- log_config_path = log_config_path
169
- or DEFAULT_MULTITENANT_LOGGING_CONFIG_PATH_INI ,
180
+ log_config_path = log_config_path ,
170
181
log_level = log_level ,
171
182
log_file = log_file ,
172
183
)
173
184
else :
185
+ # The default config for single-tenant mode does not specify a log file
186
+ # location. This is a check that requires a log file path to be provided if
187
+ # --log-file is specified on startup and a config file is not.
188
+ if not log_config_path and write_to_log_file and not log_file :
189
+ raise ValueError (
190
+ "log_file (--log-file) must be provided in single-tenant mode "
191
+ "using the default config since a log file path is not set."
192
+ )
193
+
174
194
cls ._configure_logging (
175
- log_config_path = log_config_path or DEFAULT_LOGGING_CONFIG_PATH_INI ,
195
+ log_config_path = log_config_path or cls . default_config_path_ini ,
176
196
log_level = log_level ,
177
197
log_file = log_file ,
178
198
)
179
199
180
200
@classmethod
181
201
def _configure_logging (cls , log_config_path , log_level , log_file ):
182
- if log_file is not None and log_file == "" :
183
- raise ValueError (
184
- "log_file (--log-file) must be provided in singletenant mode."
185
- )
186
-
187
202
# Setup log config and log file if provided
188
203
cls ._setup_log_config_file (log_config_path , log_file )
189
204
@@ -199,10 +214,6 @@ def _configure_logging(cls, log_config_path, log_level, log_file):
199
214
200
215
@classmethod
201
216
def _configure_multitenant_logging (cls , log_config_path , log_level , log_file ):
202
- # Unlike in singletenant mode, the defualt config for multitenant mode
203
- # specifies a default log_file if one is not explicitly provided
204
- # so we don't need the same check here
205
-
206
217
# Setup log config and log file if provided
207
218
cls ._setup_log_config_file (log_config_path , log_file )
208
219
0 commit comments